Skip to content

Commit

Permalink
Fluidic Plenisher now detects block updates directly below it, and wi…
Browse files Browse the repository at this point in the history
…ll replace the block if necessary. Will also no longer replace other source blocks.
  • Loading branch information
aidancbrady committed Aug 6, 2014
1 parent 9652b7a commit 7a67fbf
Showing 1 changed file with 31 additions and 8 deletions.
39 changes: 31 additions & 8 deletions src/main/java/mekanism/common/tile/TileEntityFluidicPlenisher.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import mekanism.common.util.FluidContainerUtils;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.PipeUtils;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
Expand Down Expand Up @@ -126,11 +127,28 @@ else if(FluidContainerRegistry.isFilledContainer(inventory[0]))
}
}

if(getEnergy() >= Mekanism.fluidicPlenisherUsage && worldObj.getWorldTime() % 10 == 0 && fluidTank.getFluidAmount() >= FluidContainerRegistry.BUCKET_VOLUME && !finishedCalc)
if(getEnergy() >= Mekanism.fluidicPlenisherUsage && worldObj.getWorldTime() % 10 == 0 && fluidTank.getFluidAmount() >= FluidContainerRegistry.BUCKET_VOLUME)
{
if(fluidTank.getFluid().getFluid().canBePlacedInWorld())
{
doPlenish();
if(!finishedCalc)
{
doPlenish();
}
else {
Coord4D below = Coord4D.get(this).getFromSide(ForgeDirection.DOWN);

if(canReplace(below, false) && getEnergy() >= Mekanism.fluidicPlenisherUsage && fluidTank.getFluidAmount() >= FluidContainerRegistry.BUCKET_VOLUME)
{
if(fluidTank.getFluid().getFluid().canBePlacedInWorld())
{
worldObj.setBlock(below.xCoord, below.yCoord, below.zCoord, MekanismUtils.getFlowingBlock(fluidTank.getFluid().getFluid()), 0, 3);

setEnergy(getEnergy() - Mekanism.fluidicPlenisherUsage);
fluidTank.drain(FluidContainerRegistry.BUCKET_VOLUME, true);
}
}
}
}
}
}
Expand All @@ -150,7 +168,7 @@ private void doPlenish()
{
Coord4D below = Coord4D.get(this).getFromSide(ForgeDirection.DOWN);

if(!canReplace(below))
if(!canReplace(below, true))
{
finishedCalc = true;
return;
Expand All @@ -168,7 +186,7 @@ private void doPlenish()

for(Coord4D coord : activeNodes)
{
if(coord.exists(worldObj) && canReplace(coord))
if(coord.exists(worldObj) && canReplace(coord, true))
{
worldObj.setBlock(coord.xCoord, coord.yCoord, coord.zCoord, MekanismUtils.getFlowingBlock(fluidTank.getFluid().getFluid()), 0, 3);

Expand All @@ -179,7 +197,7 @@ private void doPlenish()
{
Coord4D sideCoord = coord.getFromSide(dir);

if(coord.exists(worldObj) && canReplace(coord))
if(coord.exists(worldObj) && canReplace(coord, true))
{
activeNodes.add(sideCoord);
}
Expand All @@ -205,9 +223,9 @@ public int getActiveY()
return yCoord-1;
}

public boolean canReplace(Coord4D coord)
public boolean canReplace(Coord4D coord, boolean checkNodes)
{
if(usedNodes.contains(coord))
if(checkNodes && usedNodes.contains(coord))
{
return false;
}
Expand All @@ -217,6 +235,11 @@ public boolean canReplace(Coord4D coord)
return true;
}

if(MekanismUtils.isFluid(worldObj, coord.xCoord, coord.yCoord, coord.zCoord))
{
return false;
}

return coord.getBlock(worldObj).isReplaceable(worldObj, coord.xCoord, coord.yCoord, coord.zCoord);
}

Expand Down Expand Up @@ -400,7 +423,7 @@ else if(side == 0)
@Override
public FluidTankInfo[] getTankInfo(ForgeDirection direction)
{
if(direction == ForgeDirection.getOrientation(1))
if(direction == ForgeDirection.UP)
{
return new FluidTankInfo[] {fluidTank.getInfo()};
}
Expand Down

0 comments on commit 7a67fbf

Please sign in to comment.