Fix client-side slime collision box

This commit is contained in:
filoghost 2021-08-01 10:17:49 +02:00
parent bb48855396
commit 2641ec7c0f
3 changed files with 8 additions and 0 deletions

View File

@ -16,6 +16,7 @@ import java.util.Optional;
class DataWatcherKey<T> {
private static final DataWatcherSerializer<Byte> BYTE_SERIALIZER = DataWatcherRegistry.a;
private static final DataWatcherSerializer<Integer> INT_SERIALIZER = DataWatcherRegistry.b;
private static final DataWatcherSerializer<Boolean> BOOLEAN_SERIALIZER = DataWatcherRegistry.i;
private static final DataWatcherSerializer<ItemStack> ITEM_STACK_SERIALIZER = DataWatcherRegistry.g;
private static final DataWatcherSerializer<Optional<IChatBaseComponent>> OPTIONAL_CHAT_COMPONENT_SERIALIZER = DataWatcherRegistry.f;
@ -25,6 +26,7 @@ class DataWatcherKey<T> {
static DataWatcherKey<Boolean> CUSTOM_NAME_VISIBILITY = new DataWatcherKey<>(3, BOOLEAN_SERIALIZER);
static DataWatcherKey<ItemStack> ITEM_STACK = new DataWatcherKey<>(8, ITEM_STACK_SERIALIZER);
static DataWatcherKey<Byte> ARMOR_STAND_STATUS = new DataWatcherKey<>(15, BYTE_SERIALIZER);
static DataWatcherKey<Integer> SLIME_SIZE = new DataWatcherKey<>(16, INT_SERIALIZER);
private final int index;
private final DataWatcherSerializer<T> serializer;

View File

@ -75,6 +75,11 @@ class EntityMetadataNMSPacket extends VersionNMSPacket {
return this;
}
Builder setSmallSlime() {
packetByteBuffer.writeDataWatcherEntry(DataWatcherKey.SLIME_SIZE, 1);
return this;
}
EntityMetadataNMSPacket build() {
packetByteBuffer.writeDataWatcherEntriesEnd();
return new EntityMetadataNMSPacket(packetByteBuffer);

View File

@ -87,6 +87,7 @@ class VersionNMSPacketList extends AbstractNMSPacketList {
add(new EntityLivingSpawnNMSPacket(entityID, EntityTypeID.SLIME, locationX, locationY, locationZ));
add(EntityMetadataNMSPacket.builder(entityID)
.setInvisible()
.setSmallSlime() // Required for a correct client-side collision box
.build()
);
}