got pathfinder simi functional
not sure what i f'd up between this and my test build repo. What ever happened it works for water now and not for lava.
This commit is contained in:
parent
7154161a5d
commit
6939d3ca6f
10 changed files with 126 additions and 75 deletions
|
@ -200,10 +200,8 @@ public class TileEntityPipe extends TileEntityAdvanced implements ITankContainer
|
|||
public void readFromNBT(NBTTagCompound nbt)
|
||||
{
|
||||
super.readFromNBT(nbt);
|
||||
|
||||
LiquidStack liquid = new LiquidStack(0, 0, 0);
|
||||
liquid.loadLiquidStackFromNBT(nbt.getCompoundTag("stored"));
|
||||
if (Item.itemsList[liquid.itemID] != null && liquid.amount > 0)
|
||||
LiquidStack liquid = LiquidStack.loadLiquidStackFromNBT(nbt.getCompoundTag("tank"));
|
||||
if (liquid != null)
|
||||
{
|
||||
this.fakeTank.setLiquid(liquid);
|
||||
}
|
||||
|
@ -216,6 +214,28 @@ public class TileEntityPipe extends TileEntityAdvanced implements ITankContainer
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a tile entity to NBT.
|
||||
*/
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt)
|
||||
{
|
||||
super.writeToNBT(nbt);
|
||||
if (this.fakeTank.containsValidLiquid())
|
||||
{
|
||||
nbt.setTag("stored", this.fakeTank.getLiquid().writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
if (this.subEntities[i] != null)
|
||||
{
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
((TileEntity) this.subEntities[i]).writeToNBT(tag);
|
||||
nbt.setTag("Addon" + i, tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean addNewExtention(int side, Class<? extends TileEntity> partClass)
|
||||
{
|
||||
if (partClass == null)
|
||||
|
@ -300,29 +320,6 @@ public class TileEntityPipe extends TileEntityAdvanced implements ITankContainer
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a tile entity to NBT.
|
||||
*/
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt)
|
||||
{
|
||||
super.writeToNBT(nbt);
|
||||
LiquidStack stack = this.fakeTank.getLiquid();
|
||||
if (stack != null && LiquidDictionary.findLiquidName(stack) != null)
|
||||
{
|
||||
nbt.setTag("stored", stack.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
if (this.subEntities[i] != null)
|
||||
{
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
((TileEntity) this.subEntities[i]).writeToNBT(tag);
|
||||
nbt.setTag("Addon" + i, tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gets the current color mark of the pipe
|
||||
*/
|
||||
|
@ -405,7 +402,7 @@ public class TileEntityPipe extends TileEntityAdvanced implements ITankContainer
|
|||
{
|
||||
return 0;
|
||||
}
|
||||
return this.getNetwork().addFluidToNetwork(this, resource,doFill);
|
||||
return this.getNetwork().addFluidToNetwork(this, resource, doFill);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -510,7 +507,7 @@ public class TileEntityPipe extends TileEntityAdvanced implements ITankContainer
|
|||
LiquidStack stack = tankContainer.drain(dir, LiquidContainerRegistry.BUCKET_VOLUME, false);
|
||||
if (stack != null && stack.amount > 0)
|
||||
{
|
||||
int fill = this.getNetwork().addFluidToNetwork((TileEntity) tankContainer, stack,true);
|
||||
int fill = this.getNetwork().addFluidToNetwork((TileEntity) tankContainer, stack, true);
|
||||
tankContainer.drain(dir, fill, true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,7 +53,6 @@ public class BlockDrain extends BlockAdvanced
|
|||
if(!world.isRemote)
|
||||
{
|
||||
world.setBlockMetadataWithNotify(x, y, z, side, 3);
|
||||
return true;
|
||||
}
|
||||
return this.onUseWrench(world, x, y, z, entityPlayer, side, hitX, hitY, hitZ);
|
||||
}
|
||||
|
|
|
@ -3,8 +3,10 @@ package fluidmech.common.pump;
|
|||
import fluidmech.common.FluidMech;
|
||||
import hydraulic.helpers.FluidHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
@ -17,21 +19,26 @@ import universalelectricity.core.vector.Vector3;
|
|||
|
||||
public class PathfinderCheckerLiquid extends Pathfinder
|
||||
{
|
||||
public PathfinderCheckerLiquid(final World world, final int maxResources, final LiquidStack resource, final Vector3... ignoreList)
|
||||
public List<Vector3> targetList = new ArrayList<Vector3>();
|
||||
|
||||
public PathfinderCheckerLiquid(final World world, final Vector3 callLoc, final LiquidStack resource, final Vector3... ignoreList)
|
||||
{
|
||||
super(new IPathCallBack()
|
||||
{
|
||||
@Override
|
||||
public Set<Vector3> getConnectedNodes(Pathfinder finder, Vector3 currentNode)
|
||||
{
|
||||
System.out.println("AN:" + currentNode.toString());
|
||||
Set<Vector3> neighbors = new HashSet<Vector3>();
|
||||
|
||||
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
Vector3 pos = currentNode.clone().modifyPositionFromSide(direction);
|
||||
|
||||
if (FluidHelper.isLiquidBlock(world,pos) && FluidHelper.getLiquidFromBlockId(pos.getBlockID(world)).equals(resource))
|
||||
System.out.println("AN:" + direction.ordinal() + ":" + pos.toString() + " " + pos.getBlockID(world) + ":" + pos.getBlockMetadata(world));
|
||||
LiquidStack liquid = FluidHelper.getLiquidFromBlockId(pos.getBlockID(world));
|
||||
if (liquid != null && (liquid.equals(resource) || resource == null))
|
||||
{
|
||||
System.out.println("ADD:" + pos.toString());
|
||||
neighbors.add(pos);
|
||||
}
|
||||
}
|
||||
|
@ -42,7 +49,16 @@ public class PathfinderCheckerLiquid extends Pathfinder
|
|||
@Override
|
||||
public boolean onSearch(Pathfinder finder, Vector3 node)
|
||||
{
|
||||
if (finder.closedSet.size() >= maxResources)
|
||||
LiquidStack liquid = FluidHelper.getLiquidFromBlockId(node.getBlockID(world));
|
||||
if (liquid != null && (liquid.equals(resource) || resource == null) && node.getBlockMetadata(world) == 0)
|
||||
{
|
||||
TileEntity entity = callLoc.getTileEntity(world);
|
||||
if (entity instanceof TileEntityDrain)
|
||||
{
|
||||
((TileEntityDrain) entity).addVectorToQue(node);
|
||||
}
|
||||
}
|
||||
if (finder.closedSet.size() >= 2000)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -15,11 +15,11 @@ import universalelectricity.core.path.IPathCallBack;
|
|||
import universalelectricity.core.path.Pathfinder;
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
|
||||
public class PathfinderFindHighestBlock extends Pathfinder
|
||||
public class PathfinderFindLiquid extends Pathfinder
|
||||
{
|
||||
public static int highestY = 0;
|
||||
|
||||
public PathfinderFindHighestBlock(final World world, final int blockID, final Vector3... ignoreList)
|
||||
public PathfinderFindLiquid(final World world, final LiquidStack resource, final Vector3... ignoreList)
|
||||
{
|
||||
super(new IPathCallBack()
|
||||
{
|
||||
|
@ -27,8 +27,10 @@ public class PathfinderFindHighestBlock extends Pathfinder
|
|||
public Set<Vector3> getConnectedNodes(Pathfinder finder, Vector3 currentNode)
|
||||
{
|
||||
Set<Vector3> neighbors = new HashSet<Vector3>();
|
||||
|
||||
Vector3 pos = currentNode.clone().modifyPositionFromSide(ForgeDirection.UP);
|
||||
if (pos.getBlockID(world) == blockID)
|
||||
LiquidStack liquid = FluidHelper.getLiquidFromBlockId(pos.getBlockID(world));
|
||||
if (liquid != null && (liquid.equals(resource) || resource == null))
|
||||
{
|
||||
neighbors.add(pos);
|
||||
if (pos.intY() > highestY)
|
||||
|
@ -37,11 +39,12 @@ public class PathfinderFindHighestBlock extends Pathfinder
|
|||
}
|
||||
return neighbors;
|
||||
}
|
||||
|
||||
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
pos = currentNode.clone().modifyPositionFromSide(direction);
|
||||
|
||||
if (pos.getBlockID(world) == blockID)
|
||||
liquid = FluidHelper.getLiquidFromBlockId(pos.getBlockID(world));
|
||||
if (liquid != null && (liquid.equals(resource) || resource == null))
|
||||
{
|
||||
neighbors.add(pos);
|
||||
if (pos.intY() > highestY)
|
||||
|
@ -57,7 +60,7 @@ public class PathfinderFindHighestBlock extends Pathfinder
|
|||
@Override
|
||||
public boolean onSearch(Pathfinder finder, Vector3 node)
|
||||
{
|
||||
if (finder.closedSet.size() >= 10000 || highestY == 256)
|
||||
if (finder.closedSet.size() >= 1000 || highestY >= 255)
|
||||
{
|
||||
return true;
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package fluidmech.common.pump;
|
||||
|
||||
import hydraulic.api.IPipeConnection;
|
||||
import hydraulic.fluidnetwork.HydraulicNetworkHelper;
|
||||
import hydraulic.fluidnetwork.IFluidNetworkPart;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
@ -34,24 +35,28 @@ public class TileEntityConstructionPump extends TileEntityElectricityRunnable im
|
|||
this.outputSide = ForgeDirection.getOrientation(meta);
|
||||
this.inputSide = outputSide.getOpposite();
|
||||
}
|
||||
|
||||
public ForgeDirection getFacing()
|
||||
{
|
||||
int meta = 2;
|
||||
if(worldObj != null)
|
||||
if (worldObj != null)
|
||||
{
|
||||
meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord);
|
||||
meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord);
|
||||
}
|
||||
return ForgeDirection.getOrientation(meta);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
if (!worldObj.isRemote && this.wattsReceived >= this.WATTS_PER_TICK)
|
||||
// this.wattsReceived >= this.WATTS_PER_TICK
|
||||
if (!worldObj.isRemote)
|
||||
{
|
||||
if (this.ticks % 10 == 0) // TODO add electric Drain
|
||||
{
|
||||
boolean called = false;
|
||||
|
||||
TileEntity inputTile = VectorHelper.getTileEntityFromSide(worldObj, new Vector3(this), inputSide);
|
||||
TileEntity outputTile = VectorHelper.getTileEntityFromSide(worldObj, new Vector3(this), outputSide);
|
||||
if (inputTile instanceof IFluidNetworkPart)
|
||||
|
@ -89,7 +94,7 @@ public class TileEntityConstructionPump extends TileEntityElectricityRunnable im
|
|||
@Override
|
||||
public int fill(ForgeDirection from, LiquidStack resource, boolean doFill)
|
||||
{
|
||||
if (from != inputSide)
|
||||
if (from != inputSide.getOpposite())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@ -106,7 +111,8 @@ public class TileEntityConstructionPump extends TileEntityElectricityRunnable im
|
|||
TileEntity entity = VectorHelper.getTileEntityFromSide(this.worldObj, new Vector3(this), outputSide);
|
||||
if (entity instanceof ITankContainer)
|
||||
{
|
||||
return ((ITankContainer) entity).fill(outputSide.getOpposite(), resource, doFill);
|
||||
return resource.amount;
|
||||
// return ((ITankContainer) entity).fill(outputSide.getOpposite(), resource, doFill);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -149,7 +155,11 @@ public class TileEntityConstructionPump extends TileEntityElectricityRunnable im
|
|||
{
|
||||
return dir == this.inputSide || dir == this.outputSide;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void invalidate()
|
||||
{
|
||||
super.invalidate();
|
||||
HydraulicNetworkHelper.invalidate(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import hydraulic.prefab.tile.TileEntityFluidDevice;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
|
@ -24,7 +25,7 @@ public class TileEntityDrain extends TileEntityFluidDevice implements ITankConta
|
|||
{
|
||||
private boolean drainSources = true;
|
||||
/* MAX BLOCKS DRAINED PER 1/2 SECOND */
|
||||
public static int MAX_DRAIN_PER_PROCESS = 15;
|
||||
public static int MAX_DRAIN_PER_PROCESS = 30;
|
||||
private int currentDrains = 0;
|
||||
/* LIST OF PUMPS AND THERE REQUESTS FOR THIS DRAIN */
|
||||
private HashMap<TileEntityConstructionPump, LiquidStack> requestMap = new HashMap<TileEntityConstructionPump, LiquidStack>();
|
||||
|
@ -71,10 +72,12 @@ public class TileEntityDrain extends TileEntityFluidDevice implements ITankConta
|
|||
{
|
||||
break;
|
||||
}
|
||||
if (((IFluidNetworkPart) pipe).getNetwork().isConnected(request.getKey()))
|
||||
if (((IFluidNetworkPart) pipe).getNetwork().isConnected(request.getKey()) && targetSources.size() > 0)
|
||||
{
|
||||
for (Vector3 loc : targetSources)
|
||||
Iterator it = this.targetSources.iterator();
|
||||
while (it.hasNext())
|
||||
{
|
||||
Vector3 loc = (Vector3) it.next();
|
||||
if (this.currentDrains >= MAX_DRAIN_PER_PROCESS)
|
||||
{
|
||||
break;
|
||||
|
@ -87,7 +90,7 @@ public class TileEntityDrain extends TileEntityFluidDevice implements ITankConta
|
|||
|
||||
if (stack != null && requestStack != null && (requestStack.isLiquidEqual(stack) || requestStack.itemID == -1))
|
||||
{
|
||||
if (request.getKey().fill(0, stack, false) >= stack.amount)
|
||||
if (request.getKey().fill(0, stack, false) > 0)
|
||||
{
|
||||
int requestAmmount = requestStack.amount - request.getKey().fill(0, stack, true);
|
||||
if (requestAmmount <= 0)
|
||||
|
@ -101,6 +104,8 @@ public class TileEntityDrain extends TileEntityFluidDevice implements ITankConta
|
|||
|
||||
loc.setBlock(this.worldObj, 0);
|
||||
this.currentDrains++;
|
||||
it.remove();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -141,27 +146,34 @@ public class TileEntityDrain extends TileEntityFluidDevice implements ITankConta
|
|||
}
|
||||
|
||||
@Override
|
||||
public void stopRequesting(TileEntityConstructionPump pump)
|
||||
public void stopRequesting(TileEntity pump)
|
||||
{
|
||||
if (this.requestMap.containsKey(pump))
|
||||
{
|
||||
this.requestMap.remove(pump);
|
||||
}
|
||||
}
|
||||
|
||||
public void addVectorToQue(Vector3 vector)
|
||||
{
|
||||
if(!this.targetSources.contains(vector))
|
||||
{
|
||||
this.targetSources.add(vector);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Finds more liquid blocks using a path finder to be drained
|
||||
*/
|
||||
public void getNextFluidBlock()
|
||||
{
|
||||
System.out.println("Before Targets:"+this.targetSources.size());
|
||||
/* FIND HIGHEST DRAIN POINT FIRST */
|
||||
PathfinderFindHighestBlock path = new PathfinderFindHighestBlock(this.worldObj, Block.waterStill.blockID);
|
||||
path.init(new Vector3(xCoord + this.getFacing().offsetX, yCoord + this.getFacing().offsetY, zCoord + this.getFacing().offsetZ));
|
||||
PathfinderFindLiquid path = new PathfinderFindLiquid(this.worldObj, null);
|
||||
path.init(new Vector3(this.xCoord + this.getFacing().offsetX, this.yCoord + this.getFacing().offsetY, this.zCoord + this.getFacing().offsetZ));
|
||||
int y = path.highestY;
|
||||
|
||||
/* FIND 10 UNMARKED SOURCES */
|
||||
PathfinderCheckerLiquid pathFinder = new PathfinderCheckerLiquid(worldObj, this.MAX_DRAIN_PER_PROCESS, null, (Vector3[]) this.targetSources.toArray());
|
||||
pathFinder.init(new Vector3(xCoord, y, zCoord));
|
||||
PathfinderCheckerLiquid pathFinder = new PathfinderCheckerLiquid(this.worldObj, new Vector3(this), null);
|
||||
pathFinder.init(new Vector3(this.xCoord, y, this.zCoord));
|
||||
for (Vector3 loc : pathFinder.closedSet)
|
||||
{
|
||||
if (!this.targetSources.contains(loc))
|
||||
|
@ -169,6 +181,7 @@ public class TileEntityDrain extends TileEntityFluidDevice implements ITankConta
|
|||
this.targetSources.add(loc);
|
||||
}
|
||||
}
|
||||
System.out.println("Targets:"+this.targetSources.size());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package hydraulic.api;
|
||||
|
||||
import fluidmech.common.pump.TileEntityConstructionPump;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.liquids.ITankContainer;
|
||||
import net.minecraftforge.liquids.LiquidStack;
|
||||
|
||||
|
@ -38,7 +39,7 @@ public interface IDrain extends ITankContainer
|
|||
* removed from the request map after being filled. However, this can be used too stop a request
|
||||
* short if the pump becomes full before the request is filled
|
||||
*
|
||||
* @param pump - requesting pump
|
||||
* @param tileEntity - requesting pump
|
||||
*/
|
||||
public void stopRequesting(TileEntityConstructionPump pump);
|
||||
public void stopRequesting(TileEntity tileEntity);
|
||||
}
|
||||
|
|
|
@ -140,6 +140,8 @@ public class HydraulicNetwork
|
|||
{
|
||||
fluidTanks.remove(ent);
|
||||
}
|
||||
this.removeLoad(ent);
|
||||
this.removeSource(ent);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -264,7 +266,7 @@ public class HydraulicNetwork
|
|||
*/
|
||||
public int addFluidToNetwork(TileEntity source, LiquidStack stack, boolean doFill)
|
||||
{
|
||||
return this.addFluidToNetwork(source, stack, doFill, true);
|
||||
return this.addFluidToNetwork(source, stack, doFill, false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -306,7 +308,7 @@ public class HydraulicNetwork
|
|||
/* FIND THE FILL TARGET FROM THE LIST OF FLUID RECIEVERS */
|
||||
for (ITankContainer tankContainer : fluidTanks)
|
||||
{
|
||||
if (tankContainer instanceof TileEntity && tankContainer != source)
|
||||
if (tankContainer instanceof TileEntity && tankContainer != source && !(tankContainer instanceof IFluidNetworkPart))
|
||||
{
|
||||
TileEntity[] connectedTiles = connectionHelper.getSurroundingTileEntities((TileEntity) tankContainer);
|
||||
|
||||
|
@ -353,17 +355,17 @@ public class HydraulicNetwork
|
|||
if (primaryFill != null)
|
||||
{
|
||||
used = primaryFill.fill(fillDir, stack, doFill);
|
||||
System.out.println("Primary Target " + used + doFill);
|
||||
//System.out.println("Primary Target " + used + doFill);
|
||||
}
|
||||
else if (secondayFill != null)
|
||||
{
|
||||
used = secondayFill.fill(fillDir, stack, doFill);
|
||||
System.out.println("Seconday Target " + used + doFill);
|
||||
//System.out.println("Seconday Target " + used + doFill);
|
||||
}
|
||||
else if (allowStore && (this.combinedStorage.getLiquid() == null || this.combinedStorage.getLiquid().amount < this.combinedStorage.getCapacity()))
|
||||
{
|
||||
used = this.combinedStorage.fill(stack, doFill);
|
||||
System.out.println("Network Target filled for " + used + doFill);
|
||||
//System.out.println("Network Target filled for " + used + doFill);
|
||||
filledMain = true;
|
||||
}
|
||||
/* IF THE COMBINED STORAGE OF THE PIPES HAS LIQUID MOVE IT FIRST */
|
||||
|
@ -382,7 +384,7 @@ public class HydraulicNetwork
|
|||
used = Math.min(used, Math.max(used - this.combinedStorage.getLiquid().amount, 0));
|
||||
drainStack = this.combinedStorage.drain(pUsed - used, doFill);
|
||||
}
|
||||
System.out.println("Pulling " + (drainStack != null ? drainStack.amount : 0) + " from combined leaving " + (this.combinedStorage.getLiquid() != null ? this.combinedStorage.getLiquid().amount : 0));
|
||||
//System.out.println("Pulling " + (drainStack != null ? drainStack.amount : 0) + " from combined leaving " + (this.combinedStorage.getLiquid() != null ? this.combinedStorage.getLiquid().amount : 0));
|
||||
|
||||
}
|
||||
if (prevCombined != null && this.combinedStorage.getLiquid() != null && prevCombined.amount != this.combinedStorage.getLiquid().amount)
|
||||
|
@ -614,7 +616,7 @@ public class HydraulicNetwork
|
|||
{
|
||||
if (node != splitPoint)
|
||||
{
|
||||
newNetwork.getFluidNetworkParts().add((IFluidNetworkPart) node);
|
||||
newNetwork.getFluidNetworkParts().add((IFluidNetworkPart) entity);
|
||||
parts++;
|
||||
}
|
||||
}
|
||||
|
@ -681,7 +683,7 @@ public class HydraulicNetwork
|
|||
|
||||
public String getStorageFluid()
|
||||
{
|
||||
if (combinedStorage.getLiquid() == null)
|
||||
if (!combinedStorage.containsValidLiquid())
|
||||
{
|
||||
return "Zero";
|
||||
}
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
package hydraulic.fluidnetwork;
|
||||
|
||||
|
||||
import hydraulic.api.IDrain;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.liquids.ITankContainer;
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
import universalelectricity.core.vector.VectorHelper;
|
||||
|
||||
|
@ -26,8 +28,14 @@ public class HydraulicNetworkHelper
|
|||
|
||||
if (network != null)
|
||||
{
|
||||
network.removeLoad(tileEntity);
|
||||
network.removeSource(tileEntity);
|
||||
network.removeEntity(tileEntity);
|
||||
for(ITankContainer tank : network.fluidTanks)
|
||||
{
|
||||
if(tank instanceof IDrain)
|
||||
{
|
||||
((IDrain)tank).stopRequesting(tileEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -109,18 +109,20 @@ public abstract class TileEntityFluidStorage extends TileEntityFluidDevice imple
|
|||
{
|
||||
super.readFromNBT(nbt);
|
||||
|
||||
LiquidStack liquid = new LiquidStack(0, 0, 0);
|
||||
liquid.readFromNBT(nbt.getCompoundTag("stored"));
|
||||
tank.setLiquid(liquid);
|
||||
LiquidStack liquid = LiquidStack.loadLiquidStackFromNBT(nbt.getCompoundTag("stored"));
|
||||
if (liquid != null)
|
||||
{
|
||||
tank.setLiquid(liquid);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt)
|
||||
{
|
||||
super.writeToNBT(nbt);
|
||||
if (tank.getLiquid() != null)
|
||||
if (this.tank.containsValidLiquid())
|
||||
{
|
||||
nbt.setTag("stored", tank.getLiquid().writeToNBT(new NBTTagCompound()));
|
||||
nbt.setTag("stored", this.tank.getLiquid().writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue