diff --git a/SpigotCore_14/src/de/steamwar/techhider/ChunkHider14.java b/SpigotCore_14/src/de/steamwar/techhider/ChunkHider14.java index 6f779a6..9b2ab0b 100644 --- a/SpigotCore_14/src/de/steamwar/techhider/ChunkHider14.java +++ b/SpigotCore_14/src/de/steamwar/techhider/ChunkHider14.java @@ -27,7 +27,7 @@ import java.util.Set; public class ChunkHider14 extends ChunkHider9 { @Override - protected void dataHider(PosEvaluator locationEvaluator, int obfuscationTarget, Set obfuscate, ByteBuf in, ByteBuf out) { + protected void dataHider(PosEvaluator locationEvaluator, int obfuscationTarget, Set obfuscate, ByteBuf in, ByteBuf out, boolean skip) { out.writeShort(in.readShort()); // Block count byte bitsPerBlock = in.readByte(); out.writeByte(bitsPerBlock); @@ -37,6 +37,6 @@ public class ChunkHider14 extends ChunkHider9 { obfuscate = Collections.emptySet(); } - processDataArray(locationEvaluator, obfuscationTarget, obfuscate, in, out, bitsPerBlock); + processDataArray(locationEvaluator, obfuscationTarget, obfuscate, in, out, bitsPerBlock, skip); } } diff --git a/SpigotCore_18/src/de/steamwar/techhider/ChunkHider18.java b/SpigotCore_18/src/de/steamwar/techhider/ChunkHider18.java index 2d0b1fe..07d59b2 100644 --- a/SpigotCore_18/src/de/steamwar/techhider/ChunkHider18.java +++ b/SpigotCore_18/src/de/steamwar/techhider/ChunkHider18.java @@ -73,7 +73,7 @@ public class ChunkHider18 implements ChunkHider { int zOffset = 16*chunkZ; for(int yOffset = p.getWorld().getMinHeight(); yOffset < p.getWorld().getMaxHeight(); yOffset += 16) { int finalYOffset = yOffset; - dataHider((x, y, z) -> locationEvaluator.check(p, x+xOffset, y+finalYOffset, z+zOffset), obfuscationTarget, obfuscate, in, out); + dataHider((x, y, z) -> locationEvaluator.check(p, x+xOffset, y+finalYOffset, z+zOffset), obfuscationTarget, obfuscate, in, out, locationEvaluator.skipChunkSection(p, chunkX, yOffset/16, chunkZ)); } out.writeBytes(in); // MC appends a 0 byte at the end if there is a full chunk, idk why @@ -95,10 +95,10 @@ public class ChunkHider18 implements ChunkHider { return !hiddenBlockEntities.contains((String) getName.invoke(getKey.invoke(tileEntityTypes, entityType.get(tile)))); } - private void dataHider(PosEvaluator locationEvaluator, int obfuscationTarget, Set obfuscate, ByteBuf in, ByteBuf out) { + private void dataHider(PosEvaluator locationEvaluator, int obfuscationTarget, Set obfuscate, ByteBuf in, ByteBuf out, boolean skip) { out.writeShort(in.readShort()); // Block count - containerWalker(in, out, 15, obfuscationTarget, obfuscate, (paletteTarget, dataArrayLength, bitsPerBlock) -> { + containerWalker(in, out, 15, obfuscationTarget, skip ? Collections.emptySet() : obfuscate, (paletteTarget, dataArrayLength, bitsPerBlock) -> { Set palettedObfuscate; if(bitsPerBlock < 15) { palettedObfuscate = Collections.emptySet(); @@ -107,6 +107,11 @@ public class ChunkHider18 implements ChunkHider { palettedObfuscate = obfuscate; } + if(skip || dataArrayLength == 0) { + out.writeBytes(in, dataArrayLength*8); + return; + } + long[] array = new long[dataArrayLength]; for(int i = 0; i < dataArrayLength; i++) array[i] = in.readLong(); diff --git a/SpigotCore_18/src/de/steamwar/techhider/ProtocolWrapper18.java b/SpigotCore_18/src/de/steamwar/techhider/ProtocolWrapper18.java index 9f78b08..d314c2d 100644 --- a/SpigotCore_18/src/de/steamwar/techhider/ProtocolWrapper18.java +++ b/SpigotCore_18/src/de/steamwar/techhider/ProtocolWrapper18.java @@ -77,7 +77,7 @@ public class ProtocolWrapper18 implements ProtocolWrapper { newPos[i] = poss.get(i); multiBlockChangePos.set(packet, newPos); - multiBlockChangeBlocks.set(packet, blocks.toArray()); + multiBlockChangeBlocks.set(packet, blocks.toArray(new IBlockData[0])); return packet; }; } diff --git a/SpigotCore_8/src/de/steamwar/techhider/ProtocolWrapper8.java b/SpigotCore_8/src/de/steamwar/techhider/ProtocolWrapper8.java index 5b30a6b..ba307d0 100644 --- a/SpigotCore_8/src/de/steamwar/techhider/ProtocolWrapper8.java +++ b/SpigotCore_8/src/de/steamwar/techhider/ProtocolWrapper8.java @@ -23,6 +23,7 @@ import com.comphenix.tinyprotocol.Reflection; import org.bukkit.Material; import org.bukkit.entity.Player; +import java.lang.reflect.Array; import java.util.ArrayList; import java.util.Set; import java.util.function.BiFunction; @@ -67,7 +68,7 @@ public class ProtocolWrapper8 implements ProtocolWrapper { if(blockChangeInfos.isEmpty()) return null; - multiBlockChangeInfos.set(packet, blockChangeInfos.toArray(mbcis)); + multiBlockChangeInfos.set(packet, blockChangeInfos.toArray((Object[])Array.newInstance(multiBlockChangeInfo, 0))); return packet; }; } diff --git a/SpigotCore_9/src/de/steamwar/techhider/ChunkHider9.java b/SpigotCore_9/src/de/steamwar/techhider/ChunkHider9.java index 8f34dbb..bb9bf5b 100644 --- a/SpigotCore_9/src/de/steamwar/techhider/ChunkHider9.java +++ b/SpigotCore_9/src/de/steamwar/techhider/ChunkHider9.java @@ -67,7 +67,7 @@ public class ChunkHider9 extends ChunkHider8 { continue; int yOffset = 16*chunkY; - dataHider((x, y, z) -> locationEvaluator.check(p, x+xOffset, y+yOffset, z+zOffset), obfuscationTarget, obfuscate, in, out); + dataHider((x, y, z) -> locationEvaluator.check(p, x+xOffset, y+yOffset, z+zOffset), obfuscationTarget, obfuscate, in, out, locationEvaluator.skipChunkSection(p, chunkX, chunkY, chunkZ)); } byte[] data = new byte[out.readableBytes()]; out.readBytes(data); @@ -77,25 +77,30 @@ public class ChunkHider9 extends ChunkHider8 { }; } - protected void dataHider(PosEvaluator locationEvaluator, int obfuscationTarget, Set obfuscate, ByteBuf in, ByteBuf out) { + protected void dataHider(PosEvaluator locationEvaluator, int obfuscationTarget, Set obfuscate, ByteBuf in, ByteBuf out, boolean skip) { byte bitsPerBlock = in.readByte(); out.writeByte(bitsPerBlock); - int paletteTarget = ChunkHider.processPalette(obfuscationTarget, obfuscate, in, out); + int paletteTarget = ChunkHider.processPalette(obfuscationTarget, skip ? Collections.emptySet() : obfuscate, in, out); if(bitsPerBlock < 13) { obfuscationTarget = paletteTarget; obfuscate = Collections.emptySet(); } - processDataArray(locationEvaluator, obfuscationTarget, obfuscate, in, out, bitsPerBlock); + processDataArray(locationEvaluator, obfuscationTarget, obfuscate, in, out, bitsPerBlock, skip); out.writeBytes(in, 4096); //Skylight (Not in Nether/End!!!) 2048 + Blocklight 2048 } - protected void processDataArray(PosEvaluator locationEvaluator, int obfuscationTarget, Set obfuscate, ByteBuf in, ByteBuf out, int bitsPerBlock) { + protected void processDataArray(PosEvaluator locationEvaluator, int obfuscationTarget, Set obfuscate, ByteBuf in, ByteBuf out, int bitsPerBlock, boolean skip) { int dataArrayLength = ProtocolUtils.readVarInt(in); ProtocolUtils.writeVarInt(out, dataArrayLength); + if(skip) { + out.writeBytes(in, dataArrayLength*8); + return; + } + VariableValueArray values = new VariableValueArray(bitsPerBlock, dataArrayLength, in); for (int y = 0; y < 16; y++) { for (int z = 0; z < 16; z++) {