Merge pull request #6 from psxlover/Fixes

SendToPlayers only on specified world instead of all worlds.
This commit is contained in:
SirSengir 2012-05-20 07:33:16 -07:00
commit 3c17b73551
8 changed files with 19 additions and 23 deletions

View file

@ -81,7 +81,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

@ -24,7 +24,6 @@ import net.minecraft.src.Packet;
import net.minecraft.src.StringTranslate;
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 {
@ -51,20 +50,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