Fixed drain fighting itself
Though that i could just let the drain do both fill/drain at the same time. However, i did think the drain would try to self feed liquid into itself. Should be fixed now by re-adding the meta sensitive canDrain
This commit is contained in:
parent
eccb1aea7c
commit
391c54f968
2 changed files with 78 additions and 19 deletions
|
@ -53,7 +53,19 @@ public class BlockDrain extends BlockFM
|
||||||
ForgeDirection dir = ForgeDirection.getOrientation(side);
|
ForgeDirection dir = ForgeDirection.getOrientation(side);
|
||||||
if (entity instanceof TileEntityDrain)
|
if (entity instanceof TileEntityDrain)
|
||||||
{
|
{
|
||||||
return this.drainIcon;
|
|
||||||
|
if (dir == ((TileEntityDrain) entity).getDirection())
|
||||||
|
{
|
||||||
|
if (((TileEntityDrain) entity).canDrain())
|
||||||
|
{
|
||||||
|
return this.drainIcon;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return this.fillIcon;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return this.blockIcon;
|
return this.blockIcon;
|
||||||
}
|
}
|
||||||
|
@ -66,11 +78,41 @@ public class BlockDrain extends BlockFM
|
||||||
TileEntity entity = world.getBlockTileEntity(x, y, z);
|
TileEntity entity = world.getBlockTileEntity(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean onSneakUseWrench(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ)
|
||||||
|
{
|
||||||
|
if (!world.isRemote)
|
||||||
|
{
|
||||||
|
int meta = world.getBlockMetadata(x, y, z);
|
||||||
|
if (world.getBlockMetadata(x, y, z) < 6)
|
||||||
|
{
|
||||||
|
meta += 6;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
meta -= 6;
|
||||||
|
}
|
||||||
|
world.setBlockMetadataWithNotify(x, y, z, meta, 3);
|
||||||
|
TileEntity entity = world.getBlockTileEntity(x, y, z);
|
||||||
|
if (entity instanceof TileEntityDrain)
|
||||||
|
{
|
||||||
|
entityPlayer.sendChatToPlayer(ChatMessageComponent.func_111066_d("Draining Sources? " + ((TileEntityDrain) entity).canDrain()));
|
||||||
|
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean onUseWrench(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ)
|
public boolean onUseWrench(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ)
|
||||||
{
|
{
|
||||||
if (!world.isRemote)
|
if (!world.isRemote)
|
||||||
{
|
{
|
||||||
world.setBlockMetadataWithNotify(x, y, z, side, 3);
|
int meta = side;
|
||||||
|
if (world.getBlockMetadata(x, y, z) > 5)
|
||||||
|
{
|
||||||
|
meta += 6;
|
||||||
|
}
|
||||||
|
world.setBlockMetadataWithNotify(x, y, z, meta, 3);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -6,6 +6,7 @@ import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
import net.minecraftforge.common.ForgeDirection;
|
||||||
import net.minecraftforge.fluids.Fluid;
|
import net.minecraftforge.fluids.Fluid;
|
||||||
|
@ -15,6 +16,7 @@ import net.minecraftforge.fluids.FluidTank;
|
||||||
import net.minecraftforge.fluids.FluidTankInfo;
|
import net.minecraftforge.fluids.FluidTankInfo;
|
||||||
import net.minecraftforge.fluids.IFluidHandler;
|
import net.minecraftforge.fluids.IFluidHandler;
|
||||||
import universalelectricity.core.vector.Vector3;
|
import universalelectricity.core.vector.Vector3;
|
||||||
|
import dark.api.IToolReadOut.EnumTools;
|
||||||
import dark.api.fluid.IDrain;
|
import dark.api.fluid.IDrain;
|
||||||
import dark.core.helpers.FluidHelper;
|
import dark.core.helpers.FluidHelper;
|
||||||
import dark.core.helpers.Pair;
|
import dark.core.helpers.Pair;
|
||||||
|
@ -33,6 +35,11 @@ public class TileEntityDrain extends TileEntityFluidDevice implements IFluidHand
|
||||||
private LiquidPathFinder pathDrain;
|
private LiquidPathFinder pathDrain;
|
||||||
private LiquidPathFinder pathFill;
|
private LiquidPathFinder pathFill;
|
||||||
|
|
||||||
|
public boolean canDrain()
|
||||||
|
{
|
||||||
|
return this.getBlockMetadata() < 6;
|
||||||
|
}
|
||||||
|
|
||||||
public LiquidPathFinder getFillFinder()
|
public LiquidPathFinder getFillFinder()
|
||||||
{
|
{
|
||||||
if (pathFill == null)
|
if (pathFill == null)
|
||||||
|
@ -45,7 +52,7 @@ public class TileEntityDrain extends TileEntityFluidDevice implements IFluidHand
|
||||||
@Override
|
@Override
|
||||||
public Set<Vector3> getFillList()
|
public Set<Vector3> getFillList()
|
||||||
{
|
{
|
||||||
return this.getLiquidFinder().refresh().results;
|
return this.getFillFinder().refresh().results;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LiquidPathFinder getLiquidFinder()
|
public LiquidPathFinder getLiquidFinder()
|
||||||
|
@ -60,7 +67,7 @@ public class TileEntityDrain extends TileEntityFluidDevice implements IFluidHand
|
||||||
@Override
|
@Override
|
||||||
public Set<Vector3> getFluidList()
|
public Set<Vector3> getFluidList()
|
||||||
{
|
{
|
||||||
return this.getFillFinder().refresh().results;
|
return this.getLiquidFinder().refresh().results;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -79,11 +86,6 @@ public class TileEntityDrain extends TileEntityFluidDevice implements IFluidHand
|
||||||
this.getLiquidFinder().refresh().start(new Vector3(this).modifyPositionFromSide(this.getDirection()), false);
|
this.getLiquidFinder().refresh().start(new Vector3(this).modifyPositionFromSide(this.getDirection()), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.getFillFinder().results.size() < TileEntityDrain.MAX_WORLD_EDITS_PER_PROCESS + 10)
|
|
||||||
{
|
|
||||||
this.getFillFinder().refresh().start(new Vector3(this).modifyPositionFromSide(this.getDirection()), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,15 +101,20 @@ public class TileEntityDrain extends TileEntityFluidDevice implements IFluidHand
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.getFillFinder().results.size() < TileEntityDrain.MAX_WORLD_EDITS_PER_PROCESS + 10)
|
||||||
|
{
|
||||||
|
this.getFillFinder().refresh().start(new Vector3(this).modifyPositionFromSide(this.getDirection()), true);
|
||||||
|
}
|
||||||
|
|
||||||
fillVolume = resource.amount;
|
fillVolume = resource.amount;
|
||||||
|
|
||||||
System.out.println("Drain>>FillArea>>Targets>> " + getLiquidFinder().results.size());
|
System.out.println("Drain>>FillArea>>Targets>> " + getFillFinder().results.size());
|
||||||
|
|
||||||
List<Vector3> fluids = new ArrayList<Vector3>();
|
List<Vector3> fluids = new ArrayList<Vector3>();
|
||||||
List<Vector3> blocks = new ArrayList<Vector3>();
|
List<Vector3> blocks = new ArrayList<Vector3>();
|
||||||
List<Vector3> drained = new ArrayList<Vector3>();
|
List<Vector3> filled = new ArrayList<Vector3>();
|
||||||
/* Sort results out into two groups and clear the rest out of the result list */
|
/* Sort results out into two groups and clear the rest out of the result list */
|
||||||
Iterator<Vector3> it = this.getLiquidFinder().results.iterator();
|
Iterator<Vector3> it = this.getFillFinder().refresh().results.iterator();
|
||||||
while (it.hasNext())
|
while (it.hasNext())
|
||||||
{
|
{
|
||||||
Vector3 vec = it.next();
|
Vector3 vec = it.next();
|
||||||
|
@ -139,7 +146,7 @@ public class TileEntityDrain extends TileEntityFluidDevice implements IFluidHand
|
||||||
|
|
||||||
if (doFill)
|
if (doFill)
|
||||||
{
|
{
|
||||||
drained.add(loc);
|
filled.add(loc);
|
||||||
this.currentWorldEdits++;
|
this.currentWorldEdits++;
|
||||||
if (!this.updateQue.contains(loc))
|
if (!this.updateQue.contains(loc))
|
||||||
{
|
{
|
||||||
|
@ -164,7 +171,7 @@ public class TileEntityDrain extends TileEntityFluidDevice implements IFluidHand
|
||||||
|
|
||||||
if (doFill)
|
if (doFill)
|
||||||
{
|
{
|
||||||
drained.add(loc);
|
filled.add(loc);
|
||||||
this.currentWorldEdits++;
|
this.currentWorldEdits++;
|
||||||
if (!this.updateQue.contains(loc))
|
if (!this.updateQue.contains(loc))
|
||||||
{
|
{
|
||||||
|
@ -174,7 +181,7 @@ public class TileEntityDrain extends TileEntityFluidDevice implements IFluidHand
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.getLiquidFinder().results.removeAll(drained);
|
this.getLiquidFinder().results.removeAll(filled);
|
||||||
System.out.println("Drain>>FillArea>>Filling>>Filled>>" + (doFill ? "" : "Sim>>") + (resource.amount - fillVolume) + "mb");
|
System.out.println("Drain>>FillArea>>Filling>>Filled>>" + (doFill ? "" : "Sim>>") + (resource.amount - fillVolume) + "mb");
|
||||||
return Math.max(resource.amount - fillVolume, 0);
|
return Math.max(resource.amount - fillVolume, 0);
|
||||||
}
|
}
|
||||||
|
@ -209,13 +216,13 @@ public class TileEntityDrain extends TileEntityFluidDevice implements IFluidHand
|
||||||
@Override
|
@Override
|
||||||
public boolean canFill(ForgeDirection from, Fluid fluid)
|
public boolean canFill(ForgeDirection from, Fluid fluid)
|
||||||
{
|
{
|
||||||
return this.getDirection() != from;
|
return this.getDirection() != from && !this.canDrain();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill)
|
public int fill(ForgeDirection from, FluidStack resource, boolean doFill)
|
||||||
{
|
{
|
||||||
if (resource == null)
|
if (resource == null || this.canDrain())
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -250,13 +257,13 @@ public class TileEntityDrain extends TileEntityFluidDevice implements IFluidHand
|
||||||
@Override
|
@Override
|
||||||
public boolean canDrain(ForgeDirection direction)
|
public boolean canDrain(ForgeDirection direction)
|
||||||
{
|
{
|
||||||
return direction == this.getDirection() && !this.worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord);
|
return direction == this.getDirection() && !this.worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord) && this.canDrain();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canFill(ForgeDirection direction)
|
public boolean canFill(ForgeDirection direction)
|
||||||
{
|
{
|
||||||
return this.canDrain(direction);
|
return direction == this.getDirection() && !this.worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord) && !this.canDrain();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -265,4 +272,14 @@ public class TileEntityDrain extends TileEntityFluidDevice implements IFluidHand
|
||||||
this.currentWorldEdits++;
|
this.currentWorldEdits++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getMeterReading(EntityPlayer user, ForgeDirection side, EnumTools tool)
|
||||||
|
{
|
||||||
|
if (tool != null && tool == EnumTools.PIPE_GUAGE)
|
||||||
|
{
|
||||||
|
return " F:" + this.getFillList().size() + " D:" + this.getFluidList().size();
|
||||||
|
}
|
||||||
|
return super.getMeterReading(user, side, tool);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue