diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/techhider/TechHider.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/techhider/TechHider.java index 7583de12..48068779 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/techhider/TechHider.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/techhider/TechHider.java @@ -11,6 +11,7 @@ import java.util.function.ToDoubleFunction; import java.util.function.ToIntFunction; import it.unimi.dsi.fastutil.ints.IntList; +import net.minecraft.server.packs.repository.Pack; import net.minecraft.world.level.block.entity.BlockEntityType; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; @@ -377,11 +378,11 @@ public abstract class TechHider { // --- Container packets --- // 7.1.19 Set Container Content - processors.put(ClientboundContainerSetContentPacket.class, tossPacket); + processors.put(ClientboundContainerSetContentPacket.class, buildContainerPacketProcessor(ClientboundContainerSetContentPacket::containerId)); // 7.1.20 Set Container Property - processors.put(ClientboundContainerSetDataPacket.class, tossPacket); + processors.put(ClientboundContainerSetDataPacket.class, buildContainerPacketProcessor(ClientboundContainerSetDataPacket::getContainerId)); // 7.1.21 Set Container Slot - processors.put(ClientboundContainerSetSlotPacket.class, tossPacket); + processors.put(ClientboundContainerSetSlotPacket.class, buildContainerPacketProcessor(ClientboundContainerSetSlotPacket::getContainerId)); // --- Others --- // 7.1.37 Explosion: position, affected blocks, and knockback can reveal @@ -618,11 +619,25 @@ public abstract class TechHider { } private final ChunkHider chunkHider = new ChunkHider(); - private ClientboundLevelChunkWithLightPacket processChunkWithLight(Player p, ClientboundLevelChunkWithLightPacket packet) { return chunkHider.processLevelChunkWithLightPacket(p, blockEntitiesToHide, this::isPlayerPrivilegedToAccessBlockPos, blockToObfuscateTo, blockIdsToObfuscate, packet); } + private Packet processContainerPacket(Player player, int containerId, Packet packet) { + if(isPlayerPrivilegedToAccessContainer(player, containerId)) { + return packet; + } else { + return null; + } + } + private > BiFunction, Packet> buildContainerPacketProcessor(ToIntFunction containerIdExtractor) { + return (p, rawPacket) -> { + TTargetPacket packet = (TTargetPacket) rawPacket; + + return processContainerPacket(p, containerIdExtractor.applyAsInt(packet), packet); + }; + } + public abstract boolean isPlayerPrivilegedToAccessPosition(Player p, int blockX, int blockY, int blockZ); public abstract boolean isPlayerPrivilegedToAccessBlock(Player p, int blockX, int blockY, int blockZ, Block block); public abstract boolean isPlayerPrivilegedToAccessEntity(Player p, int entityId);