added size property for Slime, Magma Cube and Phantom
This commit is contained in:
parent
2c601c450d
commit
f28de908da
3 changed files with 23 additions and 4 deletions
|
@ -149,8 +149,6 @@ public class EntityPropertyRegistryImpl implements EntityPropertyRegistry {
|
|||
// Phantom
|
||||
registerType("phantom_size", 0); // TODO
|
||||
|
||||
// Slime
|
||||
registerType("slime_size", 0); // TODO
|
||||
*/
|
||||
}
|
||||
|
||||
|
@ -331,6 +329,16 @@ public class EntityPropertyRegistryImpl implements EntityPropertyRegistry {
|
|||
linkProperties("is_saddled", "is_eating", "is_rearing", "has_mouth_open");
|
||||
}
|
||||
|
||||
// Slime and Magma Cube
|
||||
int sizeIndex;
|
||||
if (ver.isNewerThanOrEquals(ServerVersion.V_1_17)) sizeIndex = 16;
|
||||
else if (ver.isNewerThanOrEquals(ServerVersion.V_1_15)) sizeIndex = 15;
|
||||
else if (ver.isNewerThanOrEquals(ServerVersion.V_1_14)) sizeIndex = 14;
|
||||
else if (ver.isNewerThanOrEquals(ServerVersion.V_1_10)) sizeIndex = 12;
|
||||
else if (ver.isNewerThanOrEquals(ServerVersion.V_1_9)) sizeIndex = 11;
|
||||
else sizeIndex = 16;
|
||||
register(new IntegerProperty("size", sizeIndex, 1, v1_8));
|
||||
|
||||
if (!ver.isNewerThanOrEquals(ServerVersion.V_1_11)) return;
|
||||
// Spellcaster Illager
|
||||
int spellIndex = 12;
|
||||
|
|
|
@ -10,14 +10,22 @@ import java.util.Map;
|
|||
|
||||
public class IntegerProperty extends EntityPropertyImpl<Integer> {
|
||||
private final int index;
|
||||
private final boolean legacy;
|
||||
|
||||
protected IntegerProperty(String name, int index, Integer defaultValue) {
|
||||
public IntegerProperty(String name, int index, Integer defaultValue) {
|
||||
this(name, index, defaultValue, false);
|
||||
}
|
||||
|
||||
public IntegerProperty(String name, int index, Integer defaultValue, boolean legacy) {
|
||||
super(name, defaultValue, Integer.class);
|
||||
this.index = index;
|
||||
this.legacy = legacy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(Player player, PacketEntity entity, boolean isSpawned, Map<Integer, EntityData> properties) {
|
||||
properties.put(index, newEntityData(index, EntityDataTypes.INT, entity.getProperty(this)));
|
||||
properties.put(index, legacy ?
|
||||
newEntityData(index, EntityDataTypes.BYTE, (byte) entity.getProperty(this).intValue()) :
|
||||
newEntityData(index, EntityDataTypes.INT, entity.getProperty(this)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -135,6 +135,9 @@ public class NpcTypeImpl implements NpcType {
|
|||
if (EntityTypes.isTypeInstanceOf(type, EntityTypes.ABSTRACT_PIGLIN)) {
|
||||
addProperties("piglin_immune_to_zombification");
|
||||
}
|
||||
if (EntityTypes.isTypeInstanceOf(type, EntityTypes.SLIME) || EntityTypes.isTypeInstanceOf(type, EntityTypes.PHANTOM)) {
|
||||
addProperties("size");
|
||||
}
|
||||
return new NpcTypeImpl(name, type, hologramOffset, new HashSet<>(allowedProperties), defaultProperties);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue