From ad1cfe3f1ff19fa8f9c266c86a50661575cffdbc Mon Sep 17 00:00:00 2001 From: filoghost Date: Fri, 20 Aug 2021 08:56:06 +0200 Subject: [PATCH] Move serializer constants to appropriate class --- .../nms/v1_8_R3/DataWatcherKey.java | 19 ++++++------------- .../nms/v1_8_R3/DataWatcherSerializer.java | 8 +++++++- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/nms/v1_8_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R3/DataWatcherKey.java b/nms/v1_8_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R3/DataWatcherKey.java index 536d26a7..8eeba40a 100644 --- a/nms/v1_8_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R3/DataWatcherKey.java +++ b/nms/v1_8_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R3/DataWatcherKey.java @@ -9,19 +9,12 @@ import net.minecraft.server.v1_8_R3.ItemStack; class DataWatcherKey { - private static final DataWatcherSerializer BYTE_SERIALIZER = - new DataWatcherSerializer<>(0, PacketByteBuffer::writeByte); - private static final DataWatcherSerializer STRING_SERIALIZER = - new DataWatcherSerializer<>(4, PacketByteBuffer::writeString); - private static final DataWatcherSerializer ITEM_STACK_SERIALIZER = - new DataWatcherSerializer<>(5, PacketByteBuffer::writeItemStack); - - static final DataWatcherKey ENTITY_STATUS = new DataWatcherKey<>(0, BYTE_SERIALIZER); - static final DataWatcherKey CUSTOM_NAME = new DataWatcherKey<>(2, STRING_SERIALIZER); - static final DataWatcherKey CUSTOM_NAME_VISIBILITY = new DataWatcherKey<>(3, BYTE_SERIALIZER); - static final DataWatcherKey ITEM_STACK = new DataWatcherKey<>(10, ITEM_STACK_SERIALIZER); - static final DataWatcherKey ARMOR_STAND_STATUS = new DataWatcherKey<>(10, BYTE_SERIALIZER); - static final DataWatcherKey SLIME_SIZE = new DataWatcherKey<>(16, BYTE_SERIALIZER); + static final DataWatcherKey ENTITY_STATUS = new DataWatcherKey<>(0, DataWatcherSerializer.BYTE); + static final DataWatcherKey CUSTOM_NAME = new DataWatcherKey<>(2, DataWatcherSerializer.STRING); + static final DataWatcherKey CUSTOM_NAME_VISIBILITY = new DataWatcherKey<>(3, DataWatcherSerializer.BYTE); + static final DataWatcherKey ITEM_STACK = new DataWatcherKey<>(10, DataWatcherSerializer.ITEM_STACK); + static final DataWatcherKey ARMOR_STAND_STATUS = new DataWatcherKey<>(10, DataWatcherSerializer.BYTE); + static final DataWatcherKey SLIME_SIZE = new DataWatcherKey<>(16, DataWatcherSerializer.BYTE); private final int index; private final DataWatcherSerializer serializer; diff --git a/nms/v1_8_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R3/DataWatcherSerializer.java b/nms/v1_8_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R3/DataWatcherSerializer.java index 7501c69e..ef512a2c 100644 --- a/nms/v1_8_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R3/DataWatcherSerializer.java +++ b/nms/v1_8_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R3/DataWatcherSerializer.java @@ -5,14 +5,20 @@ */ package me.filoghost.holographicdisplays.nms.v1_8_R3; +import net.minecraft.server.v1_8_R3.ItemStack; + import java.util.function.BiConsumer; class DataWatcherSerializer { + static final DataWatcherSerializer BYTE = new DataWatcherSerializer<>(0, PacketByteBuffer::writeByte); + static final DataWatcherSerializer STRING = new DataWatcherSerializer<>(4, PacketByteBuffer::writeString); + static final DataWatcherSerializer ITEM_STACK = new DataWatcherSerializer<>(5, PacketByteBuffer::writeItemStack); + private final int typeID; private final BiConsumer serializeFunction; - DataWatcherSerializer(int typeID, BiConsumer serializeFunction) { + private DataWatcherSerializer(int typeID, BiConsumer serializeFunction) { this.typeID = typeID; this.serializeFunction = serializeFunction; }