mirror of
https://github.com/filoghost/HolographicDisplays.git
synced 2024-12-30 04:37:42 +01:00
Move serializer constants to appropriate class
This commit is contained in:
parent
614a56ca8a
commit
ad1cfe3f1f
@ -9,19 +9,12 @@ import net.minecraft.server.v1_8_R3.ItemStack;
|
|||||||
|
|
||||||
class DataWatcherKey<T> {
|
class DataWatcherKey<T> {
|
||||||
|
|
||||||
private static final DataWatcherSerializer<Byte> BYTE_SERIALIZER =
|
static final DataWatcherKey<Byte> ENTITY_STATUS = new DataWatcherKey<>(0, DataWatcherSerializer.BYTE);
|
||||||
new DataWatcherSerializer<>(0, PacketByteBuffer::writeByte);
|
static final DataWatcherKey<String> CUSTOM_NAME = new DataWatcherKey<>(2, DataWatcherSerializer.STRING);
|
||||||
private static final DataWatcherSerializer<String> STRING_SERIALIZER =
|
static final DataWatcherKey<Byte> CUSTOM_NAME_VISIBILITY = new DataWatcherKey<>(3, DataWatcherSerializer.BYTE);
|
||||||
new DataWatcherSerializer<>(4, PacketByteBuffer::writeString);
|
static final DataWatcherKey<ItemStack> ITEM_STACK = new DataWatcherKey<>(10, DataWatcherSerializer.ITEM_STACK);
|
||||||
private static final DataWatcherSerializer<ItemStack> ITEM_STACK_SERIALIZER =
|
static final DataWatcherKey<Byte> ARMOR_STAND_STATUS = new DataWatcherKey<>(10, DataWatcherSerializer.BYTE);
|
||||||
new DataWatcherSerializer<>(5, PacketByteBuffer::writeItemStack);
|
static final DataWatcherKey<Byte> SLIME_SIZE = new DataWatcherKey<>(16, DataWatcherSerializer.BYTE);
|
||||||
|
|
||||||
static final DataWatcherKey<Byte> ENTITY_STATUS = new DataWatcherKey<>(0, BYTE_SERIALIZER);
|
|
||||||
static final DataWatcherKey<String> CUSTOM_NAME = new DataWatcherKey<>(2, STRING_SERIALIZER);
|
|
||||||
static final DataWatcherKey<Byte> CUSTOM_NAME_VISIBILITY = new DataWatcherKey<>(3, BYTE_SERIALIZER);
|
|
||||||
static final DataWatcherKey<ItemStack> ITEM_STACK = new DataWatcherKey<>(10, ITEM_STACK_SERIALIZER);
|
|
||||||
static final DataWatcherKey<Byte> ARMOR_STAND_STATUS = new DataWatcherKey<>(10, BYTE_SERIALIZER);
|
|
||||||
static final DataWatcherKey<Byte> SLIME_SIZE = new DataWatcherKey<>(16, BYTE_SERIALIZER);
|
|
||||||
|
|
||||||
private final int index;
|
private final int index;
|
||||||
private final DataWatcherSerializer<T> serializer;
|
private final DataWatcherSerializer<T> serializer;
|
||||||
|
@ -5,14 +5,20 @@
|
|||||||
*/
|
*/
|
||||||
package me.filoghost.holographicdisplays.nms.v1_8_R3;
|
package me.filoghost.holographicdisplays.nms.v1_8_R3;
|
||||||
|
|
||||||
|
import net.minecraft.server.v1_8_R3.ItemStack;
|
||||||
|
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
|
|
||||||
class DataWatcherSerializer<T> {
|
class DataWatcherSerializer<T> {
|
||||||
|
|
||||||
|
static final DataWatcherSerializer<Byte> BYTE = new DataWatcherSerializer<>(0, PacketByteBuffer::writeByte);
|
||||||
|
static final DataWatcherSerializer<String> STRING = new DataWatcherSerializer<>(4, PacketByteBuffer::writeString);
|
||||||
|
static final DataWatcherSerializer<ItemStack> ITEM_STACK = new DataWatcherSerializer<>(5, PacketByteBuffer::writeItemStack);
|
||||||
|
|
||||||
private final int typeID;
|
private final int typeID;
|
||||||
private final BiConsumer<PacketByteBuffer, T> serializeFunction;
|
private final BiConsumer<PacketByteBuffer, T> serializeFunction;
|
||||||
|
|
||||||
DataWatcherSerializer(int typeID, BiConsumer<PacketByteBuffer, T> serializeFunction) {
|
private DataWatcherSerializer(int typeID, BiConsumer<PacketByteBuffer, T> serializeFunction) {
|
||||||
this.typeID = typeID;
|
this.typeID = typeID;
|
||||||
this.serializeFunction = serializeFunction;
|
this.serializeFunction = serializeFunction;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user