From 1fd5e498e8aefaacfe098853a59b554af3cf0d82 Mon Sep 17 00:00:00 2001 From: "Aidan C. Brady" Date: Thu, 7 Aug 2014 21:33:17 -0400 Subject: [PATCH 1/2] Major packet improvements - trying to get on the good side of server owners. More to come. Instead of sending to all players in a dimension or within a defined range, packets will now only be sent to players who have the chunk loaded that the packet is being sent from on the server. --- src/main/java/mekanism/api/Range4D.java | 35 ++++++++++++++++--- .../api/transmitters/DynamicNetwork.java | 18 +++------- src/main/java/mekanism/common/Mekanism.java | 6 ++-- .../java/mekanism/common/PacketHandler.java | 18 ++++++++++ .../common/item/ItemConfigurator.java | 6 ++-- .../multipart/PartDiversionTransporter.java | 3 +- .../multipart/PartLogisticalTransporter.java | 14 ++++---- .../common/multipart/PartTransmitter.java | 5 +-- .../network/PacketConfigurationUpdate.java | 3 +- .../network/PacketPortableTeleport.java | 3 +- .../common/tile/TileEntityBasicBlock.java | 5 +-- .../common/tile/TileEntityBoundingBlock.java | 3 +- .../common/tile/TileEntityElectricPump.java | 5 +-- .../tile/TileEntityElectrolyticSeparator.java | 5 +-- .../common/tile/TileEntityEnergyCube.java | 3 +- .../tile/TileEntityLogisticalSorter.java | 3 +- .../common/tile/TileEntityPortableTank.java | 5 +-- .../tile/TileEntitySalinationController.java | 5 +-- .../common/tile/TileEntityTeleporter.java | 6 ++-- .../client/gui/GuiSolarGenerator.java | 2 +- 20 files changed, 99 insertions(+), 54 deletions(-) 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 d15e7025c..5dba0994b 100644 --- a/src/main/java/mekanism/common/Mekanism.java +++ b/src/main/java/mekanism/common/Mekanism.java @@ -1424,7 +1424,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) {} } @@ -1432,7 +1432,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) {} } @@ -1440,7 +1440,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 bbb5f0079..be3565a37 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; @@ -336,4 +338,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/item/ItemConfigurator.java b/src/main/java/mekanism/common/item/ItemConfigurator.java index 2d6cf23b1..ec229704a 100644 --- a/src/main/java/mekanism/common/item/ItemConfigurator.java +++ b/src/main/java/mekanism/common/item/ItemConfigurator.java @@ -7,6 +7,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; @@ -22,11 +23,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 { @@ -101,7 +101,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/multipart/PartTransmitter.java b/src/main/java/mekanism/common/multipart/PartTransmitter.java index bbbec3063..20e4aa8f9 100644 --- a/src/main/java/mekanism/common/multipart/PartTransmitter.java +++ b/src/main/java/mekanism/common/multipart/PartTransmitter.java @@ -5,6 +5,7 @@ import java.util.Set; import mekanism.api.Coord4D; import mekanism.api.IConfigurable; +import mekanism.api.Range4D; import mekanism.api.transmitters.DynamicNetwork; import mekanism.api.transmitters.IGridTransmitter; import mekanism.api.transmitters.TransmissionType; @@ -191,7 +192,7 @@ public abstract class PartTransmitter> extends Pa if(!world().isRemote) { - Mekanism.packetHandler.sendToDimension(new TransmitterUpdateMessage(PacketType.UPDATE, Coord4D.get(tile())), world().provider.dimensionId); + Mekanism.packetHandler.sendToReceivers(new TransmitterUpdateMessage(PacketType.UPDATE, Coord4D.get(tile())), new Range4D(Coord4D.get(tile()))); } } @@ -202,7 +203,7 @@ public abstract class PartTransmitter> extends Pa if(!world().isRemote) { - Mekanism.packetHandler.sendToDimension(new TransmitterUpdateMessage(PacketType.UPDATE, Coord4D.get(tile())), world().provider.dimensionId); + Mekanism.packetHandler.sendToReceivers(new TransmitterUpdateMessage(PacketType.UPDATE, Coord4D.get(tile())), new Range4D(Coord4D.get(tile()))); } } 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= Mekanism.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 fac5b03e2..ad9a13a7e 100644 --- a/src/main/java/mekanism/common/tile/TileEntityElectrolyticSeparator.java +++ b/src/main/java/mekanism/common/tile/TileEntityElectrolyticSeparator.java @@ -6,6 +6,7 @@ import java.util.ArrayList; import mekanism.api.ChemicalPair; import mekanism.api.Coord4D; +import mekanism.api.Range4D; import mekanism.api.gas.Gas; import mekanism.api.gas.GasRegistry; import mekanism.api.gas.GasStack; @@ -161,7 +162,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))); } } } @@ -187,7 +188,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 32cfe4cf9..edd69606a 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/TileEntityLogisticalSorter.java b/src/main/java/mekanism/common/tile/TileEntityLogisticalSorter.java index 36353828d..a8282a1ef 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))); } } diff --git a/src/main/java/mekanism/common/tile/TileEntityPortableTank.java b/src/main/java/mekanism/common/tile/TileEntityPortableTank.java index ce01feeb7..98b3f75eb 100644 --- a/src/main/java/mekanism/common/tile/TileEntityPortableTank.java +++ b/src/main/java/mekanism/common/tile/TileEntityPortableTank.java @@ -6,14 +6,15 @@ import java.util.ArrayList; import mekanism.api.Coord4D; import mekanism.api.IConfigurable; +import mekanism.api.Range4D; import mekanism.api.gas.IGasItem; import mekanism.common.IActiveState; import mekanism.common.IFluidContainerManager; import mekanism.common.ISustainedTank; import mekanism.common.Mekanism; import mekanism.common.network.PacketTileEntity.TileEntityMessage; -import mekanism.common.util.FluidContainerUtils.ContainerEditMode; import mekanism.common.util.FluidContainerUtils; +import mekanism.common.util.FluidContainerUtils.ContainerEditMode; import mekanism.common.util.InventoryUtils; import mekanism.common.util.MekanismUtils; import net.minecraft.entity.player.EntityPlayer; @@ -130,7 +131,7 @@ public class TileEntityPortableTank extends TileEntityContainerBlock implements if(needsPacket) { - Mekanism.packetHandler.sendToAllAround(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), Coord4D.get(this).getTargetPoint(50)); + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); } } } diff --git a/src/main/java/mekanism/common/tile/TileEntitySalinationController.java b/src/main/java/mekanism/common/tile/TileEntitySalinationController.java index 09f801a66..05dd14c2c 100644 --- a/src/main/java/mekanism/common/tile/TileEntitySalinationController.java +++ b/src/main/java/mekanism/common/tile/TileEntitySalinationController.java @@ -9,6 +9,7 @@ import java.util.Set; import mekanism.api.Coord4D; import mekanism.api.IConfigurable; import mekanism.api.ISalinationSolar; +import mekanism.api.Range4D; import mekanism.common.Mekanism; import mekanism.common.network.PacketTileEntity.TileEntityMessage; import mekanism.common.tank.TankUpdateProtocol; @@ -114,7 +115,7 @@ public class TileEntitySalinationController extends TileEntitySalinationTank imp { 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(); } } @@ -150,7 +151,7 @@ public class TileEntitySalinationController extends TileEntitySalinationTank imp 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/TileEntityTeleporter.java b/src/main/java/mekanism/common/tile/TileEntityTeleporter.java index 1a113a34a..ea4fab190 100644 --- a/src/main/java/mekanism/common/tile/TileEntityTeleporter.java +++ b/src/main/java/mekanism/common/tile/TileEntityTeleporter.java @@ -10,8 +10,8 @@ import java.util.Set; import mekanism.api.Coord4D; import mekanism.api.EnumColor; +import mekanism.api.Range4D; import mekanism.common.Mekanism; -import mekanism.common.PacketHandler; import mekanism.common.Teleporter; import mekanism.common.block.BlockMachine.MachineType; import mekanism.common.network.PacketPortalFX.PortalFXMessage; @@ -113,7 +113,7 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe if(shouldRender != prevShouldRender) { - Mekanism.packetHandler.sendToAllAround(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), Coord4D.get(this).getTargetPoint(40D)); + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); } prevShouldRender = shouldRender; @@ -282,7 +282,7 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe for(Coord4D coords : Mekanism.teleporters.get(code)) { - Mekanism.packetHandler.sendToAllAround(new PortalFXMessage(coords), coords.getTargetPoint(40D)); + Mekanism.packetHandler.sendToReceivers(new PortalFXMessage(coords), new Range4D(coords)); } setEnergy(getEnergy() - calculateEnergyCost(entity, closestCoords)); diff --git a/src/main/java/mekanism/generators/client/gui/GuiSolarGenerator.java b/src/main/java/mekanism/generators/client/gui/GuiSolarGenerator.java index 50aee3b70..cdf477136 100644 --- a/src/main/java/mekanism/generators/client/gui/GuiSolarGenerator.java +++ b/src/main/java/mekanism/generators/client/gui/GuiSolarGenerator.java @@ -39,7 +39,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"); } From 12ad58b1f96fc5caf5490536d9be1f6949ba5c6f Mon Sep 17 00:00:00 2001 From: "Aidan C. Brady" Date: Thu, 7 Aug 2014 22:48:35 -0400 Subject: [PATCH 2/2] Turns out I was sending a ton of packets to the entire player list on the server when it wasn't actually necessary at all, switched to new sendToReceivers() method --- src/main/java/mekanism/common/block/BlockBasic.java | 4 ++-- .../java/mekanism/common/item/ItemBlockEnergyCube.java | 4 ++-- .../mekanism/common/tile/TileEntityBasicMachine.java | 7 +++---- src/main/java/mekanism/common/tile/TileEntityBin.java | 10 +++++----- .../mekanism/common/tile/TileEntityBoundingBlock.java | 2 +- .../java/mekanism/common/tile/TileEntityChargepad.java | 3 ++- .../common/tile/TileEntityChemicalCrystallizer.java | 5 +++-- .../tile/TileEntityChemicalDissolutionChamber.java | 5 +++-- .../common/tile/TileEntityChemicalInfuser.java | 5 +++-- .../common/tile/TileEntityChemicalOxidizer.java | 5 +++-- .../mekanism/common/tile/TileEntityChemicalWasher.java | 5 +++-- .../mekanism/common/tile/TileEntityDigitalMiner.java | 3 ++- .../mekanism/common/tile/TileEntityDynamicTank.java | 9 +++++---- .../java/mekanism/common/tile/TileEntityFactory.java | 6 +++--- .../common/tile/TileEntityLogisticalSorter.java | 2 +- .../common/tile/TileEntityMetallurgicInfuser.java | 6 +++--- .../mekanism/common/tile/TileEntityPortableTank.java | 2 +- .../common/tile/TileEntityRotaryCondensentrator.java | 5 +++-- .../common/tile/TileEntitySeismicVibrator.java | 5 +++-- .../generators/common/tile/TileEntityGenerator.java | 6 +++--- 20 files changed, 54 insertions(+), 45 deletions(-) diff --git a/src/main/java/mekanism/common/block/BlockBasic.java b/src/main/java/mekanism/common/block/BlockBasic.java index fdb6bb1d3..50109498c 100644 --- a/src/main/java/mekanism/common/block/BlockBasic.java +++ b/src/main/java/mekanism/common/block/BlockBasic.java @@ -5,6 +5,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; @@ -31,7 +32,6 @@ import net.minecraft.entity.EnumCreatureType; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; @@ -422,7 +422,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 6d582bb90..93e3a7446 100644 --- a/src/main/java/mekanism/common/item/ItemBlockEnergyCube.java +++ b/src/main/java/mekanism/common/item/ItemBlockEnergyCube.java @@ -8,6 +8,7 @@ import java.util.List; import mekanism.api.Coord4D; import mekanism.api.EnumColor; +import mekanism.api.Range4D; import mekanism.api.energy.IEnergizedItem; import mekanism.common.IEnergyCube; import mekanism.common.ISustainedInventory; @@ -31,7 +32,6 @@ import net.minecraftforge.common.util.Constants.NBT; import org.lwjgl.input.Keyboard; import cofh.api.energy.IEnergyContainerItem; - import cpw.mods.fml.common.Optional.Interface; import cpw.mods.fml.common.Optional.InterfaceList; import cpw.mods.fml.common.Optional.Method; @@ -99,7 +99,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/tile/TileEntityBasicMachine.java b/src/main/java/mekanism/common/tile/TileEntityBasicMachine.java index 4de433c32..285ab9095 100644 --- a/src/main/java/mekanism/common/tile/TileEntityBasicMachine.java +++ b/src/main/java/mekanism/common/tile/TileEntityBasicMachine.java @@ -5,7 +5,7 @@ import io.netty.buffer.ByteBuf; import java.util.ArrayList; import mekanism.api.Coord4D; -import mekanism.client.gui.GuiProgress.ProgressBar; +import mekanism.api.Range4D; import mekanism.client.sound.IHasSound; import mekanism.common.IActiveState; import mekanism.common.IEjector; @@ -23,7 +23,6 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ResourceLocation; import cpw.mods.fml.common.Optional.Interface; import cpw.mods.fml.common.Optional.Method; - import dan200.computercraft.api.peripheral.IComputerAccess; import dan200.computercraft.api.peripheral.IPeripheral; @@ -117,7 +116,7 @@ public abstract class TileEntityBasicMachine 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))); } } } @@ -232,7 +231,7 @@ public abstract class TileEntityBasicMachine 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/TileEntityBin.java b/src/main/java/mekanism/common/tile/TileEntityBin.java index a756a064b..42b343847 100644 --- a/src/main/java/mekanism/common/tile/TileEntityBin.java +++ b/src/main/java/mekanism/common/tile/TileEntityBin.java @@ -6,6 +6,8 @@ import java.util.ArrayList; import mekanism.api.Coord4D; import mekanism.api.IConfigurable; +import mekanism.api.Range4D; +import mekanism.api.StackUtils; import mekanism.common.IActiveState; import mekanism.common.ILogisticalTransporter; import mekanism.common.Mekanism; @@ -15,18 +17,16 @@ import mekanism.common.network.PacketTileEntity.TileEntityMessage; import mekanism.common.transporter.TransporterManager; import mekanism.common.util.InventoryUtils; import mekanism.common.util.MekanismUtils; -import mekanism.api.StackUtils; import mekanism.common.util.TransporterUtils; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.ISidedInventory; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; -import cpw.mods.fml.common.Optional.Interface; import powercrystals.minefactoryreloaded.api.IDeepStorageUnit; +import cpw.mods.fml.common.Optional.Interface; @Interface(iface = "powercrystals.minefactoryreloaded.api.IDeepStorageUnit", modid = "MineFactoryReloaded") public class TileEntityBin extends TileEntityBasicBlock implements ISidedInventory, IActiveState, IDeepStorageUnit, IConfigurable @@ -377,7 +377,7 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento if(!worldObj.isRemote) { MekanismUtils.saveChunk(this); - 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))); prevCount = getItemCount(); sortStacks(); } @@ -489,7 +489,7 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento 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))); clientActive = active; } diff --git a/src/main/java/mekanism/common/tile/TileEntityBoundingBlock.java b/src/main/java/mekanism/common/tile/TileEntityBoundingBlock.java index 70f175d3b..787d07cce 100644 --- a/src/main/java/mekanism/common/tile/TileEntityBoundingBlock.java +++ b/src/main/java/mekanism/common/tile/TileEntityBoundingBlock.java @@ -30,7 +30,7 @@ public class TileEntityBoundingBlock extends TileEntity implements ITileNetwork mainY = y; mainZ = z; - 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))); } } diff --git a/src/main/java/mekanism/common/tile/TileEntityChargepad.java b/src/main/java/mekanism/common/tile/TileEntityChargepad.java index 1c62163ab..7fafb8a04 100644 --- a/src/main/java/mekanism/common/tile/TileEntityChargepad.java +++ b/src/main/java/mekanism/common/tile/TileEntityChargepad.java @@ -10,6 +10,7 @@ import java.util.List; import java.util.Random; import mekanism.api.Coord4D; +import mekanism.api.Range4D; import mekanism.api.energy.EnergizedItemManager; import mekanism.api.energy.IEnergizedItem; import mekanism.client.sound.IHasSound; @@ -170,7 +171,7 @@ public class TileEntityChargepad extends TileEntityElectricBlock implements IAct if(prevActive != 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))); } prevActive = active; diff --git a/src/main/java/mekanism/common/tile/TileEntityChemicalCrystallizer.java b/src/main/java/mekanism/common/tile/TileEntityChemicalCrystallizer.java index 2b519c891..c3631c64a 100644 --- a/src/main/java/mekanism/common/tile/TileEntityChemicalCrystallizer.java +++ b/src/main/java/mekanism/common/tile/TileEntityChemicalCrystallizer.java @@ -6,6 +6,7 @@ import java.util.ArrayList; import mekanism.api.Coord4D; import mekanism.api.EnumColor; +import mekanism.api.Range4D; import mekanism.api.gas.Gas; import mekanism.api.gas.GasRegistry; import mekanism.api.gas.GasStack; @@ -118,7 +119,7 @@ public class TileEntityChemicalCrystallizer extends TileEntityElectricBlock impl 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))); } } @@ -341,7 +342,7 @@ public class TileEntityChemicalCrystallizer extends TileEntityElectricBlock impl 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/TileEntityChemicalDissolutionChamber.java b/src/main/java/mekanism/common/tile/TileEntityChemicalDissolutionChamber.java index 05cb253b2..acd0af5e7 100644 --- a/src/main/java/mekanism/common/tile/TileEntityChemicalDissolutionChamber.java +++ b/src/main/java/mekanism/common/tile/TileEntityChemicalDissolutionChamber.java @@ -5,6 +5,7 @@ import io.netty.buffer.ByteBuf; import java.util.ArrayList; import mekanism.api.Coord4D; +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 TileEntityChemicalDissolutionChamber extends TileEntityElectricBloc 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))); } } @@ -350,7 +351,7 @@ public class TileEntityChemicalDissolutionChamber extends TileEntityElectricBloc 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/TileEntityChemicalInfuser.java b/src/main/java/mekanism/common/tile/TileEntityChemicalInfuser.java index c28dc2d8d..75a4442bc 100644 --- a/src/main/java/mekanism/common/tile/TileEntityChemicalInfuser.java +++ b/src/main/java/mekanism/common/tile/TileEntityChemicalInfuser.java @@ -5,6 +5,7 @@ import io.netty.buffer.ByteBuf; import java.util.ArrayList; import mekanism.api.Coord4D; +import mekanism.api.Range4D; import mekanism.api.gas.Gas; import mekanism.api.gas.GasRegistry; import mekanism.api.gas.GasStack; @@ -87,7 +88,7 @@ public class TileEntityChemicalInfuser 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))); } } @@ -335,7 +336,7 @@ public class TileEntityChemicalInfuser 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/common/tile/TileEntityChemicalOxidizer.java b/src/main/java/mekanism/common/tile/TileEntityChemicalOxidizer.java index 720de13bf..ce522d48c 100644 --- a/src/main/java/mekanism/common/tile/TileEntityChemicalOxidizer.java +++ b/src/main/java/mekanism/common/tile/TileEntityChemicalOxidizer.java @@ -5,6 +5,7 @@ import io.netty.buffer.ByteBuf; import java.util.ArrayList; import mekanism.api.Coord4D; +import mekanism.api.Range4D; import mekanism.api.gas.GasRegistry; import mekanism.api.gas.GasStack; import mekanism.api.gas.GasTank; @@ -90,7 +91,7 @@ public class TileEntityChemicalOxidizer extends TileEntityElectricBlock implemen 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))); } } @@ -305,7 +306,7 @@ public class TileEntityChemicalOxidizer extends TileEntityElectricBlock implemen 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/TileEntityChemicalWasher.java b/src/main/java/mekanism/common/tile/TileEntityChemicalWasher.java index 10dae7238..9e0936471 100644 --- a/src/main/java/mekanism/common/tile/TileEntityChemicalWasher.java +++ b/src/main/java/mekanism/common/tile/TileEntityChemicalWasher.java @@ -5,6 +5,7 @@ import io.netty.buffer.ByteBuf; import java.util.ArrayList; import mekanism.api.Coord4D; +import mekanism.api.Range4D; import mekanism.api.gas.Gas; import mekanism.api.gas.GasRegistry; import mekanism.api.gas.GasStack; @@ -100,7 +101,7 @@ public class TileEntityChemicalWasher extends TileEntityElectricBlock implements 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))); } } @@ -404,7 +405,7 @@ public class TileEntityChemicalWasher extends TileEntityElectricBlock 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/TileEntityDigitalMiner.java b/src/main/java/mekanism/common/tile/TileEntityDigitalMiner.java index f1d449534..ab213d999 100644 --- a/src/main/java/mekanism/common/tile/TileEntityDigitalMiner.java +++ b/src/main/java/mekanism/common/tile/TileEntityDigitalMiner.java @@ -10,6 +10,7 @@ import java.util.List; import java.util.Set; import mekanism.api.Coord4D; +import mekanism.api.Range4D; import mekanism.common.HashList; import mekanism.common.IActiveState; import mekanism.common.IAdvancedBoundingBlock; @@ -969,7 +970,7 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I 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))); clientActive = active; } diff --git a/src/main/java/mekanism/common/tile/TileEntityDynamicTank.java b/src/main/java/mekanism/common/tile/TileEntityDynamicTank.java index c89906ad8..ad5fc2dd7 100644 --- a/src/main/java/mekanism/common/tile/TileEntityDynamicTank.java +++ b/src/main/java/mekanism/common/tile/TileEntityDynamicTank.java @@ -7,6 +7,7 @@ import java.util.HashMap; import java.util.Map; import mekanism.api.Coord4D; +import mekanism.api.Range4D; import mekanism.common.IFluidContainerManager; import mekanism.common.Mekanism; import mekanism.common.network.PacketTileEntity.TileEntityMessage; @@ -178,7 +179,7 @@ public class TileEntityDynamicTank extends TileEntityContainerBlock implements I } } - 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))); } prevStructure = structure != null; @@ -291,7 +292,7 @@ public class TileEntityDynamicTank extends TileEntityContainerBlock implements I structure.fluidStored = null; } - 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))); } } } @@ -352,7 +353,7 @@ public class TileEntityDynamicTank extends TileEntityContainerBlock implements I markDirty(); } - 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))); } } } @@ -496,7 +497,7 @@ public class TileEntityDynamicTank extends TileEntityContainerBlock implements I if(tileEntity != null && tileEntity.isRendering) { - Mekanism.packetHandler.sendToAll(new TileEntityMessage(Coord4D.get(tileEntity), tileEntity.getNetworkedData(new ArrayList()))); + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); } } } diff --git a/src/main/java/mekanism/common/tile/TileEntityFactory.java b/src/main/java/mekanism/common/tile/TileEntityFactory.java index 4e8bbb0c8..8f21966ce 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.gas.Gas; import mekanism.api.gas.GasStack; import mekanism.api.gas.GasTank; @@ -39,7 +40,6 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; import cpw.mods.fml.common.Optional.Interface; import cpw.mods.fml.common.Optional.Method; - import dan200.computercraft.api.lua.ILuaContext; import dan200.computercraft.api.peripheral.IComputerAccess; import dan200.computercraft.api.peripheral.IPeripheral; @@ -156,7 +156,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))); } } @@ -780,7 +780,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 a8282a1ef..f5c1c47af 100644 --- a/src/main/java/mekanism/common/tile/TileEntityLogisticalSorter.java +++ b/src/main/java/mekanism/common/tile/TileEntityLogisticalSorter.java @@ -518,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 ad8344d57..df95eed8c 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.infuse.InfuseObject; import mekanism.api.infuse.InfuseRegistry; import mekanism.api.infuse.InfuseType; @@ -33,7 +34,6 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import cpw.mods.fml.common.Optional.Interface; import cpw.mods.fml.common.Optional.Method; - import dan200.computercraft.api.lua.ILuaContext; import dan200.computercraft.api.peripheral.IComputerAccess; import dan200.computercraft.api.peripheral.IPeripheral; @@ -127,7 +127,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))); } } @@ -514,7 +514,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 98b3f75eb..c024b561d 100644 --- a/src/main/java/mekanism/common/tile/TileEntityPortableTank.java +++ b/src/main/java/mekanism/common/tile/TileEntityPortableTank.java @@ -447,7 +447,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 2449b4036..16f0779b4 100644 --- a/src/main/java/mekanism/common/tile/TileEntityRotaryCondensentrator.java +++ b/src/main/java/mekanism/common/tile/TileEntityRotaryCondensentrator.java @@ -5,6 +5,7 @@ import io.netty.buffer.ByteBuf; import java.util.ArrayList; import mekanism.api.Coord4D; +import mekanism.api.Range4D; import mekanism.api.gas.Gas; import mekanism.api.gas.GasRegistry; import mekanism.api.gas.GasStack; @@ -93,7 +94,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))); } } @@ -447,7 +448,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/TileEntitySeismicVibrator.java b/src/main/java/mekanism/common/tile/TileEntitySeismicVibrator.java index 6fb13fd9f..d666b8a11 100644 --- a/src/main/java/mekanism/common/tile/TileEntitySeismicVibrator.java +++ b/src/main/java/mekanism/common/tile/TileEntitySeismicVibrator.java @@ -6,6 +6,7 @@ import java.util.ArrayList; import java.util.EnumSet; import mekanism.api.Coord4D; +import mekanism.api.Range4D; import mekanism.common.IActiveState; import mekanism.common.IRedstoneControl; import mekanism.common.Mekanism; @@ -61,7 +62,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))); } } @@ -146,7 +147,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/common/tile/TileEntityGenerator.java b/src/main/java/mekanism/generators/common/tile/TileEntityGenerator.java index ced442567..671093120 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.client.sound.IHasSound; import mekanism.common.IActiveState; import mekanism.common.IRedstoneControl; @@ -17,7 +18,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; @@ -92,7 +92,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))); } } @@ -151,7 +151,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 = Mekanism.UPDATE_DELAY; clientActive = active;