forked from SteamWar/SteamWar
Make Techhider more robust
This commit is contained in:
@@ -27,6 +27,9 @@ import net.minecraft.util.SimpleBitStorage;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
@@ -45,10 +48,15 @@ public class ChunkHider {
|
||||
|
||||
private final int blockIdUsedForHiding;
|
||||
private final AccessPrivilegeProvider accessPrivilegeProvider;
|
||||
private final int worldMinHeight;
|
||||
private final int worldMaxHeight;
|
||||
|
||||
public ChunkHider(Block blockUsedForObfuscation, AccessPrivilegeProvider accessPrivilegeProvider) {
|
||||
blockIdUsedForHiding = Block.BLOCK_STATE_REGISTRY.getId(blockUsedForObfuscation.defaultBlockState());
|
||||
this.accessPrivilegeProvider = accessPrivilegeProvider;
|
||||
World world = Bukkit.getWorlds().getFirst();
|
||||
worldMinHeight = world.getMinHeight();
|
||||
worldMaxHeight = world.getMaxHeight();
|
||||
}
|
||||
|
||||
private int getLongsRequiredToEncodeEntries(int bitsPerEntry, int entryCount) {
|
||||
@@ -77,9 +85,6 @@ public class ChunkHider {
|
||||
ByteBuf in = Unpooled.wrappedBuffer(chunkData.getReadBuffer());
|
||||
ByteBuf out = Unpooled.buffer(in.readableBytes() + 64);
|
||||
|
||||
int worldMinHeight = player.getWorld().getMinHeight();
|
||||
int worldMaxHeight = player.getWorld().getMaxHeight();
|
||||
|
||||
for (int yOffset = worldMinHeight; yOffset < worldMaxHeight; yOffset += SECTION_SPAN_SIZE) {
|
||||
short blockCount = in.readShort();
|
||||
|
||||
|
||||
@@ -202,7 +202,7 @@ public class TechHider {
|
||||
// 7.1.3 Entity Animation: entity id based signal, keep blocked until entity visibility is modeled.
|
||||
processors.put(ClientboundAnimatePacket.class, this.buildEntityPacketProcessor(ClientboundAnimatePacket::getId));
|
||||
// 7.1.35 Entity Event: entity id based signal.
|
||||
processors.put(ClientboundEntityEventPacket.class, this.buildEntityPacketProcessor(ClientboundEntityEventPacket::getEventId));
|
||||
processors.put(ClientboundEntityEventPacket.class, this.buildEntityPacketProcessor((ClientboundEntityEventPacket p) -> p.entityId));
|
||||
// 7.1.36 Teleport Entity: entity id and absolute position.
|
||||
processors.put(ClientboundTeleportEntityPacket.class, this.buildEntityPacketProcessor(ClientboundTeleportEntityPacket::id));
|
||||
// 7.1.42 Hurt Animation: entity id based signal.
|
||||
|
||||
Reference in New Issue
Block a user