From f870bd5a323d3cbaa38fb2040dea9664286f80bb Mon Sep 17 00:00:00 2001 From: Matsv Date: Thu, 19 May 2016 13:07:51 +0200 Subject: [PATCH] Transform pitch correctly --- .../ProtocolSnapshotTo1_9_3.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_9_3/ProtocolSnapshotTo1_9_3.java b/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_9_3/ProtocolSnapshotTo1_9_3.java index d8f8755ab..2f6cb1d63 100644 --- a/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_9_3/ProtocolSnapshotTo1_9_3.java +++ b/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_9_3/ProtocolSnapshotTo1_9_3.java @@ -1,9 +1,11 @@ package us.myles.ViaVersion.protocols.protocolsnapshotto1_9_3; +import us.myles.ViaVersion.api.PacketWrapper; import us.myles.ViaVersion.api.data.UserConnection; import us.myles.ViaVersion.api.minecraft.metadata.Metadata; import us.myles.ViaVersion.api.protocol.Protocol; import us.myles.ViaVersion.api.remapper.PacketRemapper; +import us.myles.ViaVersion.api.remapper.ValueTransformer; import us.myles.ViaVersion.api.type.Type; import us.myles.ViaVersion.packets.State; @@ -12,6 +14,13 @@ import java.util.List; public class ProtocolSnapshotTo1_9_3 extends Protocol { public static final Type> METADATA_LIST = new MetaListSnapshotType(); public static final Type METADATA = new MetaSnapshotType(); + public static ValueTransformer toNewPitch = new ValueTransformer(Type.FLOAT) { + @Override + public Float transform(PacketWrapper wrapper, Short inputValue) throws Exception { + return inputValue / 63.5F; + + } + }; @Override protected void registerPackets() { @@ -25,7 +34,7 @@ public class ProtocolSnapshotTo1_9_3 extends Protocol { map(Type.INT); // 3 - y map(Type.INT); // 4 - z map(Type.FLOAT); // 5 - Volume - map(Type.UNSIGNED_BYTE, Type.FLOAT); // 6 - Pitch + map(Type.UNSIGNED_BYTE, toNewPitch); // 6 - Pitch } }); @@ -39,7 +48,7 @@ public class ProtocolSnapshotTo1_9_3 extends Protocol { map(Type.INT); // 3 - y map(Type.INT); // 4 - z map(Type.FLOAT); // 5 - Volume - map(Type.UNSIGNED_BYTE, Type.FLOAT); // 6 - Pitch + map(Type.UNSIGNED_BYTE, toNewPitch); // 6 - Pitch } });