diff --git a/src/main/java/mekanism/api/Range4D.java b/src/main/java/mekanism/api/Range4D.java index 0a487b2e7..a8071ddf2 100644 --- a/src/main/java/mekanism/api/Range4D.java +++ b/src/main/java/mekanism/api/Range4D.java @@ -1,6 +1,7 @@ package mekanism.api; -import net.minecraft.server.MinecraftServer; +import net.minecraft.entity.player.EntityPlayer; +import cpw.mods.fml.common.FMLCommonHandler; public class Range4D { @@ -31,15 +32,41 @@ public class Range4D yMin = 0; zMin = chunk.zCoord*16; xMax = xMin+16; + yMax = 255; + zMax = zMin+16; } - public static Range4D getLoadedChunks(MinecraftServer server) + public Range4D(Coord4D coord) { - int range = server.getConfigurationManager().getViewDistance(); + xMin = coord.xCoord; + yMin = coord.yCoord; + zMin = coord.zCoord; + xMax = coord.xCoord+1; + yMax = coord.yCoord+1; + zMax = coord.zCoord+1; + } + + public static Range4D getChunkRange(EntityPlayer player) + { + int radius = FMLCommonHandler.instance().getMinecraftServerInstance().getConfigurationManager().getViewDistance(); + return new Range4D(new Chunk3D(player)).expandChunks(radius); + } + + public Range4D expandChunks(int chunks) + { + xMin -= chunks*16; + xMax += chunks*16; + zMin -= chunks*16; + zMax += chunks*16; - return null; + return this; + } + + public boolean intersects(Range4D range) + { + return (xMax+1 - 1.E-05D > range.xMin) && (range.xMax+1 - 1.E-05D > xMin) && (yMax+1 - 1.E-05D > range.yMin) && (range.yMax+1 - 1.E-05D > yMin) && (zMax+1 - 1.E-05D > range.zMin) && (range.zMax+1 - 1.E-05D > zMin); } @Override diff --git a/src/main/java/mekanism/api/transmitters/DynamicNetwork.java b/src/main/java/mekanism/api/transmitters/DynamicNetwork.java index 3dace876c..52c7a5f1f 100644 --- a/src/main/java/mekanism/api/transmitters/DynamicNetwork.java +++ b/src/main/java/mekanism/api/transmitters/DynamicNetwork.java @@ -12,10 +12,9 @@ import java.util.Set; import mekanism.api.Coord4D; import mekanism.api.IClientTicker; -import mekanism.common.Mekanism; +import mekanism.api.Range4D; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.ForgeDirection; @@ -31,7 +30,7 @@ public abstract class DynamicNetwork> implemen private List updateQueue = new ArrayList(); - protected AxisAlignedBB packetRange = null; + protected Range4D packetRange = null; protected int ticksSinceCreate = 0; @@ -95,7 +94,7 @@ public abstract class DynamicNetwork> implemen refresh(); } - public AxisAlignedBB getPacketRange() + public Range4D getPacketRange() { if(packetRange == null) { @@ -115,7 +114,7 @@ public abstract class DynamicNetwork> implemen return transmitters.iterator().next().getTile().getWorldObj(); } - protected AxisAlignedBB genPacketRange() + protected Range4D genPacketRange() { if(getSize() == 0) { @@ -144,14 +143,7 @@ public abstract class DynamicNetwork> implemen if(coord.zCoord > maxZ) maxZ = coord.zCoord; } - minX -= 40; - minY -= 40; - minZ -= 40; - maxX += 40; - maxY += 40; - maxZ += 40; - - return AxisAlignedBB.getBoundingBox(minX, minY, minZ, maxX, maxY, maxZ); + return new Range4D(minX, minY, minZ, maxX, maxY, maxZ, getWorld().provider.dimensionId); } @Override diff --git a/src/main/java/mekanism/common/Mekanism.java b/src/main/java/mekanism/common/Mekanism.java index d507459c2..afac76deb 100644 --- a/src/main/java/mekanism/common/Mekanism.java +++ b/src/main/java/mekanism/common/Mekanism.java @@ -1136,7 +1136,7 @@ public class Mekanism public void onEnergyTransferred(EnergyTransferEvent event) { try { - packetHandler.sendToDimension(new TransmitterUpdateMessage(PacketType.ENERGY, Coord4D.get((TileEntity)event.energyNetwork.transmitters.iterator().next()), event.power), event.energyNetwork.getWorld().provider.dimensionId); + packetHandler.sendToReceivers(new TransmitterUpdateMessage(PacketType.ENERGY, Coord4D.get((TileEntity)event.energyNetwork.transmitters.iterator().next()), event.power), event.energyNetwork.getPacketRange()); } catch(Exception e) {} } @@ -1144,7 +1144,7 @@ public class Mekanism public void onGasTransferred(GasTransferEvent event) { try { - packetHandler.sendToDimension(new TransmitterUpdateMessage(PacketType.GAS, Coord4D.get((TileEntity)event.gasNetwork.transmitters.iterator().next()), event.transferType, event.didTransfer), event.gasNetwork.getWorld().provider.dimensionId); + packetHandler.sendToReceivers(new TransmitterUpdateMessage(PacketType.GAS, Coord4D.get((TileEntity)event.gasNetwork.transmitters.iterator().next()), event.transferType, event.didTransfer), event.gasNetwork.getPacketRange()); } catch(Exception e) {} } @@ -1152,7 +1152,7 @@ public class Mekanism public void onLiquidTransferred(FluidTransferEvent event) { try { - packetHandler.sendToDimension(new TransmitterUpdateMessage(PacketType.FLUID, Coord4D.get((TileEntity)event.fluidNetwork.transmitters.iterator().next()), event.fluidType, event.didTransfer), event.fluidNetwork.getWorld().provider.dimensionId); + packetHandler.sendToReceivers(new TransmitterUpdateMessage(PacketType.FLUID, Coord4D.get((TileEntity)event.fluidNetwork.transmitters.iterator().next()), event.fluidType, event.didTransfer), event.fluidNetwork.getPacketRange()); } catch(Exception e) {} } diff --git a/src/main/java/mekanism/common/PacketHandler.java b/src/main/java/mekanism/common/PacketHandler.java index fe09a01ad..4787964c8 100644 --- a/src/main/java/mekanism/common/PacketHandler.java +++ b/src/main/java/mekanism/common/PacketHandler.java @@ -5,6 +5,8 @@ import io.netty.buffer.ByteBuf; import java.util.ArrayList; import java.util.List; +import mekanism.api.Coord4D; +import mekanism.api.Range4D; import mekanism.common.network.PacketBoxBlacklist; import mekanism.common.network.PacketBoxBlacklist.BoxBlacklistMessage; import mekanism.common.network.PacketConfigSync; @@ -268,15 +270,7 @@ public class PacketHandler { return Mekanism.proxy.getPlayer(context); } - - /** - * Send this message to everyone. - * @param message - the message to send - */ - public void sendToAll(IMessage message) - { - netHandler.sendToAll(message); - } + /** * Send this message to the specified player. @@ -339,4 +333,20 @@ public class PacketHandler } } } + + public void sendToReceivers(IMessage message, Range4D range) + { + MinecraftServer server = MinecraftServer.getServer(); + + if(server != null) + { + for(EntityPlayerMP player : (List)server.getConfigurationManager().playerEntityList) + { + if(player.dimension == range.dimensionId && Range4D.getChunkRange(player).intersects(range)) + { + sendTo(message, player); + } + } + } + } } diff --git a/src/main/java/mekanism/common/block/BlockBasic.java b/src/main/java/mekanism/common/block/BlockBasic.java index 6962a165a..f5e7a1b4d 100644 --- a/src/main/java/mekanism/common/block/BlockBasic.java +++ b/src/main/java/mekanism/common/block/BlockBasic.java @@ -6,6 +6,7 @@ import java.util.List; import java.util.Random; import mekanism.api.Coord4D; +import mekanism.api.Range4D; import mekanism.client.ClientProxy; import mekanism.common.ConnectedTextureRenderer; import mekanism.common.IActiveState; @@ -423,7 +424,7 @@ public class BlockBasic extends Block if(!manageInventory(entityplayer, tileEntity)) { - Mekanism.packetHandler.sendToAll(new TileEntityMessage(Coord4D.get(tileEntity), tileEntity.getNetworkedData(new ArrayList()))); + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(tileEntity), tileEntity.getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(tileEntity))); entityplayer.openGui(Mekanism.instance, 18, world, x, y, z); } else { diff --git a/src/main/java/mekanism/common/item/ItemBlockEnergyCube.java b/src/main/java/mekanism/common/item/ItemBlockEnergyCube.java index 116eefa9e..41c0695de 100644 --- a/src/main/java/mekanism/common/item/ItemBlockEnergyCube.java +++ b/src/main/java/mekanism/common/item/ItemBlockEnergyCube.java @@ -9,11 +9,11 @@ import java.util.List; import mekanism.api.Coord4D; import mekanism.api.EnumColor; import mekanism.api.MekanismConfig.general; +import mekanism.api.Range4D; import mekanism.api.energy.IEnergizedItem; import mekanism.common.IEnergyCube; import mekanism.common.ISustainedInventory; import mekanism.common.Mekanism; -import mekanism.common.Tier; import mekanism.common.Tier.EnergyCubeTier; import mekanism.common.integration.IC2ItemManager; import mekanism.common.network.PacketTileEntity.TileEntityMessage; @@ -100,7 +100,7 @@ public class ItemBlockEnergyCube extends ItemBlock implements IEnergizedItem, IE if(!world.isRemote) { - Mekanism.packetHandler.sendToAll(new TileEntityMessage(Coord4D.get(tileEntity), tileEntity.getNetworkedData(new ArrayList()))); + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(tileEntity), tileEntity.getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(tileEntity))); } } diff --git a/src/main/java/mekanism/common/item/ItemConfigurator.java b/src/main/java/mekanism/common/item/ItemConfigurator.java index 4aa838829..c79bcf38a 100644 --- a/src/main/java/mekanism/common/item/ItemConfigurator.java +++ b/src/main/java/mekanism/common/item/ItemConfigurator.java @@ -8,6 +8,7 @@ import java.util.Random; import mekanism.api.Coord4D; import mekanism.api.EnumColor; import mekanism.api.IConfigurable; +import mekanism.api.Range4D; import mekanism.common.IInvConfiguration; import mekanism.common.Mekanism; import mekanism.common.network.PacketTileEntity.TileEntityMessage; @@ -25,11 +26,10 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ChatComponentText; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; +import buildcraft.api.tools.IToolWrench; import cpw.mods.fml.common.Optional.Interface; import cpw.mods.fml.common.Optional.Method; -import buildcraft.api.tools.IToolWrench; - @Interface(iface = "buildcraft.api.tools.IToolWrench", modid = "BuildCraftAPI|tools") public class ItemConfigurator extends ItemEnergized implements IToolWrench { @@ -105,7 +105,7 @@ public class ItemConfigurator extends ItemEnergized implements IToolWrench if(config instanceof TileEntityBasicBlock) { TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)config; - Mekanism.packetHandler.sendToAllAround(new TileEntityMessage(Coord4D.get(tileEntity), tileEntity.getNetworkedData(new ArrayList())), Coord4D.get(tileEntity).getTargetPoint(50D)); + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(tileEntity), tileEntity.getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(tileEntity))); } return true; diff --git a/src/main/java/mekanism/common/multipart/PartDiversionTransporter.java b/src/main/java/mekanism/common/multipart/PartDiversionTransporter.java index ec14f9f17..18f85190d 100644 --- a/src/main/java/mekanism/common/multipart/PartDiversionTransporter.java +++ b/src/main/java/mekanism/common/multipart/PartDiversionTransporter.java @@ -6,6 +6,7 @@ import java.util.ArrayList; import mekanism.api.Coord4D; import mekanism.api.EnumColor; +import mekanism.api.Range4D; import mekanism.common.Mekanism; import mekanism.common.network.PacketTileEntity.TileEntityMessage; import mekanism.common.transporter.TransporterStack; @@ -121,7 +122,7 @@ public class PartDiversionTransporter extends PartLogisticalTransporter refreshConnections(); tile().notifyPartChange(this); player.addChatMessage(new ChatComponentText(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " " + MekanismUtils.localize("tooltip.configurator.toggleDiverter") + ": " + EnumColor.RED + description)); - Mekanism.packetHandler.sendToAllAround(new TileEntityMessage(Coord4D.get(tile()), getNetworkedData(new ArrayList())), Coord4D.get(tile()).getTargetPoint(50D)); + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(tile()), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(tile()))); return true; } diff --git a/src/main/java/mekanism/common/multipart/PartLogisticalTransporter.java b/src/main/java/mekanism/common/multipart/PartLogisticalTransporter.java index c21753787..fd7281241 100644 --- a/src/main/java/mekanism/common/multipart/PartLogisticalTransporter.java +++ b/src/main/java/mekanism/common/multipart/PartLogisticalTransporter.java @@ -8,6 +8,7 @@ import java.util.Set; import mekanism.api.Coord4D; import mekanism.api.EnumColor; +import mekanism.api.Range4D; import mekanism.api.transmitters.TransmissionType; import mekanism.client.render.RenderPartTransmitter; import mekanism.common.HashList; @@ -37,7 +38,6 @@ import net.minecraftforge.common.util.ForgeDirection; import buildcraft.api.transport.IPipeTile; import buildcraft.api.transport.PipeWire; import codechicken.lib.vec.Vector3; - import cpw.mods.fml.common.Optional.Interface; import cpw.mods.fml.common.Optional.Method; import cpw.mods.fml.relauncher.Side; @@ -328,7 +328,7 @@ public class PartLogisticalTransporter extends PartSidedPipe implements ILogisti for(TransporterStack stack : remove) { - Mekanism.packetHandler.sendToAllAround(new TileEntityMessage(Coord4D.get(tile()), getSyncPacket(stack, true)), Coord4D.get(tile()).getTargetPoint(50D)); + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(tile()), getSyncPacket(stack, true)), new Range4D(Coord4D.get(tile()))); transit.remove(stack); MekanismUtils.saveChunk(tile()); } @@ -337,7 +337,7 @@ public class PartLogisticalTransporter extends PartSidedPipe implements ILogisti { if(transit.contains(stack)) { - Mekanism.packetHandler.sendToAllAround(new TileEntityMessage(Coord4D.get(tile()), getSyncPacket(stack, false)), Coord4D.get(tile()).getTargetPoint(50D)); + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(tile()), getSyncPacket(stack, false)), new Range4D(Coord4D.get(tile()))); } } @@ -452,7 +452,7 @@ public class PartLogisticalTransporter extends PartSidedPipe implements ILogisti { transit.add(stack); TransporterManager.add(stack); - Mekanism.packetHandler.sendToAllAround(new TileEntityMessage(Coord4D.get(tile()), getSyncPacket(stack, false)), Coord4D.get(tile()).getTargetPoint(50D)); + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(tile()), getSyncPacket(stack, false)), new Range4D(Coord4D.get(tile()))); MekanismUtils.saveChunk(tile()); } @@ -488,7 +488,7 @@ public class PartLogisticalTransporter extends PartSidedPipe implements ILogisti { transit.add(stack); TransporterManager.add(stack); - Mekanism.packetHandler.sendToAllAround(new TileEntityMessage(Coord4D.get(tile()), getSyncPacket(stack, false)), Coord4D.get(tile()).getTargetPoint(50D)); + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(tile()), getSyncPacket(stack, false)), new Range4D(Coord4D.get(tile()))); MekanismUtils.saveChunk(tile()); } @@ -503,7 +503,7 @@ public class PartLogisticalTransporter extends PartSidedPipe implements ILogisti { stack.progress = 0; transit.add(stack); - Mekanism.packetHandler.sendToAllAround(new TileEntityMessage(Coord4D.get(tile()), getSyncPacket(stack, false)), Coord4D.get(tile()).getTargetPoint(50D)); + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(tile()), getSyncPacket(stack, false)), new Range4D(Coord4D.get(tile()))); MekanismUtils.saveChunk(tile()); } @@ -693,7 +693,7 @@ public class PartLogisticalTransporter extends PartSidedPipe implements ILogisti TransporterUtils.incrementColor(this); refreshConnections(); tile().notifyPartChange(this); - Mekanism.packetHandler.sendToAllAround(new TileEntityMessage(Coord4D.get(tile()), getNetworkedData(new ArrayList())), Coord4D.get(tile()).getTargetPoint(50D)); + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(tile()), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(tile()))); player.addChatMessage(new ChatComponentText(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " " + MekanismUtils.localize("tooltip.configurator.toggleColor") + ": " + (color != null ? color.getName() : EnumColor.BLACK + MekanismUtils.localize("gui.none")))); return true; diff --git a/src/main/java/mekanism/common/network/PacketConfigurationUpdate.java b/src/main/java/mekanism/common/network/PacketConfigurationUpdate.java index 36d49364d..40e09036d 100644 --- a/src/main/java/mekanism/common/network/PacketConfigurationUpdate.java +++ b/src/main/java/mekanism/common/network/PacketConfigurationUpdate.java @@ -5,6 +5,7 @@ import io.netty.buffer.ByteBuf; import java.util.ArrayList; import mekanism.api.Coord4D; +import mekanism.api.Range4D; import mekanism.common.IInvConfiguration; import mekanism.common.ITileNetwork; import mekanism.common.Mekanism; @@ -52,7 +53,7 @@ public class PacketConfigurationUpdate implements IMessageHandler= usage.electricPumpUsage && (fluidTank.getFluid() == null || fluidTank.getFluid().amount+FluidContainerRegistry.BUCKET_VOLUME <= fluidTank.getCapacity())) { - if(suck(true)) - { - Mekanism.packetHandler.sendToAllAround(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), Coord4D.get(this).getTargetPoint(50D)); - } + suck(true); } } diff --git a/src/main/java/mekanism/common/tile/TileEntityElectrolyticSeparator.java b/src/main/java/mekanism/common/tile/TileEntityElectrolyticSeparator.java index c033ddafc..a857e719b 100644 --- a/src/main/java/mekanism/common/tile/TileEntityElectrolyticSeparator.java +++ b/src/main/java/mekanism/common/tile/TileEntityElectrolyticSeparator.java @@ -7,6 +7,7 @@ import java.util.ArrayList; import mekanism.api.MekanismConfig.general; import mekanism.api.recipe.ChemicalPair; import mekanism.api.Coord4D; +import mekanism.api.Range4D; import mekanism.api.gas.Gas; import mekanism.api.gas.GasRegistry; import mekanism.api.gas.GasStack; @@ -162,7 +163,7 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp if(worldObj.rand.nextInt(3) == 2) { - Mekanism.packetHandler.sendToAllAround(new TileEntityMessage(Coord4D.get(this), getParticlePacket(0, new ArrayList())), Coord4D.get(this).getTargetPoint(40D)); + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getParticlePacket(0, new ArrayList())), new Range4D(Coord4D.get(this))); } } } @@ -188,7 +189,7 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp if(worldObj.rand.nextInt(3) == 2) { - Mekanism.packetHandler.sendToAllAround(new TileEntityMessage(Coord4D.get(this), getParticlePacket(1, new ArrayList())), Coord4D.get(this).getTargetPoint(40D)); + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getParticlePacket(1, new ArrayList())), new Range4D(Coord4D.get(this))); } } } diff --git a/src/main/java/mekanism/common/tile/TileEntityEnergyCube.java b/src/main/java/mekanism/common/tile/TileEntityEnergyCube.java index e45fcd408..6bbe5e428 100644 --- a/src/main/java/mekanism/common/tile/TileEntityEnergyCube.java +++ b/src/main/java/mekanism/common/tile/TileEntityEnergyCube.java @@ -6,6 +6,7 @@ import java.util.ArrayList; import java.util.EnumSet; import mekanism.api.Coord4D; +import mekanism.api.Range4D; import mekanism.common.IRedstoneControl; import mekanism.common.Mekanism; import mekanism.common.PacketHandler; @@ -68,7 +69,7 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements IPe if(newScale != prevScale) { - Mekanism.packetHandler.sendToAllAround(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), Coord4D.get(this).getTargetPoint(50D)); + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); } prevScale = newScale; diff --git a/src/main/java/mekanism/common/tile/TileEntityFactory.java b/src/main/java/mekanism/common/tile/TileEntityFactory.java index a1325fc0b..3a747550c 100644 --- a/src/main/java/mekanism/common/tile/TileEntityFactory.java +++ b/src/main/java/mekanism/common/tile/TileEntityFactory.java @@ -7,6 +7,7 @@ import java.util.List; import mekanism.api.Coord4D; import mekanism.api.EnumColor; +import mekanism.api.Range4D; import mekanism.api.MekanismConfig.general; import mekanism.api.MekanismConfig.usage; import mekanism.api.gas.Gas; @@ -157,7 +158,7 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IPerip if(updateDelay == 0 && clientActive != isActive) { - Mekanism.packetHandler.sendToAll(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList()))); + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); } } @@ -784,7 +785,7 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IPerip if(clientActive != active && updateDelay == 0) { - Mekanism.packetHandler.sendToAll(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList()))); + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); updateDelay = 10; clientActive = active; diff --git a/src/main/java/mekanism/common/tile/TileEntityLogisticalSorter.java b/src/main/java/mekanism/common/tile/TileEntityLogisticalSorter.java index a5cbe6c76..e9ebe7abe 100644 --- a/src/main/java/mekanism/common/tile/TileEntityLogisticalSorter.java +++ b/src/main/java/mekanism/common/tile/TileEntityLogisticalSorter.java @@ -8,6 +8,7 @@ import java.util.EnumSet; import mekanism.api.Coord4D; import mekanism.api.EnumColor; import mekanism.api.IFilterAccess; +import mekanism.api.Range4D; import mekanism.common.HashList; import mekanism.common.IActiveState; import mekanism.common.ILogisticalTransporter; @@ -494,7 +495,7 @@ public class TileEntityLogisticalSorter extends TileEntityElectricBlock implemen { if(!worldObj.isRemote) { - Mekanism.packetHandler.sendToAllAround(new TileEntityMessage(Coord4D.get(this), getFilterPacket(new ArrayList())), Coord4D.get(this).getTargetPoint(50D)); + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getFilterPacket(new ArrayList())), new Range4D(Coord4D.get(this))); } } @@ -517,7 +518,7 @@ public class TileEntityLogisticalSorter extends TileEntityElectricBlock implemen if(clientActive != active) { - Mekanism.packetHandler.sendToAll(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList()))); + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); if(active) { diff --git a/src/main/java/mekanism/common/tile/TileEntityMetallurgicInfuser.java b/src/main/java/mekanism/common/tile/TileEntityMetallurgicInfuser.java index 78ac39326..bea62eb55 100644 --- a/src/main/java/mekanism/common/tile/TileEntityMetallurgicInfuser.java +++ b/src/main/java/mekanism/common/tile/TileEntityMetallurgicInfuser.java @@ -6,6 +6,7 @@ import java.util.ArrayList; import mekanism.api.Coord4D; import mekanism.api.EnumColor; +import mekanism.api.Range4D; import mekanism.api.MekanismConfig.general; import mekanism.api.MekanismConfig.usage; import mekanism.api.infuse.InfuseObject; @@ -129,7 +130,7 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem if(updateDelay == 0 && clientActive != isActive) { - Mekanism.packetHandler.sendToAll(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList()))); + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); } } @@ -516,7 +517,7 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem if(clientActive != active && updateDelay == 0) { - Mekanism.packetHandler.sendToAll(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList()))); + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); updateDelay = 10; clientActive = active; diff --git a/src/main/java/mekanism/common/tile/TileEntityPortableTank.java b/src/main/java/mekanism/common/tile/TileEntityPortableTank.java index 864eca402..4b4e6315f 100644 --- a/src/main/java/mekanism/common/tile/TileEntityPortableTank.java +++ b/src/main/java/mekanism/common/tile/TileEntityPortableTank.java @@ -6,6 +6,7 @@ import java.util.ArrayList; import mekanism.api.Coord4D; import mekanism.api.IConfigurable; +import mekanism.api.Range4D; import mekanism.api.MekanismConfig.general; import mekanism.api.gas.IGasItem; import mekanism.common.IActiveState; @@ -447,7 +448,7 @@ public class TileEntityPortableTank extends TileEntityContainerBlock implements if(clientActive != active && updateDelay == 0) { - Mekanism.packetHandler.sendToAll(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList()))); + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); updateDelay = 10; clientActive = active; diff --git a/src/main/java/mekanism/common/tile/TileEntityRotaryCondensentrator.java b/src/main/java/mekanism/common/tile/TileEntityRotaryCondensentrator.java index 4f31ffd72..9b12c969a 100644 --- a/src/main/java/mekanism/common/tile/TileEntityRotaryCondensentrator.java +++ b/src/main/java/mekanism/common/tile/TileEntityRotaryCondensentrator.java @@ -6,6 +6,7 @@ import java.util.ArrayList; import mekanism.api.Coord4D; import mekanism.api.MekanismConfig.usage; +import mekanism.api.Range4D; import mekanism.api.gas.Gas; import mekanism.api.gas.GasRegistry; import mekanism.api.gas.GasStack; @@ -94,7 +95,7 @@ public class TileEntityRotaryCondensentrator extends TileEntityElectricBlock imp if(updateDelay == 0 && clientActive != isActive) { - Mekanism.packetHandler.sendToAll(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList()))); + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); } } @@ -448,7 +449,7 @@ public class TileEntityRotaryCondensentrator extends TileEntityElectricBlock imp if(clientActive != active && updateDelay == 0) { - Mekanism.packetHandler.sendToAll(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList()))); + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); updateDelay = 10; clientActive = active; diff --git a/src/main/java/mekanism/common/tile/TileEntitySalinationController.java b/src/main/java/mekanism/common/tile/TileEntitySalinationController.java index b2ae76c50..33ee9f849 100644 --- a/src/main/java/mekanism/common/tile/TileEntitySalinationController.java +++ b/src/main/java/mekanism/common/tile/TileEntitySalinationController.java @@ -8,6 +8,7 @@ import java.util.Set; import mekanism.api.Coord4D; import mekanism.api.ISalinationSolar; +import mekanism.api.Range4D; import mekanism.common.Mekanism; import mekanism.common.network.PacketTileEntity.TileEntityMessage; import mekanism.common.tank.TankUpdateProtocol; @@ -111,7 +112,7 @@ public class TileEntitySalinationController extends TileEntitySalinationBlock { if(Math.abs((float)waterTank.getFluidAmount()/waterTank.getCapacity()-prevScale) > 0.01) { - Mekanism.packetHandler.sendToAllAround(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), Coord4D.get(this).getTargetPoint(50D)); + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); prevScale = (float)waterTank.getFluidAmount()/waterTank.getCapacity(); } } @@ -147,7 +148,7 @@ public class TileEntitySalinationController extends TileEntitySalinationBlock if(structured != prev) { - Mekanism.packetHandler.sendToAllAround(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), Coord4D.get(this).getTargetPoint(50D)); + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); } if(structured) diff --git a/src/main/java/mekanism/common/tile/TileEntitySeismicVibrator.java b/src/main/java/mekanism/common/tile/TileEntitySeismicVibrator.java index 751da6d4d..99b45452d 100644 --- a/src/main/java/mekanism/common/tile/TileEntitySeismicVibrator.java +++ b/src/main/java/mekanism/common/tile/TileEntitySeismicVibrator.java @@ -8,6 +8,7 @@ import java.util.EnumSet; import mekanism.api.Coord4D; import mekanism.api.MekanismConfig.general; import mekanism.api.MekanismConfig.usage; +import mekanism.api.Range4D; import mekanism.common.IActiveState; import mekanism.common.IRedstoneControl; import mekanism.common.Mekanism; @@ -63,7 +64,7 @@ public class TileEntitySeismicVibrator extends TileEntityElectricBlock implement if(updateDelay == 0 && clientActive != isActive) { - Mekanism.packetHandler.sendToAll(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList()))); + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); } } @@ -148,7 +149,7 @@ public class TileEntitySeismicVibrator extends TileEntityElectricBlock implement if(clientActive != active && updateDelay == 0) { - Mekanism.packetHandler.sendToAll(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList()))); + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); updateDelay = 10; clientActive = active; diff --git a/src/main/java/mekanism/generators/client/gui/GuiSolarGenerator.java b/src/main/java/mekanism/generators/client/gui/GuiSolarGenerator.java index 5d9426ecc..8dcb49078 100644 --- a/src/main/java/mekanism/generators/client/gui/GuiSolarGenerator.java +++ b/src/main/java/mekanism/generators/client/gui/GuiSolarGenerator.java @@ -38,7 +38,7 @@ public class GuiSolarGenerator extends GuiMekanism public List getInfo() { return ListUtils.asList( - "Producing: " + MekanismUtils.getEnergyDisplay(tileEntity.isActive ? tileEntity.GENERATION_RATE : 0) + "/t", + "Producing: " + MekanismUtils.getEnergyDisplay(tileEntity.isActive ? tileEntity.getProduction() : 0) + "/t", "Storing: " + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), "Max Output: " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxOutput()) + "/t"); } diff --git a/src/main/java/mekanism/generators/common/tile/TileEntityGenerator.java b/src/main/java/mekanism/generators/common/tile/TileEntityGenerator.java index 6f3522377..6b8b35f50 100644 --- a/src/main/java/mekanism/generators/common/tile/TileEntityGenerator.java +++ b/src/main/java/mekanism/generators/common/tile/TileEntityGenerator.java @@ -6,6 +6,7 @@ import java.util.ArrayList; import java.util.EnumSet; import mekanism.api.Coord4D; +import mekanism.api.Range4D; import mekanism.api.MekanismConfig.general; import mekanism.client.sound.IHasSound; import mekanism.common.IActiveState; @@ -18,7 +19,6 @@ import mekanism.common.util.MekanismUtils; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.AxisAlignedBB; import net.minecraftforge.common.util.ForgeDirection; - import cpw.mods.fml.common.Optional.Interface; import cpw.mods.fml.common.Optional.Method; import cpw.mods.fml.relauncher.Side; @@ -93,7 +93,7 @@ public abstract class TileEntityGenerator extends TileEntityElectricBlock implem if(updateDelay == 0 && clientActive != isActive) { clientActive = isActive; - Mekanism.packetHandler.sendToAll(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList()))); + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); } } @@ -152,7 +152,7 @@ public abstract class TileEntityGenerator extends TileEntityElectricBlock implem if(clientActive != active && updateDelay == 0) { - Mekanism.packetHandler.sendToAll(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList()))); + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); updateDelay = general.UPDATE_DELAY; clientActive = active;