Implemented frog_variant property
This commit is contained in:
parent
4cc468b919
commit
7f5b7f8f0a
9 changed files with 38 additions and 4 deletions
|
@ -0,0 +1,7 @@
|
||||||
|
package lol.pyr.znpcsplus.util;
|
||||||
|
|
||||||
|
public enum FrogVariant {
|
||||||
|
TEMPERATE,
|
||||||
|
WARM,
|
||||||
|
COLD
|
||||||
|
}
|
|
@ -248,6 +248,7 @@ public class ZNpcsPlus extends JavaPlugin {
|
||||||
versions.put(ServerVersion.V_1_15, LazyLoader.of(V1_15MetadataFactory::new));
|
versions.put(ServerVersion.V_1_15, LazyLoader.of(V1_15MetadataFactory::new));
|
||||||
versions.put(ServerVersion.V_1_16, LazyLoader.of(V1_16MetadataFactory::new));
|
versions.put(ServerVersion.V_1_16, LazyLoader.of(V1_16MetadataFactory::new));
|
||||||
versions.put(ServerVersion.V_1_17, LazyLoader.of(V1_17MetadataFactory::new));
|
versions.put(ServerVersion.V_1_17, LazyLoader.of(V1_17MetadataFactory::new));
|
||||||
|
versions.put(ServerVersion.V_1_19, LazyLoader.of(V1_19MetadataFactory::new));
|
||||||
|
|
||||||
ServerVersion version = packetEvents.getServerManager().getVersion();
|
ServerVersion version = packetEvents.getServerManager().getVersion();
|
||||||
if (versions.containsKey(version)) return versions.get(version).get();
|
if (versions.containsKey(version)) return versions.get(version).get();
|
||||||
|
@ -286,6 +287,7 @@ public class ZNpcsPlus extends JavaPlugin {
|
||||||
registerEnumParser(manager, ParrotVariant.class, incorrectUsageMessage);
|
registerEnumParser(manager, ParrotVariant.class, incorrectUsageMessage);
|
||||||
registerEnumParser(manager, SpellType.class, incorrectUsageMessage);
|
registerEnumParser(manager, SpellType.class, incorrectUsageMessage);
|
||||||
registerEnumParser(manager, FoxVariant.class, incorrectUsageMessage);
|
registerEnumParser(manager, FoxVariant.class, incorrectUsageMessage);
|
||||||
|
registerEnumParser(manager, FrogVariant.class, incorrectUsageMessage);
|
||||||
|
|
||||||
manager.registerCommand("npc", new MultiCommand(loadHelpMessage("root"))
|
manager.registerCommand("npc", new MultiCommand(loadHelpMessage("root"))
|
||||||
.addSubcommand("create", new CreateCommand(npcRegistry, typeRegistry))
|
.addSubcommand("create", new CreateCommand(npcRegistry, typeRegistry))
|
||||||
|
|
|
@ -127,6 +127,7 @@ public class PropertySetCommand implements CommandHandler {
|
||||||
if (type == BlockState.class) return context.suggestLiteral("hand", "looking_at", "block");
|
if (type == BlockState.class) return context.suggestLiteral("hand", "looking_at", "block");
|
||||||
if (type == SpellType.class) return context.suggestEnum(SpellType.values());
|
if (type == SpellType.class) return context.suggestEnum(SpellType.values());
|
||||||
if (type == FoxVariant.class) return context.suggestEnum(FoxVariant.values());
|
if (type == FoxVariant.class) return context.suggestEnum(FoxVariant.values());
|
||||||
|
if (type == FrogVariant.class) return context.suggestEnum(FrogVariant.values());
|
||||||
}
|
}
|
||||||
else if (context.argSize() == 4) {
|
else if (context.argSize() == 4) {
|
||||||
if (type == BlockState.class) {
|
if (type == BlockState.class) {
|
||||||
|
|
|
@ -40,6 +40,7 @@ public class EntityPropertyRegistryImpl implements EntityPropertyRegistry {
|
||||||
registerEnumSerializer(ParrotVariant.class);
|
registerEnumSerializer(ParrotVariant.class);
|
||||||
registerEnumSerializer(SpellType.class);
|
registerEnumSerializer(SpellType.class);
|
||||||
registerEnumSerializer(FoxVariant.class);
|
registerEnumSerializer(FoxVariant.class);
|
||||||
|
registerEnumSerializer(FrogVariant.class);
|
||||||
|
|
||||||
registerType("glow", NamedTextColor.class);
|
registerType("glow", NamedTextColor.class);
|
||||||
registerType("fire", false);
|
registerType("fire", false);
|
||||||
|
@ -133,6 +134,9 @@ public class EntityPropertyRegistryImpl implements EntityPropertyRegistry {
|
||||||
// Pufferfish
|
// Pufferfish
|
||||||
registerType("puff_state", null); // TODO: Make a puff state enum class
|
registerType("puff_state", null); // TODO: Make a puff state enum class
|
||||||
|
|
||||||
|
// Frog
|
||||||
|
registerType("frog_variant", FrogVariant.TEMPERATE);
|
||||||
|
|
||||||
// Tropical Fish
|
// Tropical Fish
|
||||||
registerType("tropical_fish_variant", null); // TODO: Maybe make an enum class for this? its just an int on wiki.vg
|
registerType("tropical_fish_variant", null); // TODO: Maybe make an enum class for this? its just an int on wiki.vg
|
||||||
|
|
||||||
|
@ -148,9 +152,6 @@ public class EntityPropertyRegistryImpl implements EntityPropertyRegistry {
|
||||||
registerType("carpet_color", DyeColor.class); // TODO
|
registerType("carpet_color", DyeColor.class); // TODO
|
||||||
registerType("llama_variant", 0); // TODO
|
registerType("llama_variant", 0); // TODO
|
||||||
|
|
||||||
// Frog
|
|
||||||
registerType("frog_type", null); // TODO: It has a custom type read on wiki.vg
|
|
||||||
|
|
||||||
// Panda
|
// Panda
|
||||||
registerType("panda_sneezing", false); // TODO
|
registerType("panda_sneezing", false); // TODO
|
||||||
registerType("panda_rolling", false); // TODO
|
registerType("panda_rolling", false); // TODO
|
||||||
|
|
|
@ -80,4 +80,7 @@ public interface MetadataFactory {
|
||||||
// Fox
|
// Fox
|
||||||
EntityData foxVariant(int variant);
|
EntityData foxVariant(int variant);
|
||||||
EntityData foxProperties(boolean sitting, boolean crouching, boolean sleeping, boolean facePlanted);
|
EntityData foxProperties(boolean sitting, boolean crouching, boolean sleeping, boolean facePlanted);
|
||||||
|
|
||||||
|
// Frog
|
||||||
|
EntityData frogVariant(int variant);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
package lol.pyr.znpcsplus.metadata;
|
||||||
|
|
||||||
|
import com.github.retrooper.packetevents.protocol.entity.data.EntityData;
|
||||||
|
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||||
|
import lol.pyr.znpcsplus.util.FrogVariant;
|
||||||
|
|
||||||
|
public class V1_19MetadataFactory extends V1_17MetadataFactory {
|
||||||
|
@Override
|
||||||
|
public EntityData frogVariant(int variant) {
|
||||||
|
return newEntityData(17, EntityDataTypes.FROG_VARIANT, variant);
|
||||||
|
}
|
||||||
|
}
|
|
@ -195,6 +195,11 @@ public class V1_8MetadataFactory implements MetadataFactory {
|
||||||
throw new UnsupportedOperationException("The fox properties entity data isn't supported on this version");
|
throw new UnsupportedOperationException("The fox properties entity data isn't supported on this version");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EntityData frogVariant(int variant) {
|
||||||
|
throw new UnsupportedOperationException("The frog variant entity data isn't supported on this version");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EntityData silent(boolean enabled) {
|
public EntityData silent(boolean enabled) {
|
||||||
return newEntityData(4, EntityDataTypes.BYTE, (byte) (enabled ? 1 : 0));
|
return newEntityData(4, EntityDataTypes.BYTE, (byte) (enabled ? 1 : 0));
|
||||||
|
|
|
@ -313,7 +313,8 @@ public class NpcTypeRegistryImpl implements NpcTypeRegistry {
|
||||||
.addHandProperties());
|
.addHandProperties());
|
||||||
|
|
||||||
register(builder(p, "frog", EntityTypes.FROG)
|
register(builder(p, "frog", EntityTypes.FROG)
|
||||||
.setHologramOffset(-1.475));
|
.setHologramOffset(-1.475)
|
||||||
|
.addProperties("frog_variant"));
|
||||||
|
|
||||||
register(builder(p, "tadpole", EntityTypes.TADPOLE)
|
register(builder(p, "tadpole", EntityTypes.TADPOLE)
|
||||||
.setHologramOffset(-1.675));
|
.setHologramOffset(-1.675));
|
||||||
|
|
|
@ -208,6 +208,8 @@ public class V1_8PacketFactory implements PacketFactory {
|
||||||
properties.getProperty(propertyRegistry.getByName("fox_sleeping", Boolean.class)),
|
properties.getProperty(propertyRegistry.getByName("fox_sleeping", Boolean.class)),
|
||||||
properties.getProperty(propertyRegistry.getByName("fox_faceplanted", Boolean.class))
|
properties.getProperty(propertyRegistry.getByName("fox_faceplanted", Boolean.class))
|
||||||
));
|
));
|
||||||
|
} else if (entity.getType().equals(EntityTypes.FROG)) {
|
||||||
|
add(data, metadataFactory.frogVariant(properties.getProperty(propertyRegistry.getByName("frog_variant", FrogVariant.class)).ordinal()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (properties.getProperty(propertyRegistry.getByName("dinnerbone", Boolean.class))) {
|
if (properties.getProperty(propertyRegistry.getByName("dinnerbone", Boolean.class))) {
|
||||||
|
|
Loading…
Reference in a new issue