Greatly improve performance of transmitter networks, improved logistics of Mechanical Pipe
This commit is contained in:
parent
c10ba92522
commit
a360255f63
16 changed files with 317 additions and 261 deletions
|
@ -6,12 +6,15 @@ import java.util.Collection;
|
|||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Set;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import mekanism.api.Object3D;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
@ -23,10 +26,14 @@ public abstract class DynamicNetwork<A, N> implements ITransmitterNetwork<A, N>
|
|||
public HashSet<A> possibleAcceptors = new HashSet<A>();
|
||||
public HashMap<A, ForgeDirection> acceptorDirections = new HashMap<A, ForgeDirection>();
|
||||
|
||||
private List<DelayQueue> updateQueue = new ArrayList<DelayQueue>();
|
||||
|
||||
protected int ticksSinceCreate = 0;
|
||||
|
||||
protected boolean fixed = false;
|
||||
|
||||
protected boolean needsUpdate = false;
|
||||
|
||||
protected abstract ITransmitterNetwork<A, N> create(ITransmitter<N>... varTransmitters);
|
||||
|
||||
protected abstract ITransmitterNetwork<A, N> create(Collection<ITransmitter<N>> collection);
|
||||
|
@ -94,6 +101,25 @@ public abstract class DynamicNetwork<A, N> implements ITransmitterNetwork<A, N>
|
|||
fixMessedUpNetwork(transmitters.iterator().next());
|
||||
}
|
||||
}
|
||||
|
||||
if(FMLCommonHandler.instance().getEffectiveSide().isServer())
|
||||
{
|
||||
Iterator<DelayQueue> i = updateQueue.iterator();
|
||||
|
||||
while(i.hasNext())
|
||||
{
|
||||
DelayQueue q = i.next();
|
||||
|
||||
if(q.delay > 0)
|
||||
{
|
||||
q.delay--;
|
||||
}
|
||||
else {
|
||||
needsUpdate = true;
|
||||
i.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -195,6 +221,11 @@ public abstract class DynamicNetwork<A, N> implements ITransmitterNetwork<A, N>
|
|||
fixed = value;
|
||||
}
|
||||
|
||||
public void addUpdate(EntityPlayer player)
|
||||
{
|
||||
updateQueue.add(new DelayQueue(player));
|
||||
}
|
||||
|
||||
public static class NetworkFinder
|
||||
{
|
||||
public TransmissionType transmissionType;
|
||||
|
@ -254,4 +285,16 @@ public abstract class DynamicNetwork<A, N> implements ITransmitterNetwork<A, N>
|
|||
return iterated;
|
||||
}
|
||||
}
|
||||
|
||||
public static class DelayQueue
|
||||
{
|
||||
public EntityPlayer player;
|
||||
public int delay;
|
||||
|
||||
public DelayQueue(EntityPlayer p)
|
||||
{
|
||||
player = p;
|
||||
delay = 5;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
package mekanism.api.transmitters;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
@ -138,19 +136,14 @@ public class TransmitterNetworkRegistry implements ITickHandler
|
|||
try {
|
||||
if(c != null)
|
||||
{
|
||||
Map copy = (Map)((HashMap)c.chunkTileEntityMap).clone();
|
||||
|
||||
for(Object obj : copy.values())
|
||||
for(Iterator iter = c.chunkTileEntityMap.values().iterator(); iter.hasNext();)
|
||||
{
|
||||
if(obj instanceof TileEntity)
|
||||
Object obj = iter.next();
|
||||
|
||||
if(obj instanceof ITransmitter && !((TileEntity)obj).worldObj.isRemote)
|
||||
{
|
||||
TileEntity tileEntity = (TileEntity)obj;
|
||||
|
||||
if(tileEntity instanceof ITransmitter)
|
||||
{
|
||||
((ITransmitter)tileEntity).refreshTransmitterNetwork();
|
||||
((ITransmitter)tileEntity).chunkLoad();
|
||||
}
|
||||
((ITransmitter)obj).refreshTransmitterNetwork();
|
||||
((ITransmitter)obj).chunkLoad();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,41 +0,0 @@
|
|||
package mekanism.client;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import mekanism.api.transmitters.TransmissionType;
|
||||
import mekanism.api.transmitters.DynamicNetwork.NetworkFinder;
|
||||
import mekanism.api.Object3D;
|
||||
import mekanism.common.tileentity.TileEntityUniversalCable;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class EnergyClientUpdate
|
||||
{
|
||||
public NetworkFinder finder;
|
||||
|
||||
public World worldObj;
|
||||
|
||||
public double energyScale;
|
||||
|
||||
public EnergyClientUpdate(TileEntity head, double power)
|
||||
{
|
||||
worldObj = head.worldObj;
|
||||
energyScale = power;
|
||||
finder = new NetworkFinder(head.worldObj, TransmissionType.ENERGY, Object3D.get(head));
|
||||
}
|
||||
|
||||
public void clientUpdate()
|
||||
{
|
||||
List<Object3D> found = finder.exploreNetwork();
|
||||
|
||||
for(Object3D object : found)
|
||||
{
|
||||
TileEntity tileEntity = object.getTileEntity(worldObj);
|
||||
|
||||
if(tileEntity instanceof TileEntityUniversalCable)
|
||||
{
|
||||
((TileEntityUniversalCable)tileEntity).setCachedEnergy(energyScale);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,10 +1,7 @@
|
|||
package mekanism.client;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import mekanism.api.transmitters.TransmissionType;
|
||||
import mekanism.api.transmitters.DynamicNetwork.NetworkFinder;
|
||||
import mekanism.api.Object3D;
|
||||
import mekanism.api.transmitters.ITransmitter;
|
||||
import mekanism.common.FluidNetwork;
|
||||
import mekanism.common.tileentity.TileEntityMechanicalPipe;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
@ -12,31 +9,16 @@ import net.minecraftforge.fluids.FluidStack;
|
|||
|
||||
public class FluidClientUpdate
|
||||
{
|
||||
public NetworkFinder finder;
|
||||
|
||||
public World worldObj;
|
||||
|
||||
public FluidStack fluidStack;
|
||||
|
||||
public TileEntity tileEntity;
|
||||
|
||||
public FluidClientUpdate(TileEntity head, FluidStack fluid)
|
||||
{
|
||||
worldObj = head.worldObj;
|
||||
tileEntity = head;
|
||||
fluidStack = fluid;
|
||||
finder = new NetworkFinder(head.worldObj, TransmissionType.FLUID, Object3D.get(head));
|
||||
}
|
||||
|
||||
public void clientUpdate()
|
||||
{
|
||||
List<Object3D> found = finder.exploreNetwork();
|
||||
|
||||
for(Object3D object : found)
|
||||
{
|
||||
TileEntity tileEntity = object.getTileEntity(worldObj);
|
||||
|
||||
if(tileEntity instanceof TileEntityMechanicalPipe)
|
||||
{
|
||||
((TileEntityMechanicalPipe)tileEntity).onTransfer(fluidStack);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,47 +60,50 @@ public class RenderMechanicalPipe extends TileEntitySpecialRenderer
|
|||
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||
GL11.glPopMatrix();
|
||||
|
||||
if(tileEntity.fluidScale > 0 && tileEntity.refFluid != null)
|
||||
Fluid fluid = tileEntity.getTransmitterNetwork().refFluid;
|
||||
float scale = tileEntity.getTransmitterNetwork().fluidScale;
|
||||
|
||||
if(scale > 0 && fluid != null)
|
||||
{
|
||||
push();
|
||||
|
||||
MekanismRenderer.glowOn(tileEntity.refFluid.getFluid().getLuminosity());
|
||||
MekanismRenderer.glowOn(fluid.getLuminosity());
|
||||
|
||||
bindTexture(MekanismRenderer.getBlocksTexture());
|
||||
GL11.glTranslatef((float)x, (float)y, (float)z);
|
||||
|
||||
boolean gas = tileEntity.refFluid.getFluid().isGaseous();
|
||||
boolean gas = fluid.isGaseous();
|
||||
|
||||
for(int i = 0; i < 6; i++)
|
||||
{
|
||||
if(connectable[i])
|
||||
{
|
||||
DisplayInteger[] displayLists = getListAndRender(ForgeDirection.getOrientation(i), tileEntity.refFluid.getFluid());
|
||||
DisplayInteger[] displayLists = getListAndRender(ForgeDirection.getOrientation(i), fluid);
|
||||
|
||||
if(displayLists != null)
|
||||
{
|
||||
if(!gas)
|
||||
{
|
||||
displayLists[Math.max(0, (int)((float)tileEntity.fluidScale*(stages-1)))].render();
|
||||
displayLists[Math.max(0, (int)((float)scale*(stages-1)))].render();
|
||||
}
|
||||
else {
|
||||
GL11.glColor4f(1F, 1F, 1F, tileEntity.fluidScale);
|
||||
GL11.glColor4f(1F, 1F, 1F, scale);
|
||||
displayLists[stages-1].render();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DisplayInteger[] displayLists = getListAndRender(ForgeDirection.UNKNOWN, tileEntity.refFluid.getFluid());
|
||||
DisplayInteger[] displayLists = getListAndRender(ForgeDirection.UNKNOWN, fluid);
|
||||
|
||||
if(displayLists != null)
|
||||
{
|
||||
if(!gas)
|
||||
{
|
||||
displayLists[Math.max(3, (int)((float)tileEntity.fluidScale*(stages-1)))].render();
|
||||
displayLists[Math.max(3, (int)((float)scale*(stages-1)))].render();
|
||||
}
|
||||
else {
|
||||
GL11.glColor4f(1F, 1F, 1F, tileEntity.fluidScale);
|
||||
GL11.glColor4f(1F, 1F, 1F, scale);
|
||||
displayLists[stages-1].render();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ public class RenderUniversalCable extends TileEntitySpecialRenderer
|
|||
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||
GL11.glPopMatrix();
|
||||
|
||||
if(tileEntity.getEnergyScale() <= 0 || !MekanismClient.fancyUniversalCableRender)
|
||||
if(tileEntity.getTransmitterNetwork().clientEnergyScale <= 0 || !MekanismClient.fancyUniversalCableRender)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ public class RenderUniversalCable extends TileEntitySpecialRenderer
|
|||
push();
|
||||
|
||||
MekanismRenderer.glowOn();
|
||||
GL11.glColor4f(1F, 1F, 1F, tileEntity.getEnergyScale());
|
||||
GL11.glColor4f(1F, 1F, 1F, (float)tileEntity.getTransmitterNetwork().clientEnergyScale);
|
||||
bindTexture(MekanismRenderer.getBlocksTexture());
|
||||
GL11.glTranslatef((float)x, (float)y, (float)z);
|
||||
|
||||
|
|
|
@ -39,9 +39,7 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork>
|
|||
private double joulesTransmitted = 0;
|
||||
private double joulesLastTick = 0;
|
||||
|
||||
private List<DelayQueue> updateQueue = new ArrayList<DelayQueue>();
|
||||
|
||||
private boolean needsUpdate = false;
|
||||
public double clientEnergyScale = 0;
|
||||
|
||||
public EnergyNetwork(ITransmitter<EnergyNetwork>... varCables)
|
||||
{
|
||||
|
@ -72,6 +70,11 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork>
|
|||
|
||||
public synchronized double getEnergyNeeded(List<TileEntity> ignored)
|
||||
{
|
||||
if(FMLCommonHandler.instance().getEffectiveSide().isClient())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
double totalNeeded = 0;
|
||||
|
||||
for(TileEntity acceptor : getAcceptors())
|
||||
|
@ -109,6 +112,11 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork>
|
|||
|
||||
public synchronized double emit(double energyToSend, ArrayList<TileEntity> ignored)
|
||||
{
|
||||
if(FMLCommonHandler.instance().getEffectiveSide().isClient())
|
||||
{
|
||||
return energyToSend;
|
||||
}
|
||||
|
||||
double prevEnergy = energyToSend;
|
||||
double sent;
|
||||
|
||||
|
@ -207,6 +215,11 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork>
|
|||
{
|
||||
Set<TileEntity> toReturn = new HashSet<TileEntity>();
|
||||
|
||||
if(FMLCommonHandler.instance().getEffectiveSide().isClient())
|
||||
{
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
Set<TileEntity> copy = (Set<TileEntity>)possibleAcceptors.clone();
|
||||
|
||||
for(TileEntity acceptor : copy)
|
||||
|
@ -355,31 +368,15 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork>
|
|||
|
||||
@Override
|
||||
public void tick()
|
||||
{
|
||||
clearJoulesTransmitted();
|
||||
|
||||
{
|
||||
super.tick();
|
||||
|
||||
clearJoulesTransmitted();
|
||||
|
||||
double currentPowerScale = getPowerScale();
|
||||
|
||||
if(FMLCommonHandler.instance().getEffectiveSide().isServer())
|
||||
{
|
||||
Iterator<DelayQueue> i = updateQueue.iterator();
|
||||
|
||||
while(i.hasNext())
|
||||
{
|
||||
DelayQueue q = i.next();
|
||||
|
||||
if(q.delay > 0)
|
||||
{
|
||||
q.delay--;
|
||||
}
|
||||
else {
|
||||
needsUpdate = true;
|
||||
i.remove();
|
||||
}
|
||||
}
|
||||
|
||||
if(currentPowerScale != lastPowerScale)
|
||||
{
|
||||
needsUpdate = true;
|
||||
|
@ -411,11 +408,6 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork>
|
|||
return joulesLastTick * 20;
|
||||
}
|
||||
|
||||
public void addUpdate(EntityPlayer player)
|
||||
{
|
||||
updateQueue.add(new DelayQueue(player));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EnergyNetwork create(ITransmitter<EnergyNetwork>... varTransmitters)
|
||||
{
|
||||
|
@ -451,16 +443,4 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork>
|
|||
{
|
||||
return ElectricityDisplay.getDisplay((float)(getPower()*Mekanism.TO_UE), ElectricityDisplay.ElectricUnit.JOULES);
|
||||
}
|
||||
|
||||
public static class DelayQueue
|
||||
{
|
||||
public EntityPlayer player;
|
||||
public int delay;
|
||||
|
||||
public DelayQueue(EntityPlayer p)
|
||||
{
|
||||
player = p;
|
||||
delay = 5;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,13 @@ import cpw.mods.fml.common.FMLCommonHandler;
|
|||
|
||||
public class FluidNetwork extends DynamicNetwork<IFluidHandler, FluidNetwork>
|
||||
{
|
||||
public int transferDelay = 0;
|
||||
|
||||
public float fluidScale;
|
||||
public float prevFluidScale;
|
||||
|
||||
public Fluid refFluid = null;
|
||||
|
||||
public FluidNetwork(ITransmitter<FluidNetwork>... varPipes)
|
||||
{
|
||||
transmitters.addAll(Arrays.asList(varPipes));
|
||||
|
@ -74,6 +81,11 @@ public class FluidNetwork extends DynamicNetwork<IFluidHandler, FluidNetwork>
|
|||
|
||||
public synchronized int emit(FluidStack fluidToSend, boolean doTransfer, TileEntity emitter)
|
||||
{
|
||||
if(refFluid != null && refFluid != fluidToSend.getFluid())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
List availableAcceptors = Arrays.asList(getAcceptors(fluidToSend).toArray());
|
||||
|
||||
Collections.shuffle(availableAcceptors);
|
||||
|
@ -108,12 +120,53 @@ public class FluidNetwork extends DynamicNetwork<IFluidHandler, FluidNetwork>
|
|||
{
|
||||
FluidStack sendStack = fluidToSend.copy();
|
||||
sendStack.amount = fluidSent;
|
||||
MinecraftForge.EVENT_BUS.post(new FluidTransferEvent(this, sendStack));
|
||||
|
||||
if(sendStack.getFluid() == refFluid)
|
||||
{
|
||||
fluidScale = Math.min(1, fluidScale+((float)sendStack.amount/1000F));
|
||||
}
|
||||
else if(refFluid == null)
|
||||
{
|
||||
refFluid = sendStack.getFluid();
|
||||
fluidScale += Math.min(1, ((float)sendStack.amount/1000F));
|
||||
}
|
||||
|
||||
transferDelay = 2;
|
||||
}
|
||||
|
||||
return fluidSent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick()
|
||||
{
|
||||
super.tick();
|
||||
|
||||
if(FMLCommonHandler.instance().getEffectiveSide().isServer())
|
||||
{
|
||||
if(transferDelay == 0)
|
||||
{
|
||||
if(fluidScale > 0)
|
||||
{
|
||||
fluidScale -= .02;
|
||||
}
|
||||
else {
|
||||
refFluid = null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
transferDelay--;
|
||||
}
|
||||
|
||||
if(fluidScale != prevFluidScale)
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post(new FluidTransferEvent(this, refFluid != null ? refFluid.getID() : -1, fluidScale));
|
||||
}
|
||||
|
||||
prevFluidScale = fluidScale;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized Set<IFluidHandler> getAcceptors(Object... data)
|
||||
{
|
||||
|
@ -188,12 +241,14 @@ public class FluidNetwork extends DynamicNetwork<IFluidHandler, FluidNetwork>
|
|||
{
|
||||
public final FluidNetwork fluidNetwork;
|
||||
|
||||
public final FluidStack fluidSent;
|
||||
public final int fluidType;
|
||||
public final float fluidScale;
|
||||
|
||||
public FluidTransferEvent(FluidNetwork network, FluidStack fluid)
|
||||
public FluidTransferEvent(FluidNetwork network, int type, float scale)
|
||||
{
|
||||
fluidNetwork = network;
|
||||
fluidSent = fluid;
|
||||
fluidType = type;
|
||||
fluidScale = scale;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ import java.io.File;
|
|||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
@ -18,6 +19,7 @@ import mekanism.api.infuse.InfuseObject;
|
|||
import mekanism.api.infuse.InfuseRegistry;
|
||||
import mekanism.api.infuse.InfuseType;
|
||||
import mekanism.api.infuse.InfusionInput;
|
||||
import mekanism.api.transmitters.ITransmitter;
|
||||
import mekanism.api.transmitters.TransmitterNetworkRegistry;
|
||||
import mekanism.common.EnergyNetwork.EnergyTransferEvent;
|
||||
import mekanism.common.FluidNetwork.FluidTransferEvent;
|
||||
|
@ -72,8 +74,8 @@ import mekanism.common.network.PacketRobit;
|
|||
import mekanism.common.network.PacketSimpleGui;
|
||||
import mekanism.common.network.PacketStatusUpdate;
|
||||
import mekanism.common.network.PacketTileEntity;
|
||||
import mekanism.common.network.PacketTransmitterTransferUpdate;
|
||||
import mekanism.common.network.PacketTransmitterTransferUpdate.TransmitterTransferType;
|
||||
import mekanism.common.network.PacketTransmitterUpdate;
|
||||
import mekanism.common.network.PacketTransmitterUpdate.PacketType;
|
||||
import mekanism.common.network.PacketWalkieTalkieState;
|
||||
import mekanism.common.tileentity.TileEntityAdvancedBoundingBlock;
|
||||
import mekanism.common.tileentity.TileEntityBoundingBlock;
|
||||
|
@ -97,6 +99,7 @@ import net.minecraftforge.oredict.ShapelessOreRecipe;
|
|||
import rebelkeithy.mods.metallurgy.api.IOreInfo;
|
||||
import rebelkeithy.mods.metallurgy.api.MetallurgyAPI;
|
||||
import thermalexpansion.api.crafting.CraftingManagers;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.common.Mod.EventHandler;
|
||||
import cpw.mods.fml.common.Mod.Instance;
|
||||
|
@ -1120,7 +1123,7 @@ public class Mekanism
|
|||
|
||||
//Packet registrations
|
||||
PacketHandler.registerPacket(PacketRobit.class);
|
||||
PacketHandler.registerPacket(PacketTransmitterTransferUpdate.class);
|
||||
PacketHandler.registerPacket(PacketTransmitterUpdate.class);
|
||||
PacketHandler.registerPacket(PacketElectricChest.class);
|
||||
PacketHandler.registerPacket(PacketElectricBowState.class);
|
||||
PacketHandler.registerPacket(PacketConfiguratorState.class);
|
||||
|
@ -1160,7 +1163,7 @@ public class Mekanism
|
|||
public void onEnergyTransferred(EnergyTransferEvent event)
|
||||
{
|
||||
try {
|
||||
PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTransmitterTransferUpdate().setParams(TransmitterTransferType.ENERGY, event.energyNetwork.transmitters.iterator().next(), event.power));
|
||||
PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTransmitterUpdate().setParams(PacketType.ENERGY, event.energyNetwork.transmitters.iterator().next(), event.power));
|
||||
} catch(Exception e) {}
|
||||
}
|
||||
|
||||
|
@ -1168,7 +1171,7 @@ public class Mekanism
|
|||
public void onGasTransferred(GasTransferEvent event)
|
||||
{
|
||||
try {
|
||||
PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTransmitterTransferUpdate().setParams(TransmitterTransferType.GAS, event.gasNetwork.transmitters.iterator().next(), event.transferType));
|
||||
PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTransmitterUpdate().setParams(PacketType.GAS, event.gasNetwork.transmitters.iterator().next(), event.transferType));
|
||||
} catch(Exception e) {}
|
||||
}
|
||||
|
||||
|
@ -1176,7 +1179,7 @@ public class Mekanism
|
|||
public void onLiquidTransferred(FluidTransferEvent event)
|
||||
{
|
||||
try {
|
||||
PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTransmitterTransferUpdate().setParams(TransmitterTransferType.FLUID, event.fluidNetwork.transmitters.iterator().next(), event.fluidSent));
|
||||
PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTransmitterUpdate().setParams(PacketType.FLUID, event.fluidNetwork.transmitters.iterator().next(), event.fluidType, event.fluidScale));
|
||||
} catch(Exception e) {}
|
||||
}
|
||||
|
||||
|
@ -1185,10 +1188,10 @@ public class Mekanism
|
|||
{
|
||||
if(event.getChunk() != null)
|
||||
{
|
||||
Map copy = (Map)((HashMap)event.getChunk().chunkTileEntityMap).clone();
|
||||
|
||||
for(Object obj : copy.values())
|
||||
for(Iterator iter = event.getChunk().chunkTileEntityMap.values().iterator(); iter.hasNext();)
|
||||
{
|
||||
Object obj = iter.next();
|
||||
|
||||
if(obj instanceof TileEntity)
|
||||
{
|
||||
TileEntity tileEntity = (TileEntity)obj;
|
||||
|
|
|
@ -187,6 +187,9 @@ public class PacketHandler implements IPacketHandler
|
|||
Object3D obj = (Object3D)transParams[0];
|
||||
PacketDispatcher.sendPacketToAllAround(obj.xCoord, obj.yCoord, obj.zCoord, (Double)transParams[1], obj.dimensionId, packet);
|
||||
break;
|
||||
case CLIENTS_DIM:
|
||||
PacketDispatcher.sendPacketToAllInDimension(packet, (Integer)transParams[0]);
|
||||
break;
|
||||
case SINGLE_CLIENT:
|
||||
((EntityPlayerMP)transParams[0]).playerNetServerHandler.sendPacketToPlayer(packet);
|
||||
break;
|
||||
|
@ -216,6 +219,9 @@ public class PacketHandler implements IPacketHandler
|
|||
case CLIENTS_RANGE:
|
||||
System.out.println("[Mekanism] Sent '" + packetType.getName() + "' packet to clients in a " + (Double)transParams[1] + " block range.");
|
||||
break;
|
||||
case CLIENTS_DIM:
|
||||
System.out.println("[Mekanism] Sent '" + packetType.getName() + "' packet to clients in dimension ID " + (Integer)transParams[0] + ".");
|
||||
break;
|
||||
case SINGLE_CLIENT:
|
||||
System.out.println("[Mekanism] Sent '" + packetType.getName() + "' packet to " + ((EntityPlayer)transParams[0]).username);
|
||||
break;
|
||||
|
@ -234,6 +240,9 @@ public class PacketHandler implements IPacketHandler
|
|||
/** 2 parameters - Object3D representing the location of the transmission, and a double of the distance this packet can be sent in. */
|
||||
CLIENTS_RANGE(2),
|
||||
|
||||
/** 1 parameter - int representing the dimension ID to send this packet to. */
|
||||
CLIENTS_DIM(1),
|
||||
|
||||
/** 1 parameter - EntityPlayer to send this packet to. */
|
||||
SINGLE_CLIENT(1);
|
||||
|
||||
|
|
|
@ -8,7 +8,11 @@ import mekanism.api.gas.ITubeConnection;
|
|||
import mekanism.api.transmitters.ITransmitter;
|
||||
import mekanism.client.ClientProxy;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.PacketHandler;
|
||||
import mekanism.common.PacketHandler.Transmission;
|
||||
import mekanism.common.PipeUtils;
|
||||
import mekanism.common.network.PacketTransmitterUpdate;
|
||||
import mekanism.common.network.PacketTransmitterUpdate.PacketType;
|
||||
import mekanism.common.tileentity.TileEntityDiversionTransporter;
|
||||
import mekanism.common.tileentity.TileEntityLogisticalTransporter;
|
||||
import mekanism.common.tileentity.TileEntityMechanicalPipe;
|
||||
|
@ -311,6 +315,7 @@ public class BlockTransmitter extends Block
|
|||
if(tileEntity instanceof ITransmitter)
|
||||
{
|
||||
((ITransmitter)tileEntity).refreshTransmitterNetwork();
|
||||
PacketHandler.sendPacket(Transmission.CLIENTS_DIM, new PacketTransmitterUpdate().setParams(PacketType.UPDATE, tileEntity), world.provider.dimensionId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -325,6 +330,7 @@ public class BlockTransmitter extends Block
|
|||
if(tileEntity instanceof ITransmitter)
|
||||
{
|
||||
((ITransmitter)tileEntity).refreshTransmitterNetwork();
|
||||
PacketHandler.sendPacket(Transmission.CLIENTS_DIM, new PacketTransmitterUpdate().setParams(PacketType.UPDATE, tileEntity), world.provider.dimensionId);
|
||||
|
||||
if(tileEntity instanceof TileEntityUniversalCable)
|
||||
{
|
||||
|
|
|
@ -3,19 +3,21 @@ package mekanism.common.network;
|
|||
import java.io.DataOutputStream;
|
||||
|
||||
import mekanism.api.gas.EnumGas;
|
||||
import mekanism.client.EnergyClientUpdate;
|
||||
import mekanism.client.FluidClientUpdate;
|
||||
import mekanism.api.transmitters.ITransmitter;
|
||||
import mekanism.client.GasClientUpdate;
|
||||
import mekanism.common.tileentity.TileEntityMechanicalPipe;
|
||||
import mekanism.common.tileentity.TileEntityUniversalCable;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
public class PacketTransmitterTransferUpdate implements IMekanismPacket
|
||||
public class PacketTransmitterUpdate implements IMekanismPacket
|
||||
{
|
||||
public TransmitterTransferType activeType;
|
||||
public PacketType packetType;
|
||||
|
||||
public TileEntity tileEntity;
|
||||
|
||||
|
@ -23,7 +25,8 @@ public class PacketTransmitterTransferUpdate implements IMekanismPacket
|
|||
|
||||
public String gasName;
|
||||
|
||||
public FluidStack fluidStack;
|
||||
public int fluidType;
|
||||
public float fluidScale;
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
|
@ -34,10 +37,10 @@ public class PacketTransmitterTransferUpdate implements IMekanismPacket
|
|||
@Override
|
||||
public IMekanismPacket setParams(Object... data)
|
||||
{
|
||||
activeType = (TransmitterTransferType)data[0];
|
||||
packetType = (PacketType)data[0];
|
||||
tileEntity = (TileEntity)data[1];
|
||||
|
||||
switch(activeType)
|
||||
switch(packetType)
|
||||
{
|
||||
case ENERGY:
|
||||
power = (Double)data[2];
|
||||
|
@ -46,7 +49,8 @@ public class PacketTransmitterTransferUpdate implements IMekanismPacket
|
|||
gasName = ((EnumGas)data[2]).name;
|
||||
break;
|
||||
case FLUID:
|
||||
fluidStack = (FluidStack)data[2];
|
||||
fluidType = (Integer)data[2];
|
||||
fluidScale = (Float)data[3];
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -63,6 +67,15 @@ public class PacketTransmitterTransferUpdate implements IMekanismPacket
|
|||
int z = dataStream.readInt();
|
||||
|
||||
if(transmitterType == 0)
|
||||
{
|
||||
ITransmitter transmitter = (ITransmitter)world.getBlockTileEntity(x, y, z);
|
||||
|
||||
if(transmitter != null)
|
||||
{
|
||||
transmitter.refreshTransmitterNetwork();
|
||||
}
|
||||
}
|
||||
if(transmitterType == 1)
|
||||
{
|
||||
double powerLevel = dataStream.readDouble();
|
||||
|
||||
|
@ -70,10 +83,10 @@ public class PacketTransmitterTransferUpdate implements IMekanismPacket
|
|||
|
||||
if(tileEntity != null)
|
||||
{
|
||||
new EnergyClientUpdate(tileEntity, powerLevel).clientUpdate();
|
||||
((TileEntityUniversalCable)tileEntity).getTransmitterNetwork().clientEnergyScale = powerLevel;
|
||||
}
|
||||
}
|
||||
else if(transmitterType == 1)
|
||||
else if(transmitterType == 2)
|
||||
{
|
||||
EnumGas type = EnumGas.getFromName(dataStream.readUTF());
|
||||
|
||||
|
@ -84,14 +97,18 @@ public class PacketTransmitterTransferUpdate implements IMekanismPacket
|
|||
new GasClientUpdate(tileEntity, type).clientUpdate();
|
||||
}
|
||||
}
|
||||
else if(transmitterType == 2)
|
||||
else if(transmitterType == 3)
|
||||
{
|
||||
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
||||
FluidStack fluidStack = new FluidStack(dataStream.readInt(), dataStream.readInt());
|
||||
|
||||
int type = dataStream.readInt();
|
||||
Fluid fluidType = type != -1 ? FluidRegistry.getFluid(type) : null;
|
||||
float fluidScale = dataStream.readFloat();
|
||||
|
||||
if(tileEntity != null)
|
||||
{
|
||||
new FluidClientUpdate(tileEntity, fluidStack).clientUpdate();
|
||||
((TileEntityMechanicalPipe)tileEntity).getTransmitterNetwork().refFluid = fluidType;
|
||||
((TileEntityMechanicalPipe)tileEntity).getTransmitterNetwork().fluidScale = fluidScale;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -99,13 +116,13 @@ public class PacketTransmitterTransferUpdate implements IMekanismPacket
|
|||
@Override
|
||||
public void write(DataOutputStream dataStream) throws Exception
|
||||
{
|
||||
dataStream.writeInt(activeType.ordinal());
|
||||
dataStream.writeInt(packetType.ordinal());
|
||||
|
||||
dataStream.writeInt(tileEntity.xCoord);
|
||||
dataStream.writeInt(tileEntity.yCoord);
|
||||
dataStream.writeInt(tileEntity.zCoord);
|
||||
|
||||
switch(activeType)
|
||||
switch(packetType)
|
||||
{
|
||||
case ENERGY:
|
||||
dataStream.writeDouble(power);
|
||||
|
@ -114,14 +131,15 @@ public class PacketTransmitterTransferUpdate implements IMekanismPacket
|
|||
dataStream.writeUTF(gasName);
|
||||
break;
|
||||
case FLUID:
|
||||
dataStream.writeInt(fluidStack.fluidID);
|
||||
dataStream.writeInt(fluidStack.amount);
|
||||
dataStream.writeInt(fluidType);
|
||||
dataStream.writeFloat(fluidScale);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static enum TransmitterTransferType
|
||||
public static enum PacketType
|
||||
{
|
||||
UPDATE,
|
||||
ENERGY,
|
||||
GAS,
|
||||
FLUID
|
|
@ -7,6 +7,7 @@ import java.util.HashSet;
|
|||
import mekanism.api.Object3D;
|
||||
import mekanism.api.transmitters.ITransmitter;
|
||||
import mekanism.api.transmitters.TransmissionType;
|
||||
import mekanism.api.transmitters.TransmitterNetworkRegistry;
|
||||
import mekanism.common.FluidNetwork;
|
||||
import mekanism.common.ITileNetwork;
|
||||
import mekanism.common.PacketHandler;
|
||||
|
@ -34,32 +35,9 @@ public class TileEntityMechanicalPipe extends TileEntityTransmitter<FluidNetwork
|
|||
/** The fake tank used for fluid transfer calculations. */
|
||||
public FluidTank dummyTank = new FluidTank(FluidContainerRegistry.BUCKET_VOLUME);
|
||||
|
||||
/** The FluidStack displayed on this pipe. */
|
||||
public FluidStack refFluid = null;
|
||||
|
||||
/** This pipe's active state. */
|
||||
public boolean isActive = false;
|
||||
|
||||
public int transferDelay = 0;
|
||||
|
||||
/** The scale (0F -> 1F) of this pipe's fluid level. */
|
||||
public float fluidScale;
|
||||
|
||||
public void onTransfer(FluidStack fluidStack)
|
||||
{
|
||||
if(fluidStack.isFluidEqual(refFluid))
|
||||
{
|
||||
fluidScale = Math.min(1, fluidScale+((float)fluidStack.amount/1000F));
|
||||
}
|
||||
else if(refFluid == null)
|
||||
{
|
||||
refFluid = fluidStack.copy();
|
||||
fluidScale += Math.min(1, ((float)fluidStack.amount/1000F));
|
||||
}
|
||||
|
||||
transferDelay = 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TransmissionType getTransmissionType()
|
||||
{
|
||||
|
@ -82,7 +60,7 @@ public class TileEntityMechanicalPipe extends TileEntityTransmitter<FluidNetwork
|
|||
}
|
||||
}
|
||||
|
||||
if(connectedNets.size() == 0 || worldObj.isRemote)
|
||||
if(connectedNets.size() == 0)
|
||||
{
|
||||
theNetwork = new FluidNetwork(this);
|
||||
}
|
||||
|
@ -106,12 +84,22 @@ public class TileEntityMechanicalPipe extends TileEntityTransmitter<FluidNetwork
|
|||
getTransmitterNetwork().fixMessedUpNetwork(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload()
|
||||
{
|
||||
super.onChunkUnload();
|
||||
|
||||
getTransmitterNetwork().split(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate()
|
||||
{
|
||||
getTransmitterNetwork().split(this);
|
||||
|
||||
if(!worldObj.isRemote)
|
||||
{
|
||||
getTransmitterNetwork().split(this);
|
||||
TransmitterNetworkRegistry.getInstance().pruneEmptyNetworks();
|
||||
}
|
||||
|
||||
super.invalidate();
|
||||
|
@ -129,42 +117,24 @@ public class TileEntityMechanicalPipe extends TileEntityTransmitter<FluidNetwork
|
|||
@Override
|
||||
public void refreshTransmitterNetwork()
|
||||
{
|
||||
if(!worldObj.isRemote)
|
||||
for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
TileEntity tileEntity = Object3D.get(this).getFromSide(side).getTileEntity(worldObj);
|
||||
|
||||
if(TransmissionType.checkTransmissionType(tileEntity, getTransmissionType()))
|
||||
{
|
||||
getTransmitterNetwork().merge(((ITransmitter<FluidNetwork>)tileEntity).getTransmitterNetwork());
|
||||
}
|
||||
}
|
||||
TileEntity tileEntity = Object3D.get(this).getFromSide(side).getTileEntity(worldObj);
|
||||
|
||||
getTransmitterNetwork().refresh();
|
||||
if(TransmissionType.checkTransmissionType(tileEntity, getTransmissionType()))
|
||||
{
|
||||
getTransmitterNetwork().merge(((ITransmitter<FluidNetwork>)tileEntity).getTransmitterNetwork());
|
||||
}
|
||||
}
|
||||
|
||||
getTransmitterNetwork().refresh();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
if(worldObj.isRemote)
|
||||
if(!worldObj.isRemote)
|
||||
{
|
||||
if(transferDelay == 0)
|
||||
{
|
||||
if(fluidScale > 0)
|
||||
{
|
||||
fluidScale -= .01;
|
||||
}
|
||||
else {
|
||||
refFluid = null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
transferDelay--;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(isActive)
|
||||
{
|
||||
IFluidHandler[] connectedAcceptors = PipeUtils.getConnectedAcceptors(this);
|
||||
|
|
|
@ -10,6 +10,7 @@ import mekanism.api.gas.IGasTransmitter;
|
|||
import mekanism.api.gas.ITubeConnection;
|
||||
import mekanism.api.transmitters.ITransmitter;
|
||||
import mekanism.api.transmitters.TransmissionType;
|
||||
import mekanism.api.transmitters.TransmitterNetworkRegistry;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
|
@ -43,7 +44,7 @@ public class TileEntityPressurizedTube extends TileEntityTransmitter<GasNetwork>
|
|||
}
|
||||
}
|
||||
|
||||
if(connectedNets.size() == 0 || worldObj.isRemote)
|
||||
if(connectedNets.size() == 0)
|
||||
{
|
||||
theNetwork = new GasNetwork(this);
|
||||
}
|
||||
|
@ -67,12 +68,22 @@ public class TileEntityPressurizedTube extends TileEntityTransmitter<GasNetwork>
|
|||
getTransmitterNetwork().fixMessedUpNetwork(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload()
|
||||
{
|
||||
super.onChunkUnload();
|
||||
|
||||
getTransmitterNetwork().split(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate()
|
||||
{
|
||||
getTransmitterNetwork().split(this);
|
||||
|
||||
if(!worldObj.isRemote)
|
||||
{
|
||||
getTransmitterNetwork().split(this);
|
||||
TransmitterNetworkRegistry.getInstance().pruneEmptyNetworks();
|
||||
}
|
||||
|
||||
super.invalidate();
|
||||
|
@ -90,20 +101,17 @@ public class TileEntityPressurizedTube extends TileEntityTransmitter<GasNetwork>
|
|||
@Override
|
||||
public void refreshTransmitterNetwork()
|
||||
{
|
||||
if(!worldObj.isRemote)
|
||||
for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
TileEntity tileEntity = Object3D.get(this).getFromSide(side).getTileEntity(worldObj);
|
||||
|
||||
if(TransmissionType.checkTransmissionType(tileEntity, TransmissionType.GAS, this))
|
||||
{
|
||||
getTransmitterNetwork().merge(((ITransmitter<GasNetwork>)tileEntity).getTransmitterNetwork());
|
||||
}
|
||||
}
|
||||
TileEntity tileEntity = Object3D.get(this).getFromSide(side).getTileEntity(worldObj);
|
||||
|
||||
getTransmitterNetwork().refresh();
|
||||
if(TransmissionType.checkTransmissionType(tileEntity, TransmissionType.GAS, this))
|
||||
{
|
||||
getTransmitterNetwork().merge(((ITransmitter<GasNetwork>)tileEntity).getTransmitterNetwork());
|
||||
}
|
||||
}
|
||||
|
||||
getTransmitterNetwork().refresh();
|
||||
}
|
||||
|
||||
public void onTransfer(EnumGas type)
|
||||
|
@ -125,12 +133,6 @@ public class TileEntityPressurizedTube extends TileEntityTransmitter<GasNetwork>
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUpdate()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTransmitterNetworkSize()
|
||||
{
|
||||
|
|
|
@ -1,20 +1,19 @@
|
|||
package mekanism.common.tileentity;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import mekanism.api.Object3D;
|
||||
import mekanism.api.transmitters.ITransmitter;
|
||||
import mekanism.api.transmitters.TransmitterNetworkRegistry;
|
||||
import mekanism.common.PacketHandler;
|
||||
import mekanism.common.PacketHandler.Transmission;
|
||||
import mekanism.common.network.PacketDataRequest;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public abstract class TileEntityTransmitter<N> extends TileEntity implements ITransmitter<N>
|
||||
{
|
||||
public N theNetwork;
|
||||
|
||||
public int delayTicks = 0;
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public AxisAlignedBB getRenderBoundingBox()
|
||||
|
@ -22,11 +21,40 @@ public abstract class TileEntityTransmitter<N> extends TileEntity implements ITr
|
|||
return INFINITE_EXTENT_AABB;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUpdate()
|
||||
{
|
||||
return FMLCommonHandler.instance().getEffectiveSide().isClient();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
super.updateEntity();
|
||||
|
||||
if(worldObj.isRemote)
|
||||
{
|
||||
if(delayTicks == 3)
|
||||
{
|
||||
delayTicks++;
|
||||
refreshTransmitterNetwork();
|
||||
}
|
||||
else if(delayTicks < 3)
|
||||
{
|
||||
delayTicks++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload()
|
||||
{
|
||||
invalidate();
|
||||
TransmitterNetworkRegistry.getInstance().pruneEmptyNetworks();
|
||||
super.onChunkUnload();
|
||||
|
||||
if(!worldObj.isRemote)
|
||||
{
|
||||
TransmitterNetworkRegistry.getInstance().pruneEmptyNetworks();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -12,6 +12,7 @@ import java.util.Set;
|
|||
import mekanism.api.Object3D;
|
||||
import mekanism.api.transmitters.ITransmitter;
|
||||
import mekanism.api.transmitters.TransmissionType;
|
||||
import mekanism.api.transmitters.TransmitterNetworkRegistry;
|
||||
import mekanism.common.EnergyNetwork;
|
||||
import mekanism.common.ITileNetwork;
|
||||
import mekanism.common.Mekanism;
|
||||
|
@ -59,12 +60,6 @@ public class TileEntityUniversalCable extends TileEntityTransmitter<EnergyNetwor
|
|||
return TransmissionType.ENERGY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUpdate()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnergyNetwork getTransmitterNetwork(boolean createIfNull)
|
||||
{
|
||||
|
@ -81,7 +76,7 @@ public class TileEntityUniversalCable extends TileEntityTransmitter<EnergyNetwor
|
|||
}
|
||||
}
|
||||
|
||||
if(connectedNets.size() == 0 || worldObj.isRemote)
|
||||
if(connectedNets.size() == 0)
|
||||
{
|
||||
theNetwork = new EnergyNetwork(this);
|
||||
}
|
||||
|
@ -108,17 +103,30 @@ public class TileEntityUniversalCable extends TileEntityTransmitter<EnergyNetwor
|
|||
@Override
|
||||
public void invalidate()
|
||||
{
|
||||
getTransmitterNetwork().split(this);
|
||||
|
||||
if(!worldObj.isRemote)
|
||||
{
|
||||
getTransmitterNetwork().split(this);
|
||||
|
||||
Mekanism.ic2Registered.remove(Object3D.get(this));
|
||||
MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this));
|
||||
TransmitterNetworkRegistry.getInstance().pruneEmptyNetworks();
|
||||
}
|
||||
|
||||
super.invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload()
|
||||
{
|
||||
super.onChunkUnload();
|
||||
|
||||
getTransmitterNetwork().split(this);
|
||||
|
||||
if(!worldObj.isRemote)
|
||||
{
|
||||
Mekanism.ic2Registered.remove(Object3D.get(this));
|
||||
MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeFromTransmitterNetwork()
|
||||
{
|
||||
|
@ -131,21 +139,18 @@ public class TileEntityUniversalCable extends TileEntityTransmitter<EnergyNetwor
|
|||
@Override
|
||||
public void refreshTransmitterNetwork()
|
||||
{
|
||||
if(!worldObj.isRemote)
|
||||
for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
TileEntity tileEntity = Object3D.get(this).getFromSide(side).getTileEntity(worldObj);
|
||||
|
||||
if(TransmissionType.checkTransmissionType(tileEntity, TransmissionType.ENERGY))
|
||||
{
|
||||
getTransmitterNetwork().merge(((ITransmitter<EnergyNetwork>)tileEntity).getTransmitterNetwork());
|
||||
}
|
||||
}
|
||||
TileEntity tileEntity = Object3D.get(this).getFromSide(side).getTileEntity(worldObj);
|
||||
|
||||
getTransmitterNetwork().refresh();
|
||||
reconfigure();
|
||||
if(TransmissionType.checkTransmissionType(tileEntity, TransmissionType.ENERGY))
|
||||
{
|
||||
getTransmitterNetwork().merge(((ITransmitter<EnergyNetwork>)tileEntity).getTransmitterNetwork());
|
||||
}
|
||||
}
|
||||
|
||||
getTransmitterNetwork().refresh();
|
||||
reconfigure();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue