diff --git a/plugin/src/main/java/lol/pyr/znpcsplus/entity/EntityPropertyRegistryImpl.java b/plugin/src/main/java/lol/pyr/znpcsplus/entity/EntityPropertyRegistryImpl.java index 6bc2f5d..5c018ef 100644 --- a/plugin/src/main/java/lol/pyr/znpcsplus/entity/EntityPropertyRegistryImpl.java +++ b/plugin/src/main/java/lol/pyr/znpcsplus/entity/EntityPropertyRegistryImpl.java @@ -99,9 +99,6 @@ public class EntityPropertyRegistryImpl implements EntityPropertyRegistry { // Guardian registerType("is_elder", false); // TODO: ensure it only works till 1.10. Note: index is wrong on wiki.vg - // Show Golem - registerType("pumpkin", true); // TODO - // Shulker registerType("attach_direction", null); // TODO: make a direction enum registerType("shield_height", 0); // TODO: figure this out @@ -366,6 +363,16 @@ public class EntityPropertyRegistryImpl implements EntityPropertyRegistry { linkProperties("wolf_angry", "tamed", "sitting"); } + if (!ver.isNewerThanOrEquals(ServerVersion.V_1_9)) return; + // Snow Golem + int snowGolemIndex; + if (ver.isNewerThanOrEquals(ServerVersion.V_1_17)) snowGolemIndex = 16; + else if (ver.isNewerThanOrEquals(ServerVersion.V_1_15)) snowGolemIndex = 15; + else if (ver.isNewerThanOrEquals(ServerVersion.V_1_14)) snowGolemIndex = 14; + else if (ver.isNewerThanOrEquals(ServerVersion.V_1_10)) snowGolemIndex = 12; + else snowGolemIndex = 10; + register(new DerpySnowgolemProperty(snowGolemIndex)); + if (!ver.isNewerThanOrEquals(ServerVersion.V_1_10)) return; // Polar Bear int polarBearIndex; diff --git a/plugin/src/main/java/lol/pyr/znpcsplus/entity/properties/DerpySnowgolemProperty.java b/plugin/src/main/java/lol/pyr/znpcsplus/entity/properties/DerpySnowgolemProperty.java new file mode 100644 index 0000000..3a3529c --- /dev/null +++ b/plugin/src/main/java/lol/pyr/znpcsplus/entity/properties/DerpySnowgolemProperty.java @@ -0,0 +1,23 @@ +package lol.pyr.znpcsplus.entity.properties; + +import com.github.retrooper.packetevents.protocol.entity.data.EntityData; +import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes; +import lol.pyr.znpcsplus.entity.EntityPropertyImpl; +import lol.pyr.znpcsplus.entity.PacketEntity; +import org.bukkit.entity.Player; + +import java.util.Map; + +public class DerpySnowgolemProperty extends EntityPropertyImpl { + private final int index; + + public DerpySnowgolemProperty(int index) { + super("derpy_snowgolem", false, Boolean.class); + this.index = index; + } + + @Override + public void apply(Player player, PacketEntity entity, boolean isSpawned, Map properties) { + properties.put(index, new EntityData(index, EntityDataTypes.BYTE, (byte) (entity.getProperty(this) ? 0x00 : 0x10))); + } +} diff --git a/plugin/src/main/java/lol/pyr/znpcsplus/npc/NpcTypeRegistryImpl.java b/plugin/src/main/java/lol/pyr/znpcsplus/npc/NpcTypeRegistryImpl.java index fba1fad..efaaba1 100644 --- a/plugin/src/main/java/lol/pyr/znpcsplus/npc/NpcTypeRegistryImpl.java +++ b/plugin/src/main/java/lol/pyr/znpcsplus/npc/NpcTypeRegistryImpl.java @@ -135,7 +135,8 @@ public class NpcTypeRegistryImpl implements NpcTypeRegistry { register(builder(p, "slime", EntityTypes.SLIME)); // TODO: Hologram offset scaling with size property register(builder(p, "snow_golem", EntityTypes.SNOW_GOLEM) - .setHologramOffset(-0.075)); + .setHologramOffset(-0.075) + .addProperties("derpy_snowgolem")); register(builder(p, "spider", EntityTypes.SPIDER) .setHologramOffset(-1.075));