From 93cd7fe74e8eefc75bffd1f6c50c465527758016 Mon Sep 17 00:00:00 2001 From: psxlover Date: Sun, 20 May 2012 22:33:19 +0300 Subject: [PATCH] Used getEntitiesWithinAABB instead of getting all the players of the world for sendToPlayers. --- .../net/minecraft/src/buildcraft/core/CoreProxy.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/buildcraft_server/net/minecraft/src/buildcraft/core/CoreProxy.java b/buildcraft_server/net/minecraft/src/buildcraft/core/CoreProxy.java index 5f717a6f..44775dfe 100644 --- a/buildcraft_server/net/minecraft/src/buildcraft/core/CoreProxy.java +++ b/buildcraft_server/net/minecraft/src/buildcraft/core/CoreProxy.java @@ -10,7 +10,9 @@ package net.minecraft.src.buildcraft.core; import java.io.File; +import java.util.List; +import net.minecraft.src.AxisAlignedBB; import net.minecraft.src.Block; import net.minecraft.src.EntityItem; import net.minecraft.src.EntityPlayer; @@ -51,13 +53,9 @@ public class CoreProxy { public static void sendToPlayers(Packet packet, World w, int x, int y, int z, int maxDistance, NetworkMod mod) { if (packet != null) { - for (int j = 0; j < w.playerEntities.size(); j++) { - EntityPlayerMP player = (EntityPlayerMP)w.playerEntities.get(j); - - if (Math.abs(player.posX - x) <= maxDistance - && Math.abs(player.posY - y) <= maxDistance - && Math.abs(player.posZ - z) <= maxDistance) - player.playerNetServerHandler.sendPacket(packet); + List players = w.getEntitiesWithinAABB(EntityPlayerMP.class, AxisAlignedBB.getBoundingBoxFromPool(x - maxDistance, y - maxDistance, z - maxDistance, x + maxDistance, y + maxDistance, z + maxDistance)); + for (EntityPlayerMP player: players) { + player.playerNetServerHandler.sendPacket(packet); } } }