Added logging for wolf variants and cat sit states
This commit is contained in:
parent
6ff24ad347
commit
16b7d35fac
5 changed files with 76 additions and 2 deletions
|
|
@ -108,6 +108,16 @@ public class BukkitAdapter implements BukkitInterface {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void getWolfVariant(org.bukkit.entity.Wolf wolf, List<Object> 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
|
@Override
|
||||||
public EntityType getEntityType(Material material) {
|
public EntityType getEntityType(Material material) {
|
||||||
switch (material) {
|
switch (material) {
|
||||||
|
|
|
||||||
|
|
@ -241,6 +241,28 @@ public interface BukkitInterface {
|
||||||
*/
|
*/
|
||||||
boolean setEntityMeta(Entity entity, Object value, int count);
|
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<Object> 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.
|
* Gets the frame type for an entity.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
package net.coreprotect.bukkit;
|
package net.coreprotect.bukkit;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.List;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
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 RegistryAccess.registryAccess().getRegistry(RegistryKey.CAT_VARIANT).get((NamespacedKey)value);
|
||||||
return Bukkit.getRegistry((Class) tClass).get(namespacedKey);
|
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<Object> 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);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -332,6 +332,7 @@ public final class EntityDeathListener extends Queue implements Listener {
|
||||||
Cat cat = (Cat) entity;
|
Cat cat = (Cat) entity;
|
||||||
info.add(BukkitAdapter.ADAPTER.getRegistryKey(cat.getCatType()));
|
info.add(BukkitAdapter.ADAPTER.getRegistryKey(cat.getCatType()));
|
||||||
info.add(cat.getCollarColor());
|
info.add(cat.getCollarColor());
|
||||||
|
info.add(cat.isSitting());
|
||||||
}
|
}
|
||||||
else if (entity instanceof Fox) {
|
else if (entity instanceof Fox) {
|
||||||
Fox fox = (Fox) entity;
|
Fox fox = (Fox) entity;
|
||||||
|
|
@ -437,6 +438,7 @@ public final class EntityDeathListener extends Queue implements Listener {
|
||||||
Wolf wolf = (Wolf) entity;
|
Wolf wolf = (Wolf) entity;
|
||||||
info.add(wolf.isSitting());
|
info.add(wolf.isSitting());
|
||||||
info.add(wolf.getCollarColor());
|
info.add(wolf.getCollarColor());
|
||||||
|
BukkitAdapter.ADAPTER.getWolfVariant(wolf, info);
|
||||||
}
|
}
|
||||||
else if (entity instanceof ZombieVillager) {
|
else if (entity instanceof ZombieVillager) {
|
||||||
ZombieVillager zombieVillager = (ZombieVillager) entity;
|
ZombieVillager zombieVillager = (ZombieVillager) entity;
|
||||||
|
|
|
||||||
|
|
@ -249,6 +249,10 @@ public class EntityUtil {
|
||||||
DyeColor set = (DyeColor) value;
|
DyeColor set = (DyeColor) value;
|
||||||
cat.setCollarColor(set);
|
cat.setCollarColor(set);
|
||||||
}
|
}
|
||||||
|
else if (count == 2) {
|
||||||
|
boolean set = (Boolean) value;
|
||||||
|
cat.setSitting(set);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (entity instanceof Fox) {
|
else if (entity instanceof Fox) {
|
||||||
Fox fox = (Fox) entity;
|
Fox fox = (Fox) entity;
|
||||||
|
|
@ -436,6 +440,9 @@ public class EntityUtil {
|
||||||
DyeColor set = (DyeColor) value;
|
DyeColor set = (DyeColor) value;
|
||||||
wolf.setCollarColor(set);
|
wolf.setCollarColor(set);
|
||||||
}
|
}
|
||||||
|
else if (count == 2) {
|
||||||
|
BukkitAdapter.ADAPTER.setWolfVariant(wolf, value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (entity instanceof ZombieVillager) {
|
else if (entity instanceof ZombieVillager) {
|
||||||
ZombieVillager zombieVillager = (ZombieVillager) entity;
|
ZombieVillager zombieVillager = (ZombieVillager) entity;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue