(Untested) Implementation of a full chunk tech hider
Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Ursprung
c7bc8163ed
Commit
d86376c22b
@ -13,11 +13,13 @@ import de.steamwar.fightsystem.IFightSystem;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.UnpooledByteBufAllocator;
|
||||
import net.minecraft.server.v1_15_R1.PacketPlayOutMapChunk;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.CraftChunk;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import static de.steamwar.fightsystem.utils.ITechHider.bypass;
|
||||
|
||||
@ -90,8 +92,8 @@ public class TechHider_15 {
|
||||
if(bitsPerBlock < 4)
|
||||
bitsPerBlock = 4;
|
||||
else if(bitsPerBlock > 8){
|
||||
Bukkit.getLogger().log(Level.WARNING, "Full chunk! bitsPerBlock: " + bitsPerBlock + " numChunkSections: " + numChunkSections);
|
||||
bitsPerBlock = 14;
|
||||
buffer.writeByte(data[++i]);
|
||||
}
|
||||
|
||||
if(bitsPerBlock != 14){
|
||||
@ -120,12 +122,71 @@ public class TechHider_15 {
|
||||
}else{
|
||||
int dataArrayLength = ITechHider.readVarInt(data, i);
|
||||
int dataArrayLengthLength = ITechHider.readVarIntLength(data, i);
|
||||
buffer.writeBytes(data, i, dataArrayLength*8 + dataArrayLengthLength);
|
||||
buffer.writeBytes(data, i, dataArrayLengthLength);
|
||||
i += dataArrayLengthLength;
|
||||
i += dataArrayLength * 8;
|
||||
|
||||
int arrayEnd = dataArrayLength * 8 + i;
|
||||
while(i < arrayEnd){
|
||||
/*Every blockid is encoded in 14 bits (state id).
|
||||
* 4 blockIds (in the 16*16*16 Chunk) are encoded in 7 bytes:
|
||||
*
|
||||
* 1 2 3 4 5 6 7 8
|
||||
* ________________
|
||||
* | 0 |
|
||||
* | 0 | 1 |
|
||||
* | 1 |
|
||||
* | 1 | 2 |
|
||||
* | 2 |
|
||||
* | 2 | 3 |
|
||||
* | 3 |
|
||||
* ----------------
|
||||
* */
|
||||
boolean lineChanged = false;
|
||||
|
||||
//Extract block ids
|
||||
int blockId0 = (data[i] << 6) | ((data[i+1] & 0xFC) >> 2);
|
||||
int blockId1 = ((data[i+1] & 0x03) << 12) | (data[i+2] << 4) | ((data[i+3] & 0xF0) >> 4);
|
||||
int blockId2 = ((data[i+3] & 0x0F) << 10) | (data[i+4] << 2) | ((data[i+5] & 0xC0) >> 6);
|
||||
int blockId3 = ((data[i+5] & 0x3F) << 8) | data[i+6];
|
||||
|
||||
//Check for hidden blocks
|
||||
if(Config.HiddenBlocks.contains(blockId0)){
|
||||
lineChanged = true;
|
||||
blockId0 = Config.ObfuscateWith;
|
||||
}
|
||||
if(Config.HiddenBlocks.contains(blockId1)){
|
||||
lineChanged = true;
|
||||
blockId1 = Config.ObfuscateWith;
|
||||
}
|
||||
if(Config.HiddenBlocks.contains(blockId2)){
|
||||
lineChanged = true;
|
||||
blockId2 = Config.ObfuscateWith;
|
||||
}
|
||||
if(Config.HiddenBlocks.contains(blockId3)){
|
||||
lineChanged = true;
|
||||
blockId3 = Config.ObfuscateWith;
|
||||
}
|
||||
|
||||
//Write bytes out
|
||||
if(lineChanged){
|
||||
changed = true;
|
||||
buffer.writeByte(blockId0 >> 6);
|
||||
buffer.writeByte(((blockId0 << 2) & 0xFC) | blockId1 >> 12);
|
||||
buffer.writeByte((blockId1 >> 4) & 0xFF);
|
||||
buffer.writeByte(((blockId1 << 4) & 0xF0) | blockId2 >> 10);
|
||||
buffer.writeByte((blockId2 >> 2) & 0xFF);
|
||||
buffer.writeByte(((blockId2 << 6) & 0xC0) | blockId3 >> 8);
|
||||
buffer.writeByte(blockId3 & 0xFF);
|
||||
}else{
|
||||
buffer.writeBytes(data, i, 7);
|
||||
}
|
||||
i += 7;
|
||||
}
|
||||
}
|
||||
numChunkSections--;
|
||||
}
|
||||
if(data.length - i != 0)
|
||||
Bukkit.getLogger().log(Level.WARNING, "There should be no more data. i: " + i + " data.length: " + data.length);
|
||||
buffer.writeBytes(data, i, data.length - i);
|
||||
|
||||
if(changed){
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren