mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-19 03:39:17 +00:00
Use chunk util method that exists instead of own thing
This commit is contained in:
2 files changed
+5
-9
No files matched your search
@@ -24,17 +24,17 @@ public final class VanillaPacketDispatcher {
|
||||
public static void dispatchTEToNearbyPlayers(TileEntity tile) {
|
||||
if(tile.getWorld() instanceof WorldServer) {
|
||||
WorldServer ws = ((WorldServer) tile.getWorld());
|
||||
PlayerChunkMapEntry chunk = ws.getPlayerChunkMap().getEntry(tile.getPos().getX() >> 4, tile.getPos().getZ() >> 4);
|
||||
SPacketUpdateTileEntity packet = tile.getUpdatePacket();
|
||||
|
||||
if(chunk == null)
|
||||
if(packet == null)
|
||||
return;
|
||||
|
||||
for (EntityPlayer player : ws.playerEntities) {
|
||||
EntityPlayerMP playerMP = ((EntityPlayerMP) player);
|
||||
|
||||
if (playerMP.getDistanceSq(tile.getPos()) < 64 * 64
|
||||
&& chunk.containsPlayer(playerMP)) {
|
||||
playerMP.connection.sendPacket(tile.getUpdatePacket());
|
||||
&& ws.getPlayerChunkMap().isPlayerWatchingChunk(playerMP, tile.getPos().getX() >> 4, tile.getPos().getZ() >> 4)) {
|
||||
playerMP.connection.sendPacket(packet);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,16 +26,12 @@ public final class PacketHandler {
|
||||
public static void sendToNearby(World world, BlockPos pos, IMessage toSend) {
|
||||
if(world instanceof WorldServer) {
|
||||
WorldServer ws = ((WorldServer) world);
|
||||
PlayerChunkMapEntry chunk = ws.getPlayerChunkMap().getEntry(pos.getX() >> 4, pos.getZ() >> 4);
|
||||
|
||||
if(chunk == null)
|
||||
return;
|
||||
|
||||
for (EntityPlayer player : ws.playerEntities) {
|
||||
EntityPlayerMP playerMP = ((EntityPlayerMP) player);
|
||||
|
||||
if (playerMP.getDistanceSq(pos) < 64 * 64
|
||||
&& chunk.containsPlayer(playerMP)) {
|
||||
&& ws.getPlayerChunkMap().isPlayerWatchingChunk(playerMP, pos.getX() >> 4, pos.getZ() >> 4)) {
|
||||
HANDLER.sendTo(toSend, playerMP);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user