protected void register(List<Entry<Consumer<NBTCompound>>> list, Material skull, int skulltype) { for (BlockData blockdata : MaterialAPI.getBlockDataList(skull)) { byte rotation = getLegacyData(blockdata); list.add(new Entry<>(MaterialAPI.getBlockDataNetworkId(blockdata), nbt -> { nbt.setTag("SkullType", new NBTByte((byte) skulltype)); nbt.setTag("Rot", new NBTByte(rotation)); })); } }
super(DataInput::readByte, DataOutput::writeByte, DataInput::readUTF, DataOutput::writeUTF); registerType(NBTType.END, 0, stream -> NBTEnd.INSTANCE, (stream, tag) -> {}); registerType(NBTType.BYTE, 1, stream -> new NBTByte(stream.readByte()), (stream, tag) -> stream.writeByte(tag.getAsByte())); registerType(NBTType.SHORT, 2, stream -> new NBTShort(stream.readShort()), (stream, tag) -> stream.writeShort(tag.getAsShort())); registerType(NBTType.INT, 3, stream -> new NBTInt(stream.readInt()), (stream, tag) -> stream.writeInt(tag.getAsInt()));
@Test public void testEq() { Assertions.assertEquals(new NBTByte((byte) 5), new NBTByte((byte) 5)); Assertions.assertEquals(new NBTShort((short) 5), new NBTShort((short) 5)); Assertions.assertEquals(new NBTInt(5), new NBTInt(5)); Assertions.assertEquals(new NBTLong(5), new NBTLong(5)); Assertions.assertEquals(new NBTFloat(5), new NBTFloat(5)); Assertions.assertEquals(new NBTDouble(5), new NBTDouble(5)); Assertions.assertEquals(new NBTString("5"), new NBTString("5")); }