From b7b8bdc8418feb4f4be8a1fc05965b051c9779be Mon Sep 17 00:00:00 2001 From: KennyTV <28825609+KennyTV@users.noreply.github.com> Date: Wed, 11 Dec 2019 12:07:22 +0100 Subject: [PATCH 01/11] Ignore unneeded sound warnings --- .../protocol1_14to1_13_2/data/MappingData.java | 14 +++++++++++--- .../protocol1_15to1_14_4/data/MappingData.java | 3 ++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/data/MappingData.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/data/MappingData.java index 63811fc01..256074bee 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/data/MappingData.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/data/MappingData.java @@ -110,11 +110,15 @@ public class MappingData { } private static void mapIdentifiers(short[] output, JsonArray oldIdentifiers, JsonArray newIdentifiers) { + mapIdentifiers(output, oldIdentifiers, newIdentifiers, true); + } + + private static void mapIdentifiers(short[] output, JsonArray oldIdentifiers, JsonArray newIdentifiers, boolean warnOnMissing) { for (int i = 0; i < oldIdentifiers.size(); i++) { JsonElement v = oldIdentifiers.get(i); Integer index = findIndex(newIdentifiers, v.getAsString()); if (index == null) { - if (!Via.getConfig().isSuppress1_13ConversionErrors() || Via.getManager().isDebug()) { + if (warnOnMissing && !Via.getConfig().isSuppress1_13ConversionErrors() || Via.getManager().isDebug()) { Via.getPlatform().getLogger().warning("No key for " + v + " :( "); } continue; @@ -150,10 +154,14 @@ public class MappingData { public static class SoundMappingShortArray implements SoundMappings { private short[] oldToNew; - public SoundMappingShortArray(JsonArray mapping1_13_2, JsonArray mapping1_14) { + public SoundMappingShortArray(JsonArray mapping1_13_2, JsonArray mapping1_14, boolean warnOnMissing) { oldToNew = new short[mapping1_13_2.size()]; Arrays.fill(oldToNew, (short) -1); - mapIdentifiers(oldToNew, mapping1_13_2, mapping1_14); + mapIdentifiers(oldToNew, mapping1_13_2, mapping1_14, warnOnMissing); + } + + public SoundMappingShortArray(JsonArray mapping1_13_2, JsonArray mapping1_14) { + this(mapping1_13_2, mapping1_14, true); } @Override diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_15to1_14_4/data/MappingData.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_15to1_14_4/data/MappingData.java index 11d539a84..af9ec6dcd 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_15to1_14_4/data/MappingData.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_15to1_14_4/data/MappingData.java @@ -22,6 +22,7 @@ public class MappingData { Via.getPlatform().getLogger().info("Loading 1.14.4 -> 1.15 item mapping..."); us.myles.ViaVersion.protocols.protocol1_14to1_13_2.data.MappingData.mapIdentifiers(oldToNewItems, mapping1_14_4.getAsJsonObject("items"), mapping1_15.getAsJsonObject("items")); Via.getPlatform().getLogger().info("Loading 1.14.4 -> 1.15 sound mapping..."); - soundMappings = new us.myles.ViaVersion.protocols.protocol1_14to1_13_2.data.MappingData.SoundMappingShortArray(mapping1_14_4.getAsJsonArray("sounds"), mapping1_15.getAsJsonArray("sounds")); + // A few removed sounds we can simply ignore + soundMappings = new us.myles.ViaVersion.protocols.protocol1_14to1_13_2.data.MappingData.SoundMappingShortArray(mapping1_14_4.getAsJsonArray("sounds"), mapping1_15.getAsJsonArray("sounds"), false); } } From a21a2079c6cf3d8970b4581cca4121d9216f0a76 Mon Sep 17 00:00:00 2001 From: Myles Date: Wed, 11 Dec 2019 11:12:22 +0000 Subject: [PATCH 02/11] 2.2.1 --- README.md | 2 +- bukkit/pom.xml | 2 +- bungee/pom.xml | 2 +- common/pom.xml | 2 +- jar/pom.xml | 2 +- pom.xml | 2 +- sponge-legacy/pom.xml | 2 +- sponge/pom.xml | 2 +- velocity/pom.xml | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 50ced6ad7..7a3aa717f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# ViaVersion 2.2.0 - Spigot, Sponge, BungeeCord, Velocity +# ViaVersion 2.2.1 - Spigot, Sponge, BungeeCord, Velocity [![Build Status](https://travis-ci.com/ViaVersion/ViaVersion.svg?branch=master)](https://travis-ci.com/ViaVersion/ViaVersion) [![Discord](https://img.shields.io/badge/chat-on%20discord-blue.svg)](https://viaversion.com/discord) diff --git a/bukkit/pom.xml b/bukkit/pom.xml index 4ba8705a6..863ef96bd 100644 --- a/bukkit/pom.xml +++ b/bukkit/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 2.2.1-SNAPSHOT + 2.2.1 4.0.0 diff --git a/bungee/pom.xml b/bungee/pom.xml index 578e79a97..f00a9f9eb 100644 --- a/bungee/pom.xml +++ b/bungee/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 2.2.1-SNAPSHOT + 2.2.1 4.0.0 diff --git a/common/pom.xml b/common/pom.xml index d20e57b4a..bc5e18ca9 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 2.2.1-SNAPSHOT + 2.2.1 4.0.0 diff --git a/jar/pom.xml b/jar/pom.xml index 441b1ab7d..c6ffd35bc 100644 --- a/jar/pom.xml +++ b/jar/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 2.2.1-SNAPSHOT + 2.2.1 4.0.0 viaversion-jar diff --git a/pom.xml b/pom.xml index 1db37c004..420917b26 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ us.myles viaversion-parent - 2.2.1-SNAPSHOT + 2.2.1 pom viaversion-parent diff --git a/sponge-legacy/pom.xml b/sponge-legacy/pom.xml index a4c2c71a8..dd135e3cc 100644 --- a/sponge-legacy/pom.xml +++ b/sponge-legacy/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 2.2.1-SNAPSHOT + 2.2.1 4.0.0 diff --git a/sponge/pom.xml b/sponge/pom.xml index 6fd4222d3..0ff68d54f 100644 --- a/sponge/pom.xml +++ b/sponge/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 2.2.1-SNAPSHOT + 2.2.1 4.0.0 diff --git a/velocity/pom.xml b/velocity/pom.xml index 524b77df1..e60a07d0c 100644 --- a/velocity/pom.xml +++ b/velocity/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 2.2.1-SNAPSHOT + 2.2.1 4.0.0 From c1b11a55d52f9d94cce193cc4b2604827b4489c6 Mon Sep 17 00:00:00 2001 From: Myles Date: Wed, 11 Dec 2019 11:16:05 +0000 Subject: [PATCH 03/11] Back to SNAPSHOT --- bukkit/pom.xml | 2 +- bungee/pom.xml | 2 +- common/pom.xml | 2 +- jar/pom.xml | 2 +- pom.xml | 2 +- sponge-legacy/pom.xml | 2 +- sponge/pom.xml | 2 +- velocity/pom.xml | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/bukkit/pom.xml b/bukkit/pom.xml index 863ef96bd..b147f8899 100644 --- a/bukkit/pom.xml +++ b/bukkit/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 2.2.1 + 2.2.2-SNAPSHOT 4.0.0 diff --git a/bungee/pom.xml b/bungee/pom.xml index f00a9f9eb..e14b03717 100644 --- a/bungee/pom.xml +++ b/bungee/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 2.2.1 + 2.2.2-SNAPSHOT 4.0.0 diff --git a/common/pom.xml b/common/pom.xml index bc5e18ca9..ae1f37945 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 2.2.1 + 2.2.2-SNAPSHOT 4.0.0 diff --git a/jar/pom.xml b/jar/pom.xml index c6ffd35bc..d078861e0 100644 --- a/jar/pom.xml +++ b/jar/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 2.2.1 + 2.2.2-SNAPSHOT 4.0.0 viaversion-jar diff --git a/pom.xml b/pom.xml index 420917b26..3b4192b37 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ us.myles viaversion-parent - 2.2.1 + 2.2.2-SNAPSHOT pom viaversion-parent diff --git a/sponge-legacy/pom.xml b/sponge-legacy/pom.xml index dd135e3cc..b3786c360 100644 --- a/sponge-legacy/pom.xml +++ b/sponge-legacy/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 2.2.1 + 2.2.2-SNAPSHOT 4.0.0 diff --git a/sponge/pom.xml b/sponge/pom.xml index 0ff68d54f..2ad860ec4 100644 --- a/sponge/pom.xml +++ b/sponge/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 2.2.1 + 2.2.2-SNAPSHOT 4.0.0 diff --git a/velocity/pom.xml b/velocity/pom.xml index e60a07d0c..f3a585118 100644 --- a/velocity/pom.xml +++ b/velocity/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 2.2.1 + 2.2.2-SNAPSHOT 4.0.0 From 1002ca401613294db2ecc06ed35a575c483ce41b Mon Sep 17 00:00:00 2001 From: KennyTV <28825609+KennyTV@users.noreply.github.com> Date: Wed, 11 Dec 2019 20:36:49 +0100 Subject: [PATCH 04/11] Fix biomedata on some custom Spigot versions --- .../packets/WorldPackets.java | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_15to1_14_4/packets/WorldPackets.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_15to1_14_4/packets/WorldPackets.java index 77cd2cf22..a3578e146 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_15to1_14_4/packets/WorldPackets.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_15to1_14_4/packets/WorldPackets.java @@ -101,18 +101,20 @@ public class WorldPackets { if (chunk.isGroundUp()) { int[] biomeData = chunk.getBiomeData(); int[] newBiomeData = new int[1024]; - // Now in 4x4x4 areas - take the biome of each "middle" - for (int i = 0; i < 4; ++i) { - for (int j = 0; j < 4; ++j) { - int x = (j << 2) + 2; - int z = (i << 2) + 2; - int oldIndex = (z << 4 | x); - newBiomeData[i << 2 | j] = biomeData[oldIndex]; + if (biomeData != null) { + // Now in 4x4x4 areas - take the biome of each "middle" + for (int i = 0; i < 4; ++i) { + for (int j = 0; j < 4; ++j) { + int x = (j << 2) + 2; + int z = (i << 2) + 2; + int oldIndex = (z << 4 | x); + newBiomeData[i << 2 | j] = biomeData[oldIndex]; + } + } + // ... and copy it to the new y layers + for (int i = 1; i < 64; ++i) { + System.arraycopy(newBiomeData, 0, newBiomeData, i * 16, 16); } - } - // ... and copy it to the new y layers - for (int i = 1; i < 64; ++i) { - System.arraycopy(newBiomeData, 0, newBiomeData, i * 16, 16); } chunk.setBiomeData(newBiomeData); From a42e724f506dc53acedc7a1e2b28871075e32401 Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Wed, 11 Dec 2019 23:51:39 -0500 Subject: [PATCH 05/11] Remove unneeded indirection in NBTType ByteBufInputStream implements DataInput, ByteBufOutputStream implements DataOutput. Use them to exploit native Netty ByteBuf calls where possible. --- .../ViaVersion/api/type/types/minecraft/NBTType.java | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/common/src/main/java/us/myles/ViaVersion/api/type/types/minecraft/NBTType.java b/common/src/main/java/us/myles/ViaVersion/api/type/types/minecraft/NBTType.java index f46d994f6..4e9ac52e2 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/type/types/minecraft/NBTType.java +++ b/common/src/main/java/us/myles/ViaVersion/api/type/types/minecraft/NBTType.java @@ -36,10 +36,7 @@ public class NBTType extends Type { return null; } else { buffer.readerIndex(readerIndex); - ByteBufInputStream bytebufStream = new ByteBufInputStream(buffer); - try (DataInputStream dataInputStream = new DataInputStream(bytebufStream)) { - return (CompoundTag) NBTIO.readTag((DataInput) dataInputStream); - } + return (CompoundTag) NBTIO.readTag((DataInput) new ByteBufInputStream(buffer)); } } @@ -49,11 +46,7 @@ public class NBTType extends Type { buffer.writeByte(0); } else { ByteBufOutputStream bytebufStream = new ByteBufOutputStream(buffer); - DataOutputStream dataOutputStream = new DataOutputStream(bytebufStream); - - NBTIO.writeTag((DataOutput) dataOutputStream, object); - - dataOutputStream.close(); + NBTIO.writeTag((DataOutput) bytebufStream, object); } } } From 220c45b8001a13d9b1c274abd8926b3235010384 Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Wed, 11 Dec 2019 23:55:44 -0500 Subject: [PATCH 06/11] Remove indirection in StringType decoding --- .../myles/ViaVersion/api/type/types/StringType.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/common/src/main/java/us/myles/ViaVersion/api/type/types/StringType.java b/common/src/main/java/us/myles/ViaVersion/api/type/types/StringType.java index 7a0ba098d..fc3a9f340 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/type/types/StringType.java +++ b/common/src/main/java/us/myles/ViaVersion/api/type/types/StringType.java @@ -1,14 +1,15 @@ package us.myles.ViaVersion.api.type.types; -import com.google.common.base.Charsets; import com.google.common.base.Preconditions; import io.netty.buffer.ByteBuf; import us.myles.ViaVersion.api.type.Type; +import java.nio.charset.StandardCharsets; + public class StringType extends Type { // String#length() (used to limit the string in Minecraft source code) uses char[]#length private static final int maxJavaCharUtf8Length = Character.toString(Character.MAX_VALUE) - .getBytes(Charsets.UTF_8).length; + .getBytes(StandardCharsets.UTF_8).length; public StringType() { super(String.class); @@ -21,9 +22,9 @@ public class StringType extends Type { Preconditions.checkArgument(len <= Short.MAX_VALUE * maxJavaCharUtf8Length, "Cannot receive string longer than Short.MAX_VALUE * " + maxJavaCharUtf8Length + " bytes (got %s bytes)", len); - byte[] b = new byte[len]; - buffer.readBytes(b); - String string = new String(b, Charsets.UTF_8); + String string = buffer.toString(buffer.readerIndex(), len, StandardCharsets.UTF_8); + buffer.skipBytes(len); + Preconditions.checkArgument(string.length() <= Short.MAX_VALUE, "Cannot receive string longer than Short.MAX_VALUE characters (got %s bytes)", string.length()); @@ -34,7 +35,7 @@ public class StringType extends Type { public void write(ByteBuf buffer, String object) throws Exception { Preconditions.checkArgument(object.length() <= Short.MAX_VALUE, "Cannot send string longer than Short.MAX_VALUE (got %s characters)", object.length()); - byte[] b = object.getBytes(Charsets.UTF_8); + byte[] b = object.getBytes(StandardCharsets.UTF_8); Type.VAR_INT.write(buffer, b.length); buffer.writeBytes(b); } From ba08c3ad2fa0ce17dd75964f0b6a37db280bfb6f Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Thu, 12 Dec 2019 00:02:09 -0500 Subject: [PATCH 07/11] Remove indirection in byte array writing This saves us from the cost of (un)boxing bytes on the fly. --- .../us/myles/ViaVersion/api/type/Type.java | 2 +- .../api/type/types/ByteArrayType.java | 27 +++++++++++++++++++ .../packets/WorldPackets.java | 14 +++------- 3 files changed, 31 insertions(+), 12 deletions(-) create mode 100644 common/src/main/java/us/myles/ViaVersion/api/type/types/ByteArrayType.java diff --git a/common/src/main/java/us/myles/ViaVersion/api/type/Type.java b/common/src/main/java/us/myles/ViaVersion/api/type/Type.java index 25c6cd0ab..ca0dceb9d 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/type/Type.java +++ b/common/src/main/java/us/myles/ViaVersion/api/type/Type.java @@ -14,7 +14,7 @@ import java.util.UUID; public abstract class Type implements ByteBufReader, ByteBufWriter { /* Defined Types */ public static final Type BYTE = new ByteType(); - public static final Type BYTE_ARRAY = new ArrayType<>(Type.BYTE); + public static final Type BYTE_ARRAY = new ByteArrayType(); public static final Type REMAINING_BYTES = new RemainingBytesType(); diff --git a/common/src/main/java/us/myles/ViaVersion/api/type/types/ByteArrayType.java b/common/src/main/java/us/myles/ViaVersion/api/type/types/ByteArrayType.java new file mode 100644 index 000000000..429e37062 --- /dev/null +++ b/common/src/main/java/us/myles/ViaVersion/api/type/types/ByteArrayType.java @@ -0,0 +1,27 @@ +package us.myles.ViaVersion.api.type.types; + +import com.google.common.base.Preconditions; +import io.netty.buffer.ByteBuf; +import us.myles.ViaVersion.api.type.Type; + +public class ByteArrayType extends Type { + public ByteArrayType() { + super("Byte Array", byte[].class); + } + + @Override + public byte[] read(ByteBuf buffer) throws Exception { + int len = Type.VAR_INT.read(buffer); + + Preconditions.checkArgument(buffer.isReadable(len), "Could not read %s bytes from buffer (have %s)", len, buffer.readableBytes()); + byte[] data = new byte[len]; + buffer.readBytes(data); + return data; + } + + @Override + public void write(ByteBuf buffer, byte[] object) throws Exception { + Type.VAR_INT.write(buffer, object.length); + buffer.writeBytes(object); + } +} diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/packets/WorldPackets.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/packets/WorldPackets.java index 3f10c4326..4bddfd9bd 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/packets/WorldPackets.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/packets/WorldPackets.java @@ -32,7 +32,7 @@ public class WorldPackets { private static final int VOID_AIR = MappingData.blockStateMappings.getNewBlock(8591); private static final int CAVE_AIR = MappingData.blockStateMappings.getNewBlock(8592); public static final int SERVERSIDE_VIEW_DISTANCE = 64; - private static final Byte[] FULL_LIGHT = new Byte[2048]; + private static final byte[] FULL_LIGHT = new byte[2048]; static { Arrays.fill(FULL_LIGHT, (byte) 0xff); @@ -242,14 +242,14 @@ public class WorldPackets { } continue; } - lightPacket.write(Type.BYTE_ARRAY, fromPrimitiveArray(section.getSkyLight())); + lightPacket.write(Type.BYTE_ARRAY, section.getSkyLight()); } if (chunk.isGroundUp()) lightPacket.write(Type.BYTE_ARRAY, FULL_LIGHT); // chunk above 255 for (ChunkSection section : chunk.getSections()) { if (section == null) continue; - lightPacket.write(Type.BYTE_ARRAY, fromPrimitiveArray(section.getBlockLight())); + lightPacket.write(Type.BYTE_ARRAY, section.getBlockLight()); } EntityTracker entityTracker = wrapper.user().get(EntityTracker.class); @@ -268,14 +268,6 @@ public class WorldPackets { lightPacket.send(Protocol1_14To1_13_2.class, true, true); } - - private Byte[] fromPrimitiveArray(byte[] bytes) { - Byte[] newArray = new Byte[bytes.length]; - for (int i = 0; i < bytes.length; i++) { - newArray[i] = bytes[i]; - } - return newArray; - } }); } }); From 437463f1b4082382d42e3b179199b17caba6c0df Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Thu, 12 Dec 2019 20:45:03 -0500 Subject: [PATCH 08/11] Revert "Remove indirection in byte array writing" This reverts commit ba08c3ad2fa0ce17dd75964f0b6a37db280bfb6f. Breaks the API that ViaRewind and ViaBackwards depend on. --- .../us/myles/ViaVersion/api/type/Type.java | 2 +- .../api/type/types/ByteArrayType.java | 27 ------------------- .../packets/WorldPackets.java | 14 +++++++--- 3 files changed, 12 insertions(+), 31 deletions(-) delete mode 100644 common/src/main/java/us/myles/ViaVersion/api/type/types/ByteArrayType.java diff --git a/common/src/main/java/us/myles/ViaVersion/api/type/Type.java b/common/src/main/java/us/myles/ViaVersion/api/type/Type.java index ca0dceb9d..25c6cd0ab 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/type/Type.java +++ b/common/src/main/java/us/myles/ViaVersion/api/type/Type.java @@ -14,7 +14,7 @@ import java.util.UUID; public abstract class Type implements ByteBufReader, ByteBufWriter { /* Defined Types */ public static final Type BYTE = new ByteType(); - public static final Type BYTE_ARRAY = new ByteArrayType(); + public static final Type BYTE_ARRAY = new ArrayType<>(Type.BYTE); public static final Type REMAINING_BYTES = new RemainingBytesType(); diff --git a/common/src/main/java/us/myles/ViaVersion/api/type/types/ByteArrayType.java b/common/src/main/java/us/myles/ViaVersion/api/type/types/ByteArrayType.java deleted file mode 100644 index 429e37062..000000000 --- a/common/src/main/java/us/myles/ViaVersion/api/type/types/ByteArrayType.java +++ /dev/null @@ -1,27 +0,0 @@ -package us.myles.ViaVersion.api.type.types; - -import com.google.common.base.Preconditions; -import io.netty.buffer.ByteBuf; -import us.myles.ViaVersion.api.type.Type; - -public class ByteArrayType extends Type { - public ByteArrayType() { - super("Byte Array", byte[].class); - } - - @Override - public byte[] read(ByteBuf buffer) throws Exception { - int len = Type.VAR_INT.read(buffer); - - Preconditions.checkArgument(buffer.isReadable(len), "Could not read %s bytes from buffer (have %s)", len, buffer.readableBytes()); - byte[] data = new byte[len]; - buffer.readBytes(data); - return data; - } - - @Override - public void write(ByteBuf buffer, byte[] object) throws Exception { - Type.VAR_INT.write(buffer, object.length); - buffer.writeBytes(object); - } -} diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/packets/WorldPackets.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/packets/WorldPackets.java index 4bddfd9bd..3f10c4326 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/packets/WorldPackets.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/packets/WorldPackets.java @@ -32,7 +32,7 @@ public class WorldPackets { private static final int VOID_AIR = MappingData.blockStateMappings.getNewBlock(8591); private static final int CAVE_AIR = MappingData.blockStateMappings.getNewBlock(8592); public static final int SERVERSIDE_VIEW_DISTANCE = 64; - private static final byte[] FULL_LIGHT = new byte[2048]; + private static final Byte[] FULL_LIGHT = new Byte[2048]; static { Arrays.fill(FULL_LIGHT, (byte) 0xff); @@ -242,14 +242,14 @@ public class WorldPackets { } continue; } - lightPacket.write(Type.BYTE_ARRAY, section.getSkyLight()); + lightPacket.write(Type.BYTE_ARRAY, fromPrimitiveArray(section.getSkyLight())); } if (chunk.isGroundUp()) lightPacket.write(Type.BYTE_ARRAY, FULL_LIGHT); // chunk above 255 for (ChunkSection section : chunk.getSections()) { if (section == null) continue; - lightPacket.write(Type.BYTE_ARRAY, section.getBlockLight()); + lightPacket.write(Type.BYTE_ARRAY, fromPrimitiveArray(section.getBlockLight())); } EntityTracker entityTracker = wrapper.user().get(EntityTracker.class); @@ -268,6 +268,14 @@ public class WorldPackets { lightPacket.send(Protocol1_14To1_13_2.class, true, true); } + + private Byte[] fromPrimitiveArray(byte[] bytes) { + Byte[] newArray = new Byte[bytes.length]; + for (int i = 0; i < bytes.length; i++) { + newArray[i] = bytes[i]; + } + return newArray; + } }); } }); From 9c8a8e2e9c191b19918d0284a1caba976ccdad82 Mon Sep 17 00:00:00 2001 From: KennyTV <28825609+KennyTV@users.noreply.github.com> Date: Sat, 14 Dec 2019 16:22:24 +0100 Subject: [PATCH 09/11] Fix book edit --- .../protocols/protocol1_15to1_14_4/Protocol1_15To1_14_4.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_15to1_14_4/Protocol1_15To1_14_4.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_15to1_14_4/Protocol1_15To1_14_4.java index 80904747c..d0a2fe0ab 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_15to1_14_4/Protocol1_15To1_14_4.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_15to1_14_4/Protocol1_15To1_14_4.java @@ -55,7 +55,7 @@ public class Protocol1_15To1_14_4 extends Protocol { }); // Edit Book - registerIncoming(State.PLAY, 0x0C, 0x0D, new PacketRemapper() { + registerIncoming(State.PLAY, 0x0C, 0x0C, new PacketRemapper() { @Override public void registerMap() { handler(new PacketHandler() { From f35b931004d09ebd89f4b8a8bd370b29cfa2aedd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20Br=C3=A4mer?= Date: Sat, 14 Dec 2019 22:01:50 +0100 Subject: [PATCH 10/11] fix typo --- .../protocols/protocol1_13to1_12_2/data/MappingData.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/data/MappingData.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/data/MappingData.java index 9e5cfb34e..a9d3636bf 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/data/MappingData.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/data/MappingData.java @@ -48,7 +48,7 @@ public class MappingData { enchantmentMappings = new EnchantmentMappingByteArray(mapping1_12.getAsJsonObject("enchantments"), mapping1_13.getAsJsonObject("enchantments")); Via.getPlatform().getLogger().info("Loading 1.12.2 -> 1.13 sound mapping..."); soundMappings = new SoundMappingShortArray(mapping1_12.getAsJsonArray("sounds"), mapping1_13.getAsJsonArray("sounds")); - Via.getPlatform().getLogger().info("Loading translation mappping"); + Via.getPlatform().getLogger().info("Loading translation mapping"); translateMapping = new HashMap<>(); Map translateData = GsonUtil.getGson().fromJson( new InputStreamReader( From 33a34fc1495b23a5daa9559f1c4e0296917e2afc Mon Sep 17 00:00:00 2001 From: Myles Date: Sun, 15 Dec 2019 09:01:49 +0000 Subject: [PATCH 11/11] Update README with new table --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index 7a3aa717f..438f0d530 100644 --- a/README.md +++ b/README.md @@ -2,13 +2,11 @@ [![Build Status](https://travis-ci.com/ViaVersion/ViaVersion.svg?branch=master)](https://travis-ci.com/ViaVersion/ViaVersion) [![Discord](https://img.shields.io/badge/chat-on%20discord-blue.svg)](https://viaversion.com/discord) -IRC: [#viaversion](http://irc.spi.gt/iris/?channels=viaversion) on irc.spi.gt for Support. - **Allows the connection of higher client versions to lower server versions** Supported Versions: -![Table (https://i.imgur.com/iWAtD1p.png)](https://i.imgur.com/iWAtD1p.png) +![Table (https://i.imgur.com/yDtAgF7.png)](https://i.imgur.com/yDtAgF7.png) On Bukkit you may also use ProtocolSupport, but ensure you have the right build for your server version.