SteamWar/FightSystem
Archiviert
13
1

Simplified 1.12-Techhider

Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Lixfel 2020-05-19 09:42:49 +02:00
Ursprung ab4852c717
Commit c7a48f36f2
3 geänderte Dateien mit 28 neuen und 40 gelöschten Zeilen

Datei anzeigen

@ -6,19 +6,20 @@ import com.comphenix.protocol.events.PacketAdapter;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.events.PacketEvent;
import com.comphenix.protocol.reflect.StructureModifier;
import com.comphenix.protocol.wrappers.nbt.NbtBase;
import com.comphenix.protocol.wrappers.nbt.NbtCompound;
import com.comphenix.protocol.wrappers.nbt.NbtFactory;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.IFightSystem;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.UnpooledByteBufAllocator;
import net.minecraft.server.v1_12_R1.PacketPlayOutMapChunk;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_12_R1.CraftChunk;
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import static de.steamwar.fightsystem.utils.ITechHider.bypass;
@ -50,19 +51,18 @@ class TechHider_12 {
packet = packet.shallowClone();
e.setPacket(packet);
StructureModifier<List> list = packet.getSpecificModifier(List.class);
List nmsTags = list.read(0);
StructureModifier<List<NbtBase<?>>> list = packet.getListNbtModifier();
List<NbtBase<?>> nmsTags = list.read(0);
boolean changed = false;
List newNmsTags = new ArrayList(nmsTags.size());
for(Object nmsTag : nmsTags){
NbtCompound nbt = NbtFactory.fromNMSCompound(nmsTag);
if(Config.HiddenBlockEntities.contains(nbt.getString("id")))
for(int i = nmsTags.size() - 1; i >= 0; i--){
NbtCompound nbt = (NbtCompound)nmsTags.get(i);
if(Config.HiddenBlockEntities.contains(nbt.getString("id"))){
nmsTags.remove(i);
changed = true;
else
newNmsTags.add(nmsTag);
}
}
if(changed)
list.write(0, newNmsTags);
list.write(0, nmsTags);
changed = false;
StructureModifier<byte[]> byteArray = packet.getByteArrays();
@ -73,48 +73,34 @@ class TechHider_12 {
while(i < data.length){
byte bitsPerBlock = data[i++];
buffer.writeByte(bitsPerBlock);
if(bitsPerBlock < 4)
bitsPerBlock = 4;
else if(bitsPerBlock > 8){
bitsPerBlock = 13;
buffer.writeByte(data[++i]);
}
if(bitsPerBlock != 13){
int paletteLength = ITechHider.readVarInt(data, i);
int paletteLengthLength = ITechHider.readVarIntLength(data, i);
buffer.writeBytes(data, i, paletteLengthLength);
i += paletteLengthLength;
List<Integer> palette = new ArrayList<>(paletteLength);
for(int actPaletteId = 0; actPaletteId < paletteLength; actPaletteId++){
palette.add(ITechHider.readVarInt(data, i));
i += ITechHider.readVarIntLength(data, i);
}
int replacement = 0;
for(int entry : palette){
int blockId = entry >> 4;
if(Config.HiddenBlocks.contains(blockId)){
while(palette.contains((++replacement) << 4));
entry = replacement << 4;
for(int actPaletteId = 0; actPaletteId < paletteLength; actPaletteId++){
int entry = ITechHider.readVarInt(data, i);
i += ITechHider.readVarIntLength(data, i);
if(Config.HiddenBlocks.contains(entry >> 4)){
entry = obfuscateShift4;
changed = true;
}
buffer.writeBytes(ITechHider.writeVarInt(entry));
}
int dataArrayLength = ITechHider.readVarInt(data, i);
int dataArrayLengthLength = ITechHider.readVarIntLength(data, i);
buffer.writeBytes(data, i, dataArrayLength * 8 + dataArrayLengthLength);
i += dataArrayLengthLength;
i += dataArrayLength * 8;
}else{
int dataArrayLength = ITechHider.readVarInt(data, i);
int dataArrayLengthLength = ITechHider.readVarIntLength(data, i);
buffer.writeBytes(data, i, dataArrayLength*8 + dataArrayLengthLength);
i += dataArrayLengthLength;
i += dataArrayLength * 8;
buffer.writeByte(data[++i]); //Empty palette
Bukkit.getLogger().log(Level.SEVERE, "Full chunk 1.12 occured");
}
int dataArrayLength = ITechHider.readVarInt(data, i);
int dataArrayLengthLength = ITechHider.readVarIntLength(data, i);
buffer.writeBytes(data, i, dataArrayLength*8 + dataArrayLengthLength);
i += dataArrayLengthLength;
i += dataArrayLength * 8;
buffer.writeBytes(data, i, 4096);
i += 4096; //Skylight (Not in Nether/End!!!) 2048 + Blocklight 2048
}

Datei anzeigen

@ -103,6 +103,7 @@ public class Config {
public static final List<String> ForbiddenItems;
//tech hider parameter
public static final boolean TechhiderActive;
public static final Set<Integer> HiddenBlocks;
public static final Set<String> HiddenBlockTags;
public static final Set<String> HiddenBlockEntities;
@ -208,6 +209,7 @@ public class Config {
HiddenBlockEntities = Collections.unmodifiableSet(new HashSet<>(config.getStringList("Techhider.HiddenBlockEntities")));
ObfuscateWith = config.getInt("Techhider.ObfuscateWith");
ObfuscateWithTag = config.getString("Techhider.ObfuscateWithTag");
TechhiderActive = config.getBoolean("Techhider.Active");
if(schemsizeX < 0){
SchemsizeX = -schemsizeX;

Datei anzeigen

@ -236,6 +236,6 @@ public class TechHider {
}
private static boolean disabled(){
return Config.OnlyPublicSchematics || Config.test();
return Config.OnlyPublicSchematics || Config.test() || !Config.TechhiderActive;
}
}