forked from SteamWar/SteamWar
another fix
This commit is contained in:
@@ -179,7 +179,7 @@ public class ChunkHider {
|
||||
out.readBytes(data);
|
||||
|
||||
List<Object> blockEntities = chunkBlockEntitiesDataField.get(chunkData);
|
||||
List<Object> filteredBlockEntities = filterBlockEntities(player, blockEntities);
|
||||
List<Object> filteredBlockEntities = filterBlockEntities(player, blockEntities, chunkX, chunkZ);
|
||||
|
||||
return buildNewChunkPacket(packet, data, filteredBlockEntities);
|
||||
|
||||
@@ -256,18 +256,24 @@ public class ChunkHider {
|
||||
private static final Reflection.Field<Integer> packedXZField = Reflection.getField(blockEntitiyInfoClass, int.class, 0);
|
||||
private static final Reflection.Field<Integer> yField = Reflection.getField(blockEntitiyInfoClass, int.class, 1);
|
||||
|
||||
private List<Object> filterBlockEntities(Player player, List<Object> blockEntities) {
|
||||
private List<Object> filterBlockEntities(Player player, List<Object> blockEntities, int chunkX, int chunkZ) {
|
||||
int fourBitBitmask = 0b0000_1111;
|
||||
|
||||
return blockEntities.stream()
|
||||
.filter((blockEntityInfo) -> {
|
||||
BlockEntityType<?> type = blockEntityInfoTypeField.get(blockEntityInfo);
|
||||
|
||||
int packedXZ = packedXZField.get(blockEntityInfo);
|
||||
|
||||
int y = yField.get(blockEntityInfo);
|
||||
int x = SectionPos.sectionRelativeX((short) packedXZ);
|
||||
int z = SectionPos.sectionRelativeZ((short) packedXZ);
|
||||
int localX = (packedXZ >> 4) & fourBitBitmask;
|
||||
int localZ = packedXZ & fourBitBitmask;
|
||||
|
||||
return accessPrivilegeProvider.isPlayerPrivilegedToAccessPosition(player, x, y, z) && accessPrivilegeProvider.isPlayerPrivilegedToAccessBlockEntity(player, x, y, z, type);
|
||||
int worldX = (chunkX * SECTION_SPAN_SIZE) + localX;
|
||||
int worldZ = (chunkZ * SECTION_SPAN_SIZE) + localZ;
|
||||
|
||||
int worldY = yField.get(blockEntityInfo);
|
||||
|
||||
return accessPrivilegeProvider.isPlayerPrivilegedToAccessPosition(player, worldX, worldY, worldZ) && accessPrivilegeProvider.isPlayerPrivilegedToAccessBlockEntity(player, worldX, worldY, worldZ, type);
|
||||
}).toList();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user