Added puff_state property

This commit is contained in:
D3v1s0m 2023-09-13 01:13:46 +05:30
parent 7d1772236a
commit 41cccf419f
No known key found for this signature in database
GPG Key ID: FA1F770C7B1D40C1
4 changed files with 20 additions and 4 deletions

@ -0,0 +1,7 @@
package lol.pyr.znpcsplus.util;
public enum PuffState {
DEFLATED,
HALF_INFLATED,
FULLY_INFLATED,
}

@ -274,6 +274,7 @@ public class ZNpcsPlus extends JavaPlugin {
registerEnumParser(manager, MooshroomVariant.class, incorrectUsageMessage); registerEnumParser(manager, MooshroomVariant.class, incorrectUsageMessage);
registerEnumParser(manager, OcelotType.class, incorrectUsageMessage); registerEnumParser(manager, OcelotType.class, incorrectUsageMessage);
registerEnumParser(manager, PandaGene.class, incorrectUsageMessage); registerEnumParser(manager, PandaGene.class, incorrectUsageMessage);
registerEnumParser(manager, PuffState.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))

@ -71,6 +71,7 @@ public class EntityPropertyRegistryImpl implements EntityPropertyRegistry {
registerEnumSerializer(MooshroomVariant.class); registerEnumSerializer(MooshroomVariant.class);
registerEnumSerializer(OcelotType.class); registerEnumSerializer(OcelotType.class);
registerEnumSerializer(PandaGene.class); registerEnumSerializer(PandaGene.class);
registerEnumSerializer(PuffState.class);
/* /*
registerType("using_item", false); // TODO: fix it for 1.8 and add new property to use offhand item and riptide animation registerType("using_item", false); // TODO: fix it for 1.8 and add new property to use offhand item and riptide animation
@ -87,9 +88,6 @@ public class EntityPropertyRegistryImpl implements EntityPropertyRegistry {
// Guardian // Guardian
registerType("is_elder", false); // TODO: ensure it only works till 1.10. Note: index is wrong on wiki.vg registerType("is_elder", false); // TODO: ensure it only works till 1.10. Note: index is wrong on wiki.vg
// Pufferfish
registerType("puff_state", null); // TODO: Make a puff state enum class
// 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
@ -384,6 +382,15 @@ public class EntityPropertyRegistryImpl implements EntityPropertyRegistry {
register(new NBTProperty<>("shoulder_entity_left", ParrotVariant.class, shoulderIndex++, parrotVariantDecoder)); register(new NBTProperty<>("shoulder_entity_left", ParrotVariant.class, shoulderIndex++, parrotVariantDecoder));
register(new NBTProperty<>("shoulder_entity_right", ParrotVariant.class, shoulderIndex, parrotVariantDecoder)); register(new NBTProperty<>("shoulder_entity_right", ParrotVariant.class, shoulderIndex, parrotVariantDecoder));
if (!ver.isNewerThanOrEquals(ServerVersion.V_1_13)) return;
// Pufferfish
int pufferfishIndex;
if (ver.isNewerThanOrEquals(ServerVersion.V_1_17)) pufferfishIndex = 17;
else if (ver.isNewerThanOrEquals(ServerVersion.V_1_15)) pufferfishIndex = 16;
else if (ver.isNewerThanOrEquals(ServerVersion.V_1_14)) pufferfishIndex = 15;
else pufferfishIndex = 13;
register(new EncodedIntegerProperty<>("puff_state", PuffState.DEFLATED, pufferfishIndex, Enum::ordinal));
if (!ver.isNewerThanOrEquals(ServerVersion.V_1_14)) return; if (!ver.isNewerThanOrEquals(ServerVersion.V_1_14)) return;
// Pose // Pose
register(new NpcPoseProperty()); register(new NpcPoseProperty());

@ -250,7 +250,8 @@ public class NpcTypeRegistryImpl implements NpcTypeRegistry {
.setHologramOffset(-1.475)); .setHologramOffset(-1.475));
register(builder(p, "pufferfish", EntityTypes.PUFFERFISH) register(builder(p, "pufferfish", EntityTypes.PUFFERFISH)
.setHologramOffset(-1.625)); .setHologramOffset(-1.625)
.addProperties("puff_state"));
register(builder(p, "salmon", EntityTypes.SALMON) register(builder(p, "salmon", EntityTypes.SALMON)
.setHologramOffset(-1.575)); .setHologramOffset(-1.575));