Added ocelot_type property

This commit is contained in:
D3v1s0m 2023-09-11 18:11:36 +05:30
parent 0127af865b
commit 1008d31df0
No known key found for this signature in database
GPG Key ID: FA1F770C7B1D40C1
4 changed files with 27 additions and 1 deletions

@ -0,0 +1,8 @@
package lol.pyr.znpcsplus.util;
public enum OcelotType {
OCELOT,
TUXEDO,
TABBY,
SIAMESE,
}

@ -272,6 +272,7 @@ public class ZNpcsPlus extends JavaPlugin {
registerEnumParser(manager, HorseArmor.class, incorrectUsageMessage);
registerEnumParser(manager, LlamaVariant.class, incorrectUsageMessage);
registerEnumParser(manager, MooshroomVariant.class, incorrectUsageMessage);
registerEnumParser(manager, OcelotType.class, incorrectUsageMessage);
manager.registerCommand("npc", new MultiCommand(loadHelpMessage("root"))
.addSubcommand("create", new CreateCommand(npcRegistry, typeRegistry))

@ -66,6 +66,7 @@ public class EntityPropertyRegistryImpl implements EntityPropertyRegistry {
registerEnumSerializer(HorseArmor.class);
registerEnumSerializer(LlamaVariant.class);
registerEnumSerializer(MooshroomVariant.class);
registerEnumSerializer(OcelotType.class);
/*
registerType("using_item", false); // TODO: fix it for 1.8 and add new property to use offhand item and riptide animation
@ -328,7 +329,7 @@ public class EntityPropertyRegistryImpl implements EntityPropertyRegistry {
linkProperties("is_saddled", "is_eating", "is_rearing", "has_mouth_open");
}
// Slime and Magma Cube
// Slime, Magma Cube and Phantom
int sizeIndex;
if (ver.isNewerThanOrEquals(ServerVersion.V_1_17)) sizeIndex = 16;
else if (ver.isNewerThanOrEquals(ServerVersion.V_1_15)) sizeIndex = 15;
@ -338,6 +339,16 @@ public class EntityPropertyRegistryImpl implements EntityPropertyRegistry {
else sizeIndex = 16;
register(new IntegerProperty("size", sizeIndex, 1, v1_8));
// Ocelot
if (ver.isOlderThan(ServerVersion.V_1_14)) {
int ocelotIndex;
if (ver.isNewerThanOrEquals(ServerVersion.V_1_10)) ocelotIndex = 15;
else if (ver.isNewerThanOrEquals(ServerVersion.V_1_9)) ocelotIndex = 14;
else ocelotIndex = 18;
if (v1_8) register(new EncodedByteProperty<>("ocelot_type", OcelotType.OCELOT, ocelotIndex, obj -> (byte) obj.ordinal()));
else register(new EncodedIntegerProperty<>("ocelot_type", OcelotType.OCELOT, ocelotIndex, Enum::ordinal));
}
if (!ver.isNewerThanOrEquals(ServerVersion.V_1_11)) return;
// Spellcaster Illager
int spellIndex = 12;

@ -110,6 +110,7 @@ public class NpcTypeImpl implements NpcType {
ServerVersion version = PacketEvents.getAPI().getServerManager().getVersion();
addProperties("fire", "invisible", "silent", "look",
"potion_color", "potion_ambient", "dinnerbone");
// TODO: make this look nicer after completing the rest of the properties
if (version.isNewerThanOrEquals(ServerVersion.V_1_9)) addProperties("glow");
if (version.isNewerThanOrEquals(ServerVersion.V_1_14)) {
addProperties("pose");
@ -138,6 +139,11 @@ public class NpcTypeImpl implements NpcType {
if (EntityTypes.isTypeInstanceOf(type, EntityTypes.SLIME) || EntityTypes.isTypeInstanceOf(type, EntityTypes.PHANTOM)) {
addProperties("size");
}
if (version.isOlderThan(ServerVersion.V_1_14)) {
if (EntityTypes.isTypeInstanceOf(type, EntityTypes.OCELOT)) {
addProperties("ocelot_type");
}
}
return new NpcTypeImpl(name, type, hologramOffset, new HashSet<>(allowedProperties), defaultProperties);
}
}