package protocolsupport.protocol.transformer.middlepacketimpl.clientbound.play.v_1_4_1_5_1_6_1_7_1_8;

import java.io.IOException;

import org.bukkit.event.inventory.InventoryType;

import protocolsupport.api.ProtocolVersion;
import protocolsupport.protocol.ClientBoundPacket;
import protocolsupport.protocol.transformer.middlepacket.clientbound.play.MiddleInventoryData;
import protocolsupport.protocol.transformer.middlepacketimpl.PacketData;
import protocolsupport.utils.recyclable.RecyclableCollection;
import protocolsupport.utils.recyclable.RecyclableSingletonList;

public class InventoryData extends MiddleInventoryData<RecyclableCollection<PacketData>> {

	private static final int[] furTypeTr = {1, 2, 0};

	@Override
	public RecyclableCollection<PacketData> toData(ProtocolVersion version) throws IOException {
		if (version.isBefore(ProtocolVersion.MINECRAFT_1_8) && player.getOpenInventory().getType() == InventoryType.FURNACE) {
			if (type < furTypeTr.length) {
				type = furTypeTr[type];
			}
		}
		PacketData serializer = PacketData.create(ClientBoundPacket.PLAY_WINDOW_DATA_ID, version);
		serializer.writeByte(windowId);
		serializer.writeShort(type);
		serializer.writeShort(value);
		return RecyclableSingletonList.<PacketData>create(serializer);
	}

}

@@ -708,16 +708,64 @@
 , 2, 0%7D;
+%0A%09private final int%5B%5D enchTypeVal = new int%5B10%5D;
 %0A%0A%09@Over
@@ -868,16 +868,846 @@
  %7B%0A%09%09if 
+(version == ProtocolVersion.MINECRAFT_1_8 && player.getOpenInventory().getType() == InventoryType.ENCHANTING) %7B%0A%09%09%09enchTypeVal%5Btype%5D = value;%0A%09%09%09if (type %3E= 7 && type %3C= 9) %7B%0A%09%09%09%09PacketData serializer = PacketData.create(ClientBoundPacket.PLAY_WINDOW_DATA_ID, version);%0A%09%09%09%09serializer.writeByte(windowId);%0A%09%09%09%09serializer.writeShort(type - 3);%0A%09%09%09%09serializer.writeShort((value %3C%3C 8) %7C enchTypeVal%5Btype - 3%5D);%0A%09%09%09%09return RecyclableSingletonList.%3CPacketData%3Ecreate(serializer);%0A%09%09%09%7D else if (type %3E= 4 && type %3C= 6) %7B%0A%09%09%09%09PacketData serializer = PacketData.create(ClientBoundPacket.PLAY_WINDOW_DATA_ID, version);%0A%09%09%09%09serializer.writeByte(windowId);%0A%09%09%09%09serializer.writeShort(type);%0A%09%09%09%09serializer.writeShort(((enchTypeVal%5Btype + 3%5D) %3C%3C 8) %7C value);%0A%09%09%09%09return RecyclableSingletonList.%3CPacketData%3Ecreate(serializer);%0A%09%09%09%7D%0A%09%09%7D else if 
 (version

Fix enchantment display in enchantment table