From 6ea0d5979ad0607034fb72590c8489a948443952 Mon Sep 17 00:00:00 2001 From: psxlover Date: Sun, 20 May 2012 14:34:23 +0300 Subject: [PATCH 1/2] Fixed weird bug where sendtoplayers would send to the players on all worlds instead of only the one where the block calling sendtoplayer is. --- .../src/buildcraft/core/CoreProxy.java | 2 +- .../src/buildcraft/core/CoreProxy.java | 19 ++++++++----------- .../src/buildcraft/core/TileBuildCraft.java | 4 ++-- .../buildcraft/factory/TileAssemblyTable.java | 2 +- .../transport/PipeLogicDiamond.java | 6 +++--- .../transport/PipeTransportItems.java | 2 +- .../transport/PipeTransportPower.java | 2 +- .../buildcraft/transport/TileGenericPipe.java | 4 ++-- 8 files changed, 19 insertions(+), 22 deletions(-) diff --git a/buildcraft_client/net/minecraft/src/buildcraft/core/CoreProxy.java b/buildcraft_client/net/minecraft/src/buildcraft/core/CoreProxy.java index 2920cfe6..25e6be71 100644 --- a/buildcraft_client/net/minecraft/src/buildcraft/core/CoreProxy.java +++ b/buildcraft_client/net/minecraft/src/buildcraft/core/CoreProxy.java @@ -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) { diff --git a/buildcraft_server/net/minecraft/src/buildcraft/core/CoreProxy.java b/buildcraft_server/net/minecraft/src/buildcraft/core/CoreProxy.java index c692e85f..6addfa93 100644 --- a/buildcraft_server/net/minecraft/src/buildcraft/core/CoreProxy.java +++ b/buildcraft_server/net/minecraft/src/buildcraft/core/CoreProxy.java @@ -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); + } } } diff --git a/common/net/minecraft/src/buildcraft/core/TileBuildCraft.java b/common/net/minecraft/src/buildcraft/core/TileBuildCraft.java index 84e9c02c..beef7a48 100644 --- a/common/net/minecraft/src/buildcraft/core/TileBuildCraft.java +++ b/common/net/minecraft/src/buildcraft/core/TileBuildCraft.java @@ -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 diff --git a/common/net/minecraft/src/buildcraft/factory/TileAssemblyTable.java b/common/net/minecraft/src/buildcraft/factory/TileAssemblyTable.java index 42a9a2a7..544380fa 100644 --- a/common/net/minecraft/src/buildcraft/factory/TileAssemblyTable.java +++ b/common/net/minecraft/src/buildcraft/factory/TileAssemblyTable.java @@ -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); } diff --git a/common/net/minecraft/src/buildcraft/transport/PipeLogicDiamond.java b/common/net/minecraft/src/buildcraft/transport/PipeLogicDiamond.java index 388d8f21..2fb14ec0 100644 --- a/common/net/minecraft/src/buildcraft/transport/PipeLogicDiamond.java +++ b/common/net/minecraft/src/buildcraft/transport/PipeLogicDiamond.java @@ -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); } diff --git a/common/net/minecraft/src/buildcraft/transport/PipeTransportItems.java b/common/net/minecraft/src/buildcraft/transport/PipeTransportItems.java index e69817aa..a9fb4d52 100644 --- a/common/net/minecraft/src/buildcraft/transport/PipeTransportItems.java +++ b/common/net/minecraft/src/buildcraft/transport/PipeTransportItems.java @@ -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) { diff --git a/common/net/minecraft/src/buildcraft/transport/PipeTransportPower.java b/common/net/minecraft/src/buildcraft/transport/PipeTransportPower.java index 6b881af4..1f841f42 100644 --- a/common/net/minecraft/src/buildcraft/transport/PipeTransportPower.java +++ b/common/net/minecraft/src/buildcraft/transport/PipeTransportPower.java @@ -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); } diff --git a/common/net/minecraft/src/buildcraft/transport/TileGenericPipe.java b/common/net/minecraft/src/buildcraft/transport/TileGenericPipe.java index 29275482..e1908e2b 100644 --- a/common/net/minecraft/src/buildcraft/transport/TileGenericPipe.java +++ b/common/net/minecraft/src/buildcraft/transport/TileGenericPipe.java @@ -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 From 0111cd7528f8cbfe583ac74ed490d10f8a007035 Mon Sep 17 00:00:00 2001 From: psxlover Date: Sun, 20 May 2012 14:37:52 +0300 Subject: [PATCH 2/2] Forgot to remove an import --- .../net/minecraft/src/buildcraft/core/CoreProxy.java | 1 - 1 file changed, 1 deletion(-) diff --git a/buildcraft_server/net/minecraft/src/buildcraft/core/CoreProxy.java b/buildcraft_server/net/minecraft/src/buildcraft/core/CoreProxy.java index 6addfa93..5f717a6f 100644 --- a/buildcraft_server/net/minecraft/src/buildcraft/core/CoreProxy.java +++ b/buildcraft_server/net/minecraft/src/buildcraft/core/CoreProxy.java @@ -22,7 +22,6 @@ import net.minecraft.src.ModLoader; import net.minecraft.src.Packet; import net.minecraft.src.World; import net.minecraft.src.buildcraft.core.network.BuildCraftPacket; -import net.minecraft.src.forge.DimensionManager; import net.minecraft.src.forge.NetworkMod; public class CoreProxy {