Working full chunk techhider version without debug output
Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Ursprung
6a4c080b5d
Commit
d8dc0cd6b0
@ -35,6 +35,9 @@ public class TechHider_15 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void chunkHider(){
|
static void chunkHider(){
|
||||||
|
/*
|
||||||
|
* Bevor editing this function read and understand: https://wiki.vg/Chunk_Format
|
||||||
|
* */
|
||||||
ProtocolLibrary.getProtocolManager().getAsynchronousManager().registerAsyncHandler(new PacketAdapter(IFightSystem.getPlugin(), PacketType.Play.Server.MAP_CHUNK) {
|
ProtocolLibrary.getProtocolManager().getAsynchronousManager().registerAsyncHandler(new PacketAdapter(IFightSystem.getPlugin(), PacketType.Play.Server.MAP_CHUNK) {
|
||||||
@Override
|
@Override
|
||||||
public void onPacketSending(PacketEvent e) {
|
public void onPacketSending(PacketEvent e) {
|
||||||
@ -114,12 +117,15 @@ public class TechHider_15 {
|
|||||||
}
|
}
|
||||||
i += actPaletteLength;
|
i += actPaletteLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//We modify only the chunk palette for performance reasons
|
||||||
int dataArrayLength = ITechHider.readVarInt(data, i);
|
int dataArrayLength = ITechHider.readVarInt(data, i);
|
||||||
int dataArrayLengthLength = ITechHider.readVarIntLength(data, i);
|
int dataArrayLengthLength = ITechHider.readVarIntLength(data, i);
|
||||||
buffer.writeBytes(data, i, dataArrayLength * 8 + dataArrayLengthLength);
|
buffer.writeBytes(data, i, dataArrayLength * 8 + dataArrayLengthLength);
|
||||||
i += dataArrayLengthLength;
|
i += dataArrayLengthLength;
|
||||||
i += dataArrayLength * 8;
|
i += dataArrayLength * 8;
|
||||||
}else{
|
}else{
|
||||||
|
//Full Chunk/no palette, so the chunk has to be crawled through
|
||||||
int dataArrayLength = ITechHider.readVarInt(data, i);
|
int dataArrayLength = ITechHider.readVarInt(data, i);
|
||||||
int dataArrayLengthLength = ITechHider.readVarIntLength(data, i);
|
int dataArrayLengthLength = ITechHider.readVarIntLength(data, i);
|
||||||
buffer.writeBytes(data, i, dataArrayLengthLength);
|
buffer.writeBytes(data, i, dataArrayLengthLength);
|
||||||
@ -128,8 +134,6 @@ public class TechHider_15 {
|
|||||||
ByteBuf chunkData = UnpooledByteBufAllocator.DEFAULT.directBuffer(dataArrayLength * 8);
|
ByteBuf chunkData = UnpooledByteBufAllocator.DEFAULT.directBuffer(dataArrayLength * 8);
|
||||||
chunkData.writeBytes(data, i, dataArrayLength * 8);
|
chunkData.writeBytes(data, i, dataArrayLength * 8);
|
||||||
|
|
||||||
int arrayEnd = dataArrayLength * 8 + i;
|
|
||||||
|
|
||||||
int bitsOver = 0; // Anzahl an Bits, die aus dem letzten Durchlauf noch über sind
|
int bitsOver = 0; // Anzahl an Bits, die aus dem letzten Durchlauf noch über sind
|
||||||
int lastBits = 0; // Die letzten Bits aus dem vorigen Durchlauf
|
int lastBits = 0; // Die letzten Bits aus dem vorigen Durchlauf
|
||||||
Bukkit.broadcastMessage("Full Chunk!");
|
Bukkit.broadcastMessage("Full Chunk!");
|
||||||
@ -147,24 +151,21 @@ public class TechHider_15 {
|
|||||||
|
|
||||||
if(currentPos > 50){ //64 - 14, Prüfen auf Ende des Longs
|
if(currentPos > 50){ //64 - 14, Prüfen auf Ende des Longs
|
||||||
int offset = 14 - (currentPos - 50);
|
int offset = 14 - (currentPos - 50);
|
||||||
if(arrayEnd <= i+15)
|
|
||||||
System.out.println("Array Overflow!!!! i: " + i + " currentPos:" + currentPos + " bitsOver:" + bitsOver + " lastBits:" + lastBits);
|
|
||||||
|
|
||||||
blockId |= (data[i+14] << (offset + 8) | data[i+15] << offset) & 0x3FFF;
|
blockId |= (data[i+14] << (offset + 8) | data[i+15] << offset) & 0x3FFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Config.HiddenBlocks.contains(blockId))
|
if(Config.HiddenBlocks.contains(blockId))
|
||||||
blockId = Config.ObfuscateWith;
|
blockId = Config.ObfuscateWith;
|
||||||
|
|
||||||
if(blockId > 11336)
|
//TODO: Fix last edge cases of Full Chunk techhider
|
||||||
System.out.println("WTF? blockId: " + blockId);
|
//if(blockId > 11336) Should not occur, but occurs
|
||||||
|
|
||||||
result <<= 14;
|
result <<= 14;
|
||||||
result |= blockId;
|
result |= blockId;
|
||||||
currentPos -= 14;
|
currentPos -= 14;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(currentPos > -14){ //Überprüfen der ersten Bits
|
if(currentPos > -14){ // Check the first bits of the chunk
|
||||||
int blockId = ((int)values << -currentPos | lastBits) & 0x3FFF;
|
int blockId = ((int)values << -currentPos | lastBits) & 0x3FFF;
|
||||||
if(Config.HiddenBlocks.contains(blockId))
|
if(Config.HiddenBlocks.contains(blockId))
|
||||||
blockId = Config.ObfuscateWith;
|
blockId = Config.ObfuscateWith;
|
||||||
@ -183,9 +184,7 @@ public class TechHider_15 {
|
|||||||
}
|
}
|
||||||
numChunkSections--;
|
numChunkSections--;
|
||||||
}
|
}
|
||||||
if(data.length - i != 0)
|
buffer.writeBytes(data, i, data.length - i); // MC appends a 0 byte at the end if there is a full chunk, idk why
|
||||||
Bukkit.getLogger().log(Level.WARNING, "There should be no more data. i: " + i + " data.length: " + data.length + " data[i]:" + data[i]);
|
|
||||||
buffer.writeBytes(data, i, data.length - i);
|
|
||||||
|
|
||||||
if(changed){
|
if(changed){
|
||||||
data = new byte[buffer.readableBytes()];
|
data = new byte[buffer.readableBytes()];
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren