diff --git a/common/src/main/java/us/myles/ViaVersion/api/minecraft/chunks/BaseChunk.java b/common/src/main/java/us/myles/ViaVersion/api/minecraft/chunks/BaseChunk.java index 931dda65e..7614d63a5 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/minecraft/chunks/BaseChunk.java +++ b/common/src/main/java/us/myles/ViaVersion/api/minecraft/chunks/BaseChunk.java @@ -9,13 +9,13 @@ import java.util.List; @AllArgsConstructor @Data public class BaseChunk implements Chunk { - protected int x; - protected int z; - protected boolean groundUp; - protected int bitmask; - protected ChunkSection[] sections; - protected byte[] biomeData; - protected List blockEntities; + protected int x; + protected int z; + protected boolean groundUp; + protected int bitmask; + protected ChunkSection[] sections; + protected int[] biomeData; + protected List blockEntities; @Override public boolean isBiomeData() { diff --git a/common/src/main/java/us/myles/ViaVersion/api/minecraft/chunks/Chunk.java b/common/src/main/java/us/myles/ViaVersion/api/minecraft/chunks/Chunk.java index f5b078748..7b2589dfb 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/minecraft/chunks/Chunk.java +++ b/common/src/main/java/us/myles/ViaVersion/api/minecraft/chunks/Chunk.java @@ -15,7 +15,7 @@ public interface Chunk { ChunkSection[] getSections(); - byte[] getBiomeData(); + int[] getBiomeData(); List getBlockEntities(); diff --git a/common/src/main/java/us/myles/ViaVersion/api/minecraft/chunks/Chunk1_8.java b/common/src/main/java/us/myles/ViaVersion/api/minecraft/chunks/Chunk1_8.java index 4bfe7f3ed..1a79c1891 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/minecraft/chunks/Chunk1_8.java +++ b/common/src/main/java/us/myles/ViaVersion/api/minecraft/chunks/Chunk1_8.java @@ -10,7 +10,7 @@ public class Chunk1_8 extends BaseChunk { @Getter private boolean unloadPacket = false; - public Chunk1_8(int x, int z, boolean groundUp, int bitmask, ChunkSection[] sections, byte[] biomeData, List blockEntities) { + public Chunk1_8(int x, int z, boolean groundUp, int bitmask, ChunkSection[] sections, int[] biomeData, List blockEntities) { super(x, z, groundUp, bitmask, sections, biomeData, blockEntities); } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/Protocol1_13To1_12_2.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/Protocol1_13To1_12_2.java index cb27c3719..ce98f2aef 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/Protocol1_13To1_12_2.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/Protocol1_13To1_12_2.java @@ -18,12 +18,15 @@ import us.myles.ViaVersion.api.remapper.ValueTransformer; import us.myles.ViaVersion.api.type.Type; import us.myles.ViaVersion.packets.State; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections.ConnectionData; +import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections.providers.BlockConnectionProvider; +import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections.providers.PacketBlockConnectionProvider; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.MappingData; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.packets.EntityPackets; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.packets.InventoryPackets; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.packets.WorldPackets; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.providers.BlockEntityProvider; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.providers.PaintingProvider; +import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.storage.BlockConnectionStorage; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.storage.BlockStorage; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.storage.EntityTracker; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.storage.TabCompleteTracker; @@ -1042,6 +1045,11 @@ public class Protocol1_13To1_12_2 extends Protocol { if (!userConnection.has(ClientWorld.class)) userConnection.put(new ClientWorld(userConnection)); userConnection.put(new BlockStorage(userConnection)); + if (Via.getConfig().isServersideBlockConnections()) { + if (Via.getManager().getProviders().get(BlockConnectionProvider.class) instanceof PacketBlockConnectionProvider) { + userConnection.put(new BlockConnectionStorage(userConnection)); + } + } } @Override diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/packets/WorldPackets.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/packets/WorldPackets.java index 3182f63e3..5c9486c42 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/packets/WorldPackets.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/packets/WorldPackets.java @@ -334,7 +334,7 @@ public class WorldPackets { if (chunk.isBiomeData()) { int latestBiomeWarn = Integer.MIN_VALUE; for (int i = 0; i < 256; i++) { - int biome = chunk.getBiomeData()[i] & 0xFF; + int biome = chunk.getBiomeData()[i]; if (!validBiomes.contains(biome)) { if (biome != 255 // is it generated naturally? *shrug* && latestBiomeWarn != biome) { diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/types/Chunk1_13Type.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/types/Chunk1_13Type.java index 7b5d72100..ac030d099 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/types/Chunk1_13Type.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/types/Chunk1_13Type.java @@ -52,11 +52,10 @@ public class Chunk1_13Type extends PartialType { } } - byte[] biomeData = groundUp ? new byte[256] : null; + int[] biomeData = groundUp ? new int[256] : null; if (groundUp) { for (int i = 0; i < 256; i++) { - // todo use int in Chunk? - biomeData[i] = (byte) input.readInt(); + biomeData[i] = input.readInt(); } } @@ -99,8 +98,8 @@ public class Chunk1_13Type extends PartialType { // Write biome data if (chunk.isBiomeData()) { - for (byte value : chunk.getBiomeData()) { - output.writeInt(value & 0xFF); // This is a temporary workaround, we'll look into fixing this soon :) + for (int value : chunk.getBiomeData()) { + output.writeInt(value); } } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9_1_2to1_9_3_4/types/Chunk1_9_3_4Type.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9_1_2to1_9_3_4/types/Chunk1_9_3_4Type.java index 5f7188ca4..d40bf219a 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9_1_2to1_9_3_4/types/Chunk1_9_3_4Type.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9_1_2to1_9_3_4/types/Chunk1_9_3_4Type.java @@ -53,9 +53,11 @@ public class Chunk1_9_3_4Type extends PartialType { } } - byte[] biomeData = groundUp ? new byte[256] : null; + int[] biomeData = groundUp ? new int[256] : null; if (groundUp) { - input.readBytes(biomeData); + for (int i = 0; i < 256; i++) { + biomeData[i] = input.readByte() & 0xFF; + } } List nbtData = new ArrayList<>(Arrays.asList(Type.NBT_ARRAY.read(input))); @@ -97,7 +99,9 @@ public class Chunk1_9_3_4Type extends PartialType { // Write biome data if (chunk.isBiomeData()) { - output.writeBytes(chunk.getBiomeData()); + for (int biome : chunk.getBiomeData()) { + buf.writeByte((byte) biome); + } } // Write Block Entities diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9_3to1_9_1_2/types/Chunk1_9_1_2Type.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9_3to1_9_1_2/types/Chunk1_9_1_2Type.java index 64a0bc949..9dcc6e5e6 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9_3to1_9_1_2/types/Chunk1_9_1_2Type.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9_3to1_9_1_2/types/Chunk1_9_1_2Type.java @@ -59,9 +59,11 @@ public class Chunk1_9_1_2Type extends PartialType { } } - byte[] biomeData = groundUp ? new byte[256] : null; + int[] biomeData = groundUp ? new int[256] : null; if (groundUp) { - input.readBytes(biomeData); + for (int i = 0; i < 256; i++) { + biomeData[i] = input.readByte() & 0xFF; + } } return new BaseChunk(chunkX, chunkZ, groundUp, primaryBitmask, sections, biomeData, new ArrayList()); @@ -93,7 +95,9 @@ public class Chunk1_9_1_2Type extends PartialType { // Write biome data if (chunk.isBiomeData()) { - output.writeBytes(chunk.getBiomeData()); + for (int biome : chunk.getBiomeData()) { + output.writeByte((byte) biome); + } } } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/types/Chunk1_9to1_8Type.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/types/Chunk1_9to1_8Type.java index 4f2d47b18..7f681d69e 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/types/Chunk1_9to1_8Type.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/types/Chunk1_9to1_8Type.java @@ -61,7 +61,7 @@ public class Chunk1_9to1_8Type extends PartialType { // Data to be read BitSet usedSections = new BitSet(16); ChunkSection[] sections = new ChunkSection[16]; - byte[] biomeData = null; + int[] biomeData = null; // Calculate section count from bitmask for (int i = 0; i < 16; i++) { @@ -112,8 +112,10 @@ public class Chunk1_9to1_8Type extends PartialType { // Read biome data if (bytesLeft >= BIOME_DATA_LENGTH) { - biomeData = new byte[BIOME_DATA_LENGTH]; - input.readBytes(biomeData); + biomeData = new int[BIOME_DATA_LENGTH]; + for (int i = 0; i < BIOME_DATA_LENGTH; i++){ + biomeData[i] = input.readByte() & 0xFF; + } bytesLeft -= BIOME_DATA_LENGTH; } @@ -156,7 +158,9 @@ public class Chunk1_9to1_8Type extends PartialType { // Write biome data if (chunk.hasBiomeData()) { - output.writeBytes(chunk.getBiomeData()); + for (int biome : chunk.getBiomeData()) { + buf.writeByte((byte) biome); + } } } }