added baby property

This commit is contained in:
D3v1s0m 2023-08-21 20:17:30 +05:30
parent 329d344013
commit 12ea0eab22
No known key found for this signature in database
GPG Key ID: FA1F770C7B1D40C1
2 changed files with 13 additions and 2 deletions

@ -62,8 +62,6 @@ public class EntityPropertyRegistryImpl implements EntityPropertyRegistry {
/*
registerType("using_item", false); // TODO: fix it for 1.8 and add new property to use offhand item and riptide animation
registerType("baby", false); // TODO
// Player
registerType("shoulder_entity_left", ParrotVariant.NONE);
registerType("shoulder_entity_right", ParrotVariant.NONE);
@ -210,6 +208,15 @@ public class EntityPropertyRegistryImpl implements EntityPropertyRegistry {
register(new EncodedIntegerProperty<>("potion_color", Color.class, potionIndex++, Color::asRGB));
register(new BooleanProperty("potion_ambient", potionIndex, false, legacyBooleans));
int babyIndex;
if (ver.isNewerThanOrEquals(ServerVersion.V_1_17)) babyIndex = 16;
else if (ver.isNewerThanOrEquals(ServerVersion.V_1_15)) babyIndex = 15;
else if (ver.isNewerThanOrEquals(ServerVersion.V_1_14)) babyIndex = 14;
else if (ver.isNewerThanOrEquals(ServerVersion.V_1_10)) babyIndex = 12;
else if (ver.isNewerThanOrEquals(ServerVersion.V_1_9)) babyIndex = 11;
else babyIndex = 12;
register(new BooleanProperty("baby", babyIndex, false, legacyBooleans));
// Player
register(new DummyProperty<>("skin", SkinDescriptor.class, false));
final int skinLayersIndex;

@ -3,6 +3,7 @@ package lol.pyr.znpcsplus.npc;
import com.github.retrooper.packetevents.PacketEvents;
import com.github.retrooper.packetevents.manager.server.ServerVersion;
import com.github.retrooper.packetevents.protocol.entity.type.EntityType;
import com.github.retrooper.packetevents.protocol.entity.type.EntityTypes;
import lol.pyr.znpcsplus.api.entity.EntityProperty;
import lol.pyr.znpcsplus.api.npc.NpcType;
import lol.pyr.znpcsplus.entity.EntityPropertyImpl;
@ -92,6 +93,9 @@ public class NpcTypeImpl implements NpcType {
if (version.isNewerThanOrEquals(ServerVersion.V_1_9)) addProperties("glow");
if (version.isNewerThanOrEquals(ServerVersion.V_1_14)) addProperties("pose");
if (version.isNewerThanOrEquals(ServerVersion.V_1_17)) addProperties("shaking");
if (EntityTypes.isTypeInstanceOf(type, EntityTypes.ABSTRACT_AGEABLE)) {
addProperties("baby");
}
return new NpcTypeImpl(name, type, hologramOffset, new HashSet<>(allowedProperties));
}
}