diff --git a/src/main/java/net/coreprotect/bukkit/BukkitAdapter.java b/src/main/java/net/coreprotect/bukkit/BukkitAdapter.java index ce86bc7..f498ef3 100644 --- a/src/main/java/net/coreprotect/bukkit/BukkitAdapter.java +++ b/src/main/java/net/coreprotect/bukkit/BukkitAdapter.java @@ -108,6 +108,16 @@ public class BukkitAdapter implements BukkitInterface { return false; } + @Override + public void getWolfVariant(org.bukkit.entity.Wolf wolf, List info) { + // Base implementation does nothing - Wolf variants only exist in 1.21+ + } + + @Override + public void setWolfVariant(org.bukkit.entity.Wolf wolf, Object value) { + // Base implementation does nothing - Wolf variants only exist in 1.21+ + } + @Override public EntityType getEntityType(Material material) { switch (material) { diff --git a/src/main/java/net/coreprotect/bukkit/BukkitInterface.java b/src/main/java/net/coreprotect/bukkit/BukkitInterface.java index cd60cf0..a648b26 100644 --- a/src/main/java/net/coreprotect/bukkit/BukkitInterface.java +++ b/src/main/java/net/coreprotect/bukkit/BukkitInterface.java @@ -241,6 +241,28 @@ public interface BukkitInterface { */ boolean setEntityMeta(Entity entity, Object value, int count); + /** + * Gets the wolf variant and adds it to the info list. + * Only implemented in Minecraft 1.21+. + * + * @param wolf + * The wolf entity + * @param info + * The list to add the variant information to + */ + void getWolfVariant(org.bukkit.entity.Wolf wolf, List info); + + /** + * Sets the wolf variant from the provided value. + * Only implemented in Minecraft 1.21+. + * + * @param wolf + * The wolf entity + * @param value + * The variant value to set + */ + void setWolfVariant(org.bukkit.entity.Wolf wolf, Object value); + /** * Gets the frame type for an entity. * diff --git a/src/main/java/net/coreprotect/bukkit/Bukkit_v1_21.java b/src/main/java/net/coreprotect/bukkit/Bukkit_v1_21.java index 0dbd41b..ad718fb 100644 --- a/src/main/java/net/coreprotect/bukkit/Bukkit_v1_21.java +++ b/src/main/java/net/coreprotect/bukkit/Bukkit_v1_21.java @@ -1,7 +1,6 @@ package net.coreprotect.bukkit; -import java.util.Arrays; -import java.util.HashSet; +import java.util.List; import java.util.Set; import org.bukkit.Bukkit; @@ -126,4 +125,38 @@ public class Bukkit_v1_21 extends Bukkit_v1_20 implements BukkitInterface { // return RegistryAccess.registryAccess().getRegistry(RegistryKey.CAT_VARIANT).get((NamespacedKey)value); return Bukkit.getRegistry((Class) tClass).get(namespacedKey); } + + /** + * Gets the wolf variant and adds it to the info list. + * This functionality is specific to Minecraft 1.21+. + * + * @param wolf + * The wolf entity + * @param info + * The list to add the variant information to + */ + @Override + public void getWolfVariant(org.bukkit.entity.Wolf wolf, List info) { + // Add the variant to the info list + info.add(getRegistryKey(wolf.getVariant())); + } + + /** + * Sets the wolf variant from the provided value. + * This functionality is specific to Minecraft 1.21+. + * + * @param wolf + * The wolf entity + * @param value + * The variant value to set + */ + @Override + public void setWolfVariant(org.bukkit.entity.Wolf wolf, Object value) { + if (value instanceof String) { + value = getRegistryValue((String) value, org.bukkit.entity.Wolf.Variant.class); + } + org.bukkit.entity.Wolf.Variant variant = (org.bukkit.entity.Wolf.Variant) value; + wolf.setVariant(variant); + + } } diff --git a/src/main/java/net/coreprotect/listener/entity/EntityDeathListener.java b/src/main/java/net/coreprotect/listener/entity/EntityDeathListener.java index c8b8c1c..a5a38f8 100644 --- a/src/main/java/net/coreprotect/listener/entity/EntityDeathListener.java +++ b/src/main/java/net/coreprotect/listener/entity/EntityDeathListener.java @@ -332,6 +332,7 @@ public final class EntityDeathListener extends Queue implements Listener { Cat cat = (Cat) entity; info.add(BukkitAdapter.ADAPTER.getRegistryKey(cat.getCatType())); info.add(cat.getCollarColor()); + info.add(cat.isSitting()); } else if (entity instanceof Fox) { Fox fox = (Fox) entity; @@ -437,6 +438,7 @@ public final class EntityDeathListener extends Queue implements Listener { Wolf wolf = (Wolf) entity; info.add(wolf.isSitting()); info.add(wolf.getCollarColor()); + BukkitAdapter.ADAPTER.getWolfVariant(wolf, info); } else if (entity instanceof ZombieVillager) { ZombieVillager zombieVillager = (ZombieVillager) entity; diff --git a/src/main/java/net/coreprotect/utility/entity/EntityUtil.java b/src/main/java/net/coreprotect/utility/entity/EntityUtil.java index 3a4da22..db72047 100644 --- a/src/main/java/net/coreprotect/utility/entity/EntityUtil.java +++ b/src/main/java/net/coreprotect/utility/entity/EntityUtil.java @@ -249,6 +249,10 @@ public class EntityUtil { DyeColor set = (DyeColor) value; cat.setCollarColor(set); } + else if (count == 2) { + boolean set = (Boolean) value; + cat.setSitting(set); + } } else if (entity instanceof Fox) { Fox fox = (Fox) entity; @@ -436,6 +440,9 @@ public class EntityUtil { DyeColor set = (DyeColor) value; wolf.setCollarColor(set); } + else if (count == 2) { + BukkitAdapter.ADAPTER.setWolfVariant(wolf, value); + } } else if (entity instanceof ZombieVillager) { ZombieVillager zombieVillager = (ZombieVillager) entity;