Fix some pretty severe plenisher problems that must have gone a while relatively unnoticed.

This commit is contained in:
Ben Spiers 2014-08-28 03:12:58 +01:00
parent 40c06f1004
commit dd3ae67750
2 changed files with 35 additions and 36 deletions

View file

@ -60,18 +60,21 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen
if(inventory[0] != null)
{
if(inventory[0].getItem() instanceof IFluidContainerItem)
if(inventory[0].getItem() instanceof IFluidContainerItem && ((IFluidContainerItem)inventory[0].getItem()).getFluid(inventory[0]) != null)
{
fluidTank.fill(FluidContainerUtils.extractFluid(fluidTank, inventory[0]), true);
if(((IFluidContainerItem)inventory[0].getItem()).getFluid(inventory[0]) == null || fluidTank.getFluidAmount() == fluidTank.getCapacity())
if(((IFluidContainerItem)inventory[0].getItem()).getFluid(inventory[0]).getFluid().canBePlacedInWorld())
{
if(inventory[1] == null)
fluidTank.fill(FluidContainerUtils.extractFluid(fluidTank, inventory[0]), true);
if(((IFluidContainerItem) inventory[0].getItem()).getFluid(inventory[0]) == null || fluidTank.getFluidAmount() == fluidTank.getCapacity())
{
inventory[1] = inventory[0].copy();
inventory[0] = null;
markDirty();
if(inventory[1] == null)
{
inventory[1] = inventory[0].copy();
inventory[0] = null;
markDirty();
}
}
}
}
@ -81,7 +84,7 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen
if((fluidTank.getFluid() == null && itemFluid.amount <= fluidTank.getCapacity()) || fluidTank.getFluid().amount+itemFluid.amount <= fluidTank.getCapacity())
{
if(fluidTank.getFluid() != null && !fluidTank.getFluid().isFluidEqual(itemFluid))
if((fluidTank.getFluid() != null && !fluidTank.getFluid().isFluidEqual(itemFluid)) || !itemFluid.getFluid().canBePlacedInWorld())
{
return;
}
@ -138,7 +141,7 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen
else {
Coord4D below = Coord4D.get(this).getFromSide(ForgeDirection.DOWN);
if(canReplace(below, false) && getEnergy() >= Mekanism.fluidicPlenisherUsage && fluidTank.getFluidAmount() >= FluidContainerRegistry.BUCKET_VOLUME)
if(canReplace(below, false, false) && getEnergy() >= Mekanism.fluidicPlenisherUsage && fluidTank.getFluidAmount() >= FluidContainerRegistry.BUCKET_VOLUME)
{
if(fluidTank.getFluid().getFluid().canBePlacedInWorld())
{
@ -168,12 +171,12 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen
{
Coord4D below = Coord4D.get(this).getFromSide(ForgeDirection.DOWN);
if(!canReplace(below, true))
if(!canReplace(below, true, true))
{
finishedCalc = true;
return;
}
activeNodes.add(below);
}
else {
@ -186,18 +189,22 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen
for(Coord4D coord : activeNodes)
{
if(coord.exists(worldObj) && canReplace(coord, true))
if(coord.exists(worldObj))
{
worldObj.setBlock(coord.xCoord, coord.yCoord, coord.zCoord, MekanismUtils.getFlowingBlock(fluidTank.getFluid().getFluid()), 0, 3);
setEnergy(getEnergy() - Mekanism.fluidicPlenisherUsage);
fluidTank.drain(FluidContainerRegistry.BUCKET_VOLUME, true);
if(canReplace(coord, true, false))
{
worldObj.setBlock(coord.xCoord, coord.yCoord, coord.zCoord, MekanismUtils.getFlowingBlock(fluidTank.getFluid().getFluid()), 0, 3);
setEnergy(getEnergy() - Mekanism.fluidicPlenisherUsage);
fluidTank.drain(FluidContainerRegistry.BUCKET_VOLUME, true);
}
for(ForgeDirection dir : dirs)
{
Coord4D sideCoord = coord.getFromSide(dir);
if(coord.exists(worldObj) && canReplace(coord, true))
if(sideCoord.exists(worldObj) && canReplace(sideCoord, true, true))
{
activeNodes.add(sideCoord);
}
@ -223,7 +230,7 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen
return yCoord-1;
}
public boolean canReplace(Coord4D coord, boolean checkNodes)
public boolean canReplace(Coord4D coord, boolean checkNodes, boolean isPathfinding)
{
if(checkNodes && usedNodes.contains(coord))
{
@ -237,7 +244,7 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen
if(MekanismUtils.isFluid(worldObj, coord.xCoord, coord.yCoord, coord.zCoord))
{
return false;
return isPathfinding;
}
return coord.getBlock(worldObj).isReplaceable(worldObj, coord.xCoord, coord.yCoord, coord.zCoord);
@ -281,11 +288,6 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen
return data;
}
public int getScaledFluidLevel(int i)
{
return fluidTank.getFluid() != null ? fluidTank.getFluid().amount*i / 10000 : 0;
}
@Override
public void writeToNBT(NBTTagCompound nbtTags)
{
@ -452,7 +454,7 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen
@Override
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain)
{
if(fluidTank.getFluid() != null && fluidTank.getFluid().getFluid() == resource.getFluid() && from == ForgeDirection.getOrientation(1))
if(fluidTank.getFluid() != null && fluidTank.getFluid().getFluid() == resource.getFluid() && from == ForgeDirection.UP)
{
return drain(from, resource.amount, doDrain);
}
@ -463,7 +465,7 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen
@Override
public int fill(ForgeDirection from, FluidStack resource, boolean doFill)
{
if(from == ForgeDirection.UP)
if(from == ForgeDirection.UP && resource.getFluid().canBePlacedInWorld())
{
return fluidTank.fill(resource, true);
}
@ -480,7 +482,7 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen
@Override
public boolean canFill(ForgeDirection from, Fluid fluid)
{
return from == ForgeDirection.UP;
return from == ForgeDirection.UP && fluid.canBePlacedInWorld();
}
@Override

View file

@ -818,25 +818,22 @@ public final class MekanismUtils
Block block = world.getBlock(x, y, z);
int meta = world.getBlockMetadata(x, y, z);
if(block == null)
if(block == null || meta == 0)
{
return false;
}
if((block == Blocks.water || block == Blocks.flowing_water) && meta != 0)
if((block == Blocks.water || block == Blocks.flowing_water))
{
return true;
}
else if((block == Blocks.lava || block == Blocks.flowing_lava) && meta != 0)
else if((block == Blocks.lava || block == Blocks.flowing_lava))
{
return true;
}
else if(block instanceof IFluidBlock)
{
if(meta != 0)
{
return true;
}
return true;
}
return false;