Dieser Commit ist enthalten in:
Ursprung
6becd70986
Commit
22359819f2
@ -28,8 +28,6 @@ import java.util.Set;
|
||||
|
||||
public class BlockIds14 implements BlockIds {
|
||||
|
||||
private static final Class<?> iRegistry = Reflection.getClass("{nms.core}.IRegistry");
|
||||
private static final Class<?> minecraftKey = Reflection.getClass("{nms.resources}.MinecraftKey");
|
||||
private static final Class<?> blockStateList = Reflection.getClass("{nms.world.level.block.state}.BlockStateList");
|
||||
private static final Class<?> fluidTypeFlowing = Reflection.getClass("{nms.world.level.material}.FluidTypeFlowing");
|
||||
private static final Class<?> fluid = Reflection.getClass("{nms.world.level.material}.Fluid");
|
||||
@ -63,11 +61,9 @@ public class BlockIds14 implements BlockIds {
|
||||
return ids;
|
||||
}
|
||||
|
||||
private static final Reflection.ConstructorInvoker newMinecraftkey = Reflection.getConstructor(minecraftKey, String.class);
|
||||
private static final Reflection.MethodInvoker registryBlocksGet = Reflection.getTypedMethod(iRegistry, null, Object.class, minecraftKey);
|
||||
private static final Object blockRegistry = Reflection.getField(iRegistry, Reflection.getClass("{nms.core}.RegistryBlocks"), 0, TechHider.block).get(null);
|
||||
private static final Reflection.MethodInvoker getBlock = Reflection.getTypedMethod(TechHider.craftMagicNumbers, "getBlock", TechHider.block, Material.class);
|
||||
private Object getBlock(Material material) {
|
||||
return registryBlocksGet.invoke(blockRegistry, newMinecraftkey.invoke(material.name().toLowerCase()));
|
||||
return getBlock.invoke(null, material);
|
||||
}
|
||||
|
||||
private static final Reflection.MethodInvoker getCombinedId = Reflection.getTypedMethod(TechHider.block, null, int.class, TechHider.iBlockData);
|
||||
|
@ -40,7 +40,7 @@ public class ProtocolWrapper14 extends ProtocolWrapper8 {
|
||||
if(bypass.bypass(p, ProtocolUtils.posToChunk(TechHider.blockPositionX.get(pos)), ProtocolUtils.posToChunk(TechHider.blockPositionZ.get(pos))))
|
||||
return packet;
|
||||
|
||||
if(ProtocolWrapper.impl.iBlockDataHidden(obfuscate, blockBreakBlockData.get(packet))){
|
||||
if(TechHider.iBlockDataHidden(obfuscate, blockBreakBlockData.get(packet))){
|
||||
packet = blockBreakCloner.apply(packet);
|
||||
blockBreakBlockData.set(packet, obfuscationTarget);
|
||||
}
|
||||
|
@ -20,9 +20,9 @@
|
||||
package de.steamwar.techhider;
|
||||
|
||||
import com.comphenix.tinyprotocol.Reflection;
|
||||
import net.minecraft.core.IRegistry;
|
||||
import net.minecraft.core.SectionPosition;
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutBlockBreak;
|
||||
import net.minecraft.world.level.block.entity.TileEntitySign;
|
||||
import net.minecraft.world.level.block.entity.TileEntityTypes;
|
||||
import net.minecraft.world.level.block.state.IBlockData;
|
||||
import org.bukkit.Material;
|
||||
@ -45,15 +45,16 @@ public class ProtocolWrapper18 implements ProtocolWrapper {
|
||||
return packet;
|
||||
|
||||
packet = TechHider.multiBlockChangeCloner.apply(packet);
|
||||
multiBlockChangeBlocks.set(packet, iBlockDataArrayCloner.apply(multiBlockChangeBlocks.get(packet), block -> ProtocolWrapper.impl.iBlockDataHidden(obfuscate, block) ? obfuscationTarget : block));
|
||||
multiBlockChangeBlocks.set(packet, iBlockDataArrayCloner.apply(multiBlockChangeBlocks.get(packet), block -> TechHider.iBlockDataHidden(obfuscate, block) ? obfuscationTarget : block));
|
||||
return packet;
|
||||
};
|
||||
}
|
||||
|
||||
private static final Reflection.FieldAccessor<TileEntityTypes> tileEntityType = Reflection.getField(TechHider.tileEntityDataPacket, TileEntityTypes.class, 0);
|
||||
private static final TileEntityTypes<?> signType = Reflection.getField(TileEntityTypes.class, TileEntityTypes.class, 0, TileEntitySign.class).get(null);
|
||||
@Override
|
||||
public boolean unfilteredTileEntityDataAction(Object packet) {
|
||||
return tileEntityType.get(packet) != TileEntityTypes.h;
|
||||
return tileEntityType.get(packet) != signType;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -63,15 +64,10 @@ public class ProtocolWrapper18 implements ProtocolWrapper {
|
||||
if(bypass.bypass(p, ProtocolUtils.posToChunk(TechHider.blockPositionX.get(breakPacket.b())), ProtocolUtils.posToChunk(TechHider.blockPositionZ.get(breakPacket.b()))))
|
||||
return packet;
|
||||
|
||||
if(!ProtocolWrapper.impl.iBlockDataHidden(obfuscate, breakPacket.c()))
|
||||
if(!TechHider.iBlockDataHidden(obfuscate, breakPacket.c()))
|
||||
return packet;
|
||||
|
||||
return new PacketPlayOutBlockBreak(breakPacket.b(), (IBlockData) obfuscationTarget, breakPacket.d(), breakPacket.a());
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean iBlockDataHidden(Set<Material> obfuscate, Object iBlockData) {
|
||||
return obfuscate.contains(Material.getMaterial(IRegistry.U.b(((IBlockData) iBlockData).b()).a().toUpperCase()));
|
||||
}
|
||||
}
|
||||
|
@ -19,49 +19,16 @@
|
||||
|
||||
package de.steamwar.techhider;
|
||||
|
||||
import com.comphenix.tinyprotocol.Reflection;
|
||||
import net.minecraft.core.IRegistry;
|
||||
import net.minecraft.core.SectionPosition;
|
||||
import net.minecraft.world.level.block.entity.TileEntityTypes;
|
||||
import net.minecraft.world.level.block.state.IBlockData;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.UnaryOperator;
|
||||
|
||||
public class ProtocolWrapper19 implements ProtocolWrapper {
|
||||
|
||||
private static final Reflection.FieldAccessor<SectionPosition> multiBlockChangeChunk = Reflection.getField(TechHider.multiBlockChangePacket, SectionPosition.class, 0);
|
||||
private static final Reflection.FieldAccessor<IBlockData[]> multiBlockChangeBlocks = Reflection.getField(TechHider.multiBlockChangePacket, IBlockData[].class, 0);
|
||||
private static final BiFunction<Object, UnaryOperator<Object>, Object> iBlockDataArrayCloner = ProtocolUtils.arrayCloneGenerator(TechHider.iBlockData);
|
||||
@Override
|
||||
public BiFunction<Player, Object, Object> multiBlockChangeGenerator(Object obfuscationTarget, Set<Material> obfuscate, TechHider.BypassEvaluator bypass) {
|
||||
return (p, packet) -> {
|
||||
Object chunkCoords = multiBlockChangeChunk.get(packet);
|
||||
if(bypass.bypass(p, TechHider.blockPositionX.get(chunkCoords), TechHider.blockPositionZ.get(chunkCoords)))
|
||||
return packet;
|
||||
|
||||
packet = TechHider.multiBlockChangeCloner.apply(packet);
|
||||
multiBlockChangeBlocks.set(packet, iBlockDataArrayCloner.apply(multiBlockChangeBlocks.get(packet), block -> ProtocolWrapper.impl.iBlockDataHidden(obfuscate, block) ? obfuscationTarget : block));
|
||||
return packet;
|
||||
};
|
||||
}
|
||||
|
||||
private static final Reflection.FieldAccessor<TileEntityTypes> tileEntityType = Reflection.getField(TechHider.tileEntityDataPacket, TileEntityTypes.class, 0);
|
||||
@Override
|
||||
public boolean unfilteredTileEntityDataAction(Object packet) {
|
||||
return tileEntityType.get(packet) != TileEntityTypes.h;
|
||||
}
|
||||
public class ProtocolWrapper19 extends ProtocolWrapper18 {
|
||||
|
||||
@Override
|
||||
public BiFunction<Player, Object, Object> blockBreakHiderGenerator(Class<?> blockBreakPacket, Object obfuscationTarget, Set<Material> obfuscate, TechHider.BypassEvaluator bypass) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean iBlockDataHidden(Set<Material> obfuscate, Object iBlockData) {
|
||||
return obfuscate.contains(Material.getMaterial(IRegistry.V.b(((IBlockData) iBlockData).b()).a().toUpperCase()));
|
||||
}
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ public class ProtocolWrapper8 implements ProtocolWrapper {
|
||||
|
||||
Object modpacket = TechHider.multiBlockChangeCloner.apply(packet);
|
||||
multiBlockChangeInfos.set(modpacket, multiBlockChangeInfoArrayCloner.apply(multiBlockChangeInfos.get(modpacket), mbci -> {
|
||||
if(ProtocolWrapper.impl.iBlockDataHidden(obfuscate, multiBlockChangeInfoBlock.get(mbci)))
|
||||
if(TechHider.iBlockDataHidden(obfuscate, multiBlockChangeInfoBlock.get(mbci)))
|
||||
return multiBlockChangeInfoConstructor.invoke(modpacket, multiBlockChangeInfoPos.get(mbci), obfuscationTarget);
|
||||
return mbci;
|
||||
}));
|
||||
@ -66,11 +66,4 @@ public class ProtocolWrapper8 implements ProtocolWrapper {
|
||||
public BiFunction<Player, Object, Object> blockBreakHiderGenerator(Class<?> blockBreakPacket, Object obfuscationTarget, Set<Material> obfuscate, TechHider.BypassEvaluator bypass) {
|
||||
return null;
|
||||
}
|
||||
|
||||
private static final Reflection.MethodInvoker getBlockByBlockData = Reflection.getTypedMethod(TechHider.iBlockData, null, TechHider.block);
|
||||
private static final Reflection.MethodInvoker getMaterialByBlock = Reflection.getTypedMethod(TechHider.craftMagicNumbers, "getMaterial", Material.class, TechHider.block);
|
||||
@Override
|
||||
public boolean iBlockDataHidden(Set<Material> obfuscate, Object iBlockData) {
|
||||
return obfuscate.contains((Material) getMaterialByBlock.invoke(null, getBlockByBlockData.invoke(iBlockData)));
|
||||
}
|
||||
}
|
||||
|
@ -36,6 +36,4 @@ public interface ProtocolWrapper {
|
||||
BiFunction<Player, Object, Object> blockBreakHiderGenerator(Class<?> blockBreakPacket, Object obfuscationTarget, Set<Material> obfuscate, TechHider.BypassEvaluator bypass);
|
||||
|
||||
BiFunction<Player, Object, Object> multiBlockChangeGenerator(Object obfuscationTarget, Set<Material> obfuscate, TechHider.BypassEvaluator bypass);
|
||||
|
||||
boolean iBlockDataHidden(Set<Material> obfuscate, Object iBlockData);
|
||||
}
|
||||
|
@ -46,6 +46,12 @@ public class TechHider {
|
||||
public static final Class<?> craftMagicNumbers = Reflection.getClass("{obc}.util.CraftMagicNumbers");
|
||||
private static final Reflection.MethodInvoker getBlockByMaterial = Reflection.getTypedMethod(craftMagicNumbers, "getBlock", block, Material.class);
|
||||
|
||||
private static final Reflection.MethodInvoker getBlockByBlockData = Reflection.getTypedMethod(iBlockData, null, block);
|
||||
private static final Reflection.MethodInvoker getMaterialByBlock = Reflection.getTypedMethod(craftMagicNumbers, "getMaterial", Material.class, block);
|
||||
public static boolean iBlockDataHidden(Set<Material> obfuscate, Object iBlockData) {
|
||||
return obfuscate.contains((Material) getMaterialByBlock.invoke(null, getBlockByBlockData.invoke(iBlockData)));
|
||||
}
|
||||
|
||||
private final Map<Class<?>, BiFunction<Player, Object, Object>> techhiders = new HashMap<>();
|
||||
private final BypassEvaluator bypass;
|
||||
private final Object obfuscationTarget;
|
||||
@ -94,7 +100,7 @@ public class TechHider {
|
||||
if(bypass.bypass(p, ProtocolUtils.posToChunk(blockPositionX.get(pos)), ProtocolUtils.posToChunk(blockPositionZ.get(pos))))
|
||||
return packet;
|
||||
|
||||
if(ProtocolWrapper.impl.iBlockDataHidden(obfuscate, blockChangeBlockData.get(packet))) {
|
||||
if(iBlockDataHidden(obfuscate, blockChangeBlockData.get(packet))) {
|
||||
packet = blockChangeCloner.apply(packet);
|
||||
blockChangeBlockData.set(packet, obfuscationTarget);
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren