Reduced the range of Pipe update packets

They are only used for rendering, no need to send them to people who are
beyond the render distance.
This commit is contained in:
CovertJaguar 2012-11-23 20:50:31 -08:00
parent 1817ae6936
commit ecc3f98024
5 changed files with 23 additions and 23 deletions

View file

@ -19,6 +19,7 @@ public class DefaultProps {
public static int WORLD_HEIGHT = 256;
public static final String NET_CHANNEL_NAME = "BC";
public static int NETWORK_UPDATE_RANGE = 128;
public static int PIPE_CONTENTS_RENDER_DIST = 24;
public static String TEXTURE_PATH_GUI = "/gfx/buildcraft/gui";
public static String TEXTURE_PATH_BLOCKS = "/gfx/buildcraft/blocks";

View file

@ -440,7 +440,7 @@ public class PipeTransportItems extends PipeTransport {
private void sendItemPacket(EntityData data) {
int dimension = worldObj.provider.dimensionId;
PacketDispatcher.sendPacketToAllAround(xCoord, yCoord, zCoord, DefaultProps.NETWORK_UPDATE_RANGE, dimension, createItemPacket(data));
PacketDispatcher.sendPacketToAllAround(xCoord, yCoord, zCoord, DefaultProps.PIPE_CONTENTS_RENDER_DIST, dimension, createItemPacket(data));
}
public int getNumberOfItems() {
@ -479,7 +479,7 @@ public class PipeTransportItems extends PipeTransport {
public void groupEntities() {
EntityData[] entities = travelingEntities.values().toArray(new EntityData[travelingEntities.size()]);
TreeSet<Integer> toRemove = new TreeSet<Integer>();
TreeSet<Integer> remove = new TreeSet<Integer>();
for (int i = 0; i < entities.length; ++i) {
EntityData data1 = entities[i];
@ -489,17 +489,17 @@ public class PipeTransportItems extends PipeTransport {
if (data1.item.getItemStack().itemID == data2.item.getItemStack().itemID
&& data1.item.getItemStack().getItemDamage() == data2.item.getItemStack().getItemDamage()
&& !toRemove.contains(data1.item.getEntityId()) && !toRemove.contains(data2.item.getEntityId())
&& !remove.contains(data1.item.getEntityId()) && !remove.contains(data2.item.getEntityId())
&& !data1.item.hasContributions() && !data2.item.hasContributions()
&& data1.item.getItemStack().stackSize + data2.item.getItemStack().stackSize < data1.item.getItemStack().getMaxStackSize()) {
data1.item.getItemStack().stackSize += data2.item.getItemStack().stackSize;
toRemove.add(data2.item.getEntityId());
remove.add(data2.item.getEntityId());
}
}
}
for (Integer i : toRemove) {
for (Integer i : remove) {
travelingEntities.get(i).item.remove();
travelingEntities.remove(i);
}
@ -509,8 +509,9 @@ public class PipeTransportItems extends PipeTransport {
public void dropContents() {
groupEntities();
for (EntityData data : travelingEntities.values())
for (EntityData data : travelingEntities.values()) {
Utils.dropItems(worldObj, data.item.getItemStack(), xCoord, yCoord, zCoord);
}
travelingEntities.clear();
}

View file

@ -222,7 +222,7 @@ public class PipeTransportLiquids extends PipeTransport implements ITankContaine
PacketLiquidUpdate packet = new PacketLiquidUpdate(xCoord, yCoord, zCoord);
packet.displayLiquid = this.renderCache;
CoreProxy.proxy.sendToPlayers(packet.getPacket(), worldObj, xCoord, yCoord, zCoord,
DefaultProps.NETWORK_UPDATE_RANGE);
DefaultProps.PIPE_CONTENTS_RENDER_DIST);
}
//this.container.synchronizeIfDelay(1 * BuildCraftCore.updateFactor);

View file

@ -168,7 +168,7 @@ public class PipeTransportPower extends PipeTransport {
PacketPowerUpdate packet = new PacketPowerUpdate(xCoord, yCoord, zCoord);
packet.displayPower = displayPower;
CoreProxy.proxy.sendToPlayers(packet.getPacket(), worldObj, xCoord, yCoord, zCoord,
DefaultProps.NETWORK_UPDATE_RANGE);
DefaultProps.PIPE_CONTENTS_RENDER_DIST);
}
}

View file

@ -9,20 +9,8 @@
package buildcraft.transport;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.LinkedList;
import cpw.mods.fml.common.Side;
import cpw.mods.fml.common.asm.SideOnly;
import buildcraft.BuildCraftCore;
import buildcraft.BuildCraftTransport;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.liquids.ILiquidTank;
import net.minecraftforge.liquids.ITankContainer;
import net.minecraftforge.liquids.LiquidStack;
import buildcraft.api.core.Position;
import buildcraft.api.core.SafeTimeTracker;
import buildcraft.api.gates.IOverrideDefaultTriggers;
@ -30,11 +18,12 @@ import buildcraft.api.gates.ITrigger;
import buildcraft.api.power.IPowerProvider;
import buildcraft.api.power.IPowerReceptor;
import buildcraft.api.transport.IPipe;
import buildcraft.api.transport.IPipe.WireColor;
import buildcraft.api.transport.IPipeConnection;
import buildcraft.api.transport.IPipeEntry;
import buildcraft.api.transport.IPipeTile;
import buildcraft.api.transport.IPipedItem;
import buildcraft.api.transport.IPipe.WireColor;
import buildcraft.core.DefaultProps;
import buildcraft.core.EntityPassiveItem;
import buildcraft.core.IDropControlInventory;
import buildcraft.core.ITileBufferHolder;
@ -45,12 +34,21 @@ import buildcraft.core.network.PacketTileState;
import buildcraft.core.utils.Utils;
import buildcraft.transport.Gate.GateKind;
import buildcraft.transport.network.PipeRenderStatePacket;
import cpw.mods.fml.common.Side;
import cpw.mods.fml.common.asm.SideOnly;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.LinkedList;
import net.minecraft.src.Block;
import net.minecraft.src.ItemStack;
import net.minecraft.src.NBTTagCompound;
import net.minecraft.src.Packet;
import net.minecraft.src.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.liquids.ILiquidTank;
import net.minecraftforge.liquids.ITankContainer;
import net.minecraftforge.liquids.LiquidStack;
public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITankContainer, IPipeEntry,
IPipeTile, IOverrideDefaultTriggers, ITileBufferHolder, IPipeConnection, IDropControlInventory, IPipeRenderState,
@ -627,7 +625,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank
@Override
@SideOnly(Side.CLIENT)
public double func_82115_m() {
return 24 * 24;
return DefaultProps.PIPE_CONTENTS_RENDER_DIST * DefaultProps.PIPE_CONTENTS_RENDER_DIST;
}
@Override