Techhider 2
Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Ursprung
d86376c22b
Commit
ff6182fad4
@ -92,7 +92,7 @@ public class TechHider_15 {
|
||||
if(bitsPerBlock < 4)
|
||||
bitsPerBlock = 4;
|
||||
else if(bitsPerBlock > 8){
|
||||
Bukkit.getLogger().log(Level.WARNING, "Full chunk! bitsPerBlock: " + bitsPerBlock + " numChunkSections: " + numChunkSections);
|
||||
Bukkit.getLogger().log(Level.WARNING, "Full chunk! bitsPerBlock: " + bitsPerBlock + " numChunkSections: " + numChunkSections + " x: " + chunkX*16 + "-" + (chunkX+1)*16 + " z: " + chunkZ*16 + "-" + (chunkZ+1)*16);
|
||||
bitsPerBlock = 14;
|
||||
}
|
||||
|
||||
@ -126,67 +126,46 @@ public class TechHider_15 {
|
||||
i += dataArrayLengthLength;
|
||||
|
||||
int arrayEnd = dataArrayLength * 8 + i;
|
||||
System.out.println("i:" + i + " dataArrayLength: " + dataArrayLength + " arrayEnd:" + arrayEnd + " data.length:" + data.length);
|
||||
int bitsOver = 0;
|
||||
int lastBits = 0;
|
||||
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;
|
||||
int currentPos = 64 + bitsOver;
|
||||
long values = (long)data[i] << 56 | (long)data[i+1] << 48 | (long)data[i+2] << 40 | (long)data[i+3] << 32 | data[i+4] << 24 | data[i+5] << 16 | data[i+6] << 8 | data[i+7];
|
||||
long result = 0;
|
||||
|
||||
//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];
|
||||
do{
|
||||
currentPos -= 14;
|
||||
int blockId = (int)(values >> currentPos) & 0x3FFF;
|
||||
if(currentPos > 64-14){
|
||||
blockId <<= bitsOver;
|
||||
blockId |= lastBits;
|
||||
}
|
||||
if(Config.HiddenBlocks.contains(blockId))
|
||||
blockId = Config.ObfuscateWith;
|
||||
result <<= 14;
|
||||
result |= blockId;
|
||||
}while(currentPos >= 14);
|
||||
|
||||
//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;
|
||||
bitsOver = currentPos;
|
||||
lastBits = (int)values;
|
||||
|
||||
if(currentPos > 0){
|
||||
values |= data[i+15] << bitsOver | data[i+14] << (bitsOver + 8);
|
||||
if(Config.HiddenBlocks.contains((int)values & 0x3FFF))
|
||||
values = Config.ObfuscateWith;
|
||||
result <<= currentPos;
|
||||
result |= (values & (65536 >> (16-currentPos)));
|
||||
}
|
||||
|
||||
//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;
|
||||
buffer.writeLong(result);
|
||||
i += 8;
|
||||
}
|
||||
}
|
||||
numChunkSections--;
|
||||
}
|
||||
if(data.length - i != 0)
|
||||
Bukkit.getLogger().log(Level.WARNING, "There should be no more data. i: " + i + " data.length: " + data.length);
|
||||
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){
|
||||
|
@ -117,8 +117,8 @@ public class FightSystem extends JavaPlugin {
|
||||
throw new SecurityException(fightState.name());
|
||||
setFightState(FightState.POST_SCHEM_SETUP);
|
||||
|
||||
TechHider.start();
|
||||
if(!Config.test()){
|
||||
TechHider.start();
|
||||
Fight.getBlueTeam().pasteSchematic();
|
||||
Fight.getRedTeam().pasteSchematic();
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren