Fixed weird bug where sendtoplayers would send to the players on all worlds instead of only the one where the block calling sendtoplayer is.

This commit is contained in:
psxlover 2012-05-20 14:34:23 +03:00
parent 20e5a70575
commit 6ea0d5979a
8 changed files with 19 additions and 22 deletions

View file

@ -78,7 +78,7 @@ public class CoreProxy {
return new File(Minecraft.getMinecraftDir(), "/buildcraft/");
}
public static void sendToPlayers(Packet packet, int x, int y, int z, int maxDistance, NetworkMod mod) {}
public static void sendToPlayers(Packet packet, World w, int x, int y, int z, int maxDistance, NetworkMod mod) {}
public static void sendToPlayer(EntityPlayer entityplayer, BuildCraftPacket packet) {}
public static void sendToServer(Packet packet) {

View file

@ -49,20 +49,17 @@ public class CoreProxy {
return new File("BuildCraft.cfg");
}
public static void sendToPlayers(Packet packet, int x, int y,
public static void sendToPlayers(Packet packet, World w, int x, int y,
int z, int maxDistance, NetworkMod mod) {
if (packet != null) {
World[] worlds = DimensionManager.getWorlds();
for (int i = 0; i < worlds.length; i++)
for (int j = 0; j < worlds[i].playerEntities
.size(); j++) {
EntityPlayerMP player = (EntityPlayerMP)worlds[i].playerEntities.get(j);
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);
}
if (Math.abs(player.posX - x) <= maxDistance
&& Math.abs(player.posY - y) <= maxDistance
&& Math.abs(player.posZ - z) <= maxDistance)
player.playerNetServerHandler.sendPacket(packet);
}
}
}

View file

@ -71,8 +71,8 @@ public abstract class TileBuildCraft extends TileEntity implements ISynchronized
public void sendNetworkUpdate() {
if (this instanceof ISynchronizedTile)
CoreProxy.sendToPlayers(
((ISynchronizedTile) this).getUpdatePacket(), xCoord,
yCoord, zCoord, 50, mod_BuildCraftCore.instance);
((ISynchronizedTile) this).getUpdatePacket(), worldObj,
xCoord, yCoord, zCoord, 50, mod_BuildCraftCore.instance);
}
@Override

View file

@ -370,7 +370,7 @@ public class TileAssemblyTable extends TileEntity implements IInventory, IPipeCo
packet.posX = xCoord;
packet.posY = yCoord;
packet.posZ = zCoord;
CoreProxy.sendToPlayers(packet.getPacket(),
CoreProxy.sendToPlayers(packet.getPacket(), worldObj,
(int) player.posX, (int) player.posY, (int) player.posZ, 100,
mod_BuildCraftSilicon.instance);
}

View file

@ -88,7 +88,7 @@ public class PipeLogicDiamond extends PipeLogic {
if (APIProxy.isServerSide())
for (int p = 0; p < 6; ++p)
CoreProxy.sendToPlayers(
getContentsPacket(p), xCoord,
getContentsPacket(p), worldObj, xCoord,
yCoord, zCoord, 50, mod_BuildCraftTransport.instance);
return stack;
@ -109,7 +109,7 @@ public class PipeLogicDiamond extends PipeLogic {
if (APIProxy.isServerSide())
for (int p = 0; p < 6; ++p)
CoreProxy.sendToPlayers(
getContentsPacket(p), xCoord,
getContentsPacket(p), worldObj, xCoord,
yCoord, zCoord, 50, mod_BuildCraftTransport.instance);
}
@ -119,7 +119,7 @@ public class PipeLogicDiamond extends PipeLogic {
if (APIProxy.isServerSide())
for (int p = 0; p < 6; ++p)
CoreProxy.sendToPlayers(
getContentsPacket(p), xCoord,
getContentsPacket(p), worldObj, xCoord,
yCoord, zCoord, 50, mod_BuildCraftTransport.instance);
}

View file

@ -98,7 +98,7 @@ public class PipeTransportItems extends PipeTransport {
if (APIProxy.isServerSide())
if (item.synchroTracker.markTimeIfDelay(worldObj, 6 * BuildCraftCore.updateFactor))
CoreProxy.sendToPlayers(createItemPacket(item, orientation),
xCoord, yCoord, zCoord, 50,
worldObj, xCoord, yCoord, zCoord, 50,
mod_BuildCraftTransport.instance);
if (travelingEntities.size() > BuildCraftTransport.groupItemsTrigger) {

View file

@ -159,7 +159,7 @@ public class PipeTransportPower extends PipeTransport {
if (tracker.markTimeIfDelay(worldObj, 2 * BuildCraftCore.updateFactor))
CoreProxy
.sendToPlayers(this.container.getUpdatePacket(),
xCoord, yCoord, zCoord, 40,
worldObj, xCoord, yCoord, zCoord, 40,
mod_BuildCraftCore.instance);
}

View file

@ -92,8 +92,8 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor,
public void synchronizeIfDelay (int delay) {
if (APIProxy.isServerSide())
if (networkSyncTracker.markTimeIfDelay(worldObj, delay))
CoreProxy.sendToPlayers(getUpdatePacket(), xCoord, yCoord,
zCoord, 40, mod_BuildCraftCore.instance);
CoreProxy.sendToPlayers(getUpdatePacket(), worldObj, xCoord,
yCoord, zCoord, 40, mod_BuildCraftCore.instance);
}
@Override