package protocolsupport.protocol.packet.middle.impl.serverbound.play.v_4_5_6;

import org.bukkit.inventory.MainHand;

import io.netty.buffer.ByteBuf;
import protocolsupport.protocol.codec.StringCodec;
import protocolsupport.protocol.packet.middle.base.serverbound.play.MiddleClientSettings;
import protocolsupport.protocol.packet.middle.impl.serverbound.IServerboundMiddlePacketV4;
import protocolsupport.protocol.packet.middle.impl.serverbound.IServerboundMiddlePacketV5;
import protocolsupport.protocol.packet.middle.impl.serverbound.IServerboundMiddlePacketV6;

public class ClientSettings extends MiddleClientSettings implements
IServerboundMiddlePacketV4,
IServerboundMiddlePacketV5,
IServerboundMiddlePacketV6 {

	public ClientSettings(IMiddlePacketInit init) {
		super(init);
		mainHand = MainHand.RIGHT;
		disableTextFilter = true;
	}

	@Override
	protected void read(ByteBuf clientdata) {
		locale = StringCodec.readShortUTF16BEString(clientdata, 16);
		viewDist = clientdata.readByte();
		int chatState = clientdata.readByte();
		chatMode = ChatMode.CONSTANT_LOOKUP.getByOrdinal(chatState & 7);
		chatColors = (chatState & 8) == 8;
		clientdata.readByte();
		clientdata.readBoolean();
		skinFlags = 255;
	}

}

@@ -143,16 +143,69 @@
 yteBuf;%0A
+import protocolsupport.protocol.codec.MiscDataCodec;%0A
 import p
@@ -243,24 +243,24 @@
 tringCodec;%0A
-
 import proto
@@ -609,16 +609,74 @@
 acketV6;
+%0Aimport protocolsupport.protocol.utils.EnumConstantLookup;
 %0A%0Apublic
@@ -1078,34 +1078,99 @@
 wDist = 
-clientdata.readByt
+MiscDataCodec.readByteEnum(clientdata, ViewDistanceType.CONSTANT_LOOKUP).getDistanc
 e();%0A%09%09i
@@ -1364,16 +1364,16 @@
 lean();%0A
-
 %09%09skinFl
@@ -1387,10 +1387,388 @@
 55;%0A%09%7D%0A%0A
+%09protected enum ViewDistanceType %7B%0A%0A%09%09FAR(16),%0A%09%09NORMAL(8),%0A%09%09SHORT(4),%0A%09%09TINY(2);%0A%0A%09%09public static final EnumConstantLookup%3CViewDistanceType%3E CONSTANT_LOOKUP = new EnumConstantLookup%3C%3E(ViewDistanceType.class);%0A%0A%09%09private final int distance;%0A%0A%09%09private ViewDistanceType(int distance) %7B%0A%09%09%09this.distance = distance;%0A%09%09%7D%0A%0A%09%09public int getDistance() %7B%0A%09%09%09return distance;%0A%09%09%7D%0A%0A%09%7D%0A%0A
 %7D%0A

Fix < 1.7 client settings view distance read