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/"); 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 sendToPlayer(EntityPlayer entityplayer, BuildCraftPacket packet) {}
public static void sendToServer(Packet 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.StringTranslate;
import net.minecraft.src.World; import net.minecraft.src.World;
import net.minecraft.src.buildcraft.core.network.BuildCraftPacket; import net.minecraft.src.buildcraft.core.network.BuildCraftPacket;
import net.minecraft.src.forge.DimensionManager;
import net.minecraft.src.forge.NetworkMod; import net.minecraft.src.forge.NetworkMod;
public class CoreProxy { public class CoreProxy {
@ -51,20 +50,17 @@ public class CoreProxy {
return new File("BuildCraft.cfg"); 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) { int z, int maxDistance, NetworkMod mod) {
if (packet != null) { if (packet != null) {
World[] worlds = DimensionManager.getWorlds(); for (int j = 0; j < w.playerEntities.size(); j++) {
for (int i = 0; i < worlds.length; i++) EntityPlayerMP player = (EntityPlayerMP)w.playerEntities.get(j);
for (int j = 0; j < worlds[i].playerEntities
.size(); j++) {
EntityPlayerMP player = (EntityPlayerMP)worlds[i].playerEntities.get(j);
if (Math.abs(player.posX - x) <= maxDistance if (Math.abs(player.posX - x) <= maxDistance
&& Math.abs(player.posY - y) <= maxDistance && Math.abs(player.posY - y) <= maxDistance
&& Math.abs(player.posZ - z) <= maxDistance) && Math.abs(player.posZ - z) <= maxDistance)
player.playerNetServerHandler.sendPacket(packet); player.playerNetServerHandler.sendPacket(packet);
} }
} }
} }

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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