Fix fluids now flowing after being placed

Closes #5
This commit is contained in:
Shadowfacts 2016-12-10 13:48:57 -05:00
parent ed28182ba5
commit cb91c531e4
Signed by: shadowfacts
GPG Key ID: 94A5AB95422746E5
1 changed files with 24 additions and 23 deletions

View File

@ -1,6 +1,8 @@
package net.shadowfacts.funnels;
import net.minecraft.block.Block;
import net.minecraft.block.BlockLiquid;
import net.minecraft.block.state.IBlockState;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
@ -63,8 +65,6 @@ public class TileEntityFunnel extends BaseTileEntity implements ITickable {
}
}
world:
{
tick++;
if (tick % 40 == 0) {
// pickup from world
@ -75,7 +75,7 @@ public class TileEntityFunnel extends BaseTileEntity implements ITickable {
if (toDrain.amount <= tank.getCapacity() - tank.getFluidAmount()) {
tank.fill(FluidUtils.drainFluidBlock(world, pos.up(), true), true);
save();
break world;
return;
}
}
}
@ -84,6 +84,8 @@ public class TileEntityFunnel extends BaseTileEntity implements ITickable {
FluidStack fluid = tank.getFluid();
if (fluid.getFluid().canBePlacedInWorld()) {
Block fluidBlock = fluid.getFluid().getBlock();
if (fluidBlock instanceof BlockLiquid) fluidBlock = BlockLiquid.getFlowingBlock(fluidBlock.getMaterial(fluidBlock.getDefaultState()));
BlockPos newPos = pos.offset(world.getBlockState(pos).getValue(BlockFunnel.FACING));
if (fluidBlock.canPlaceBlockAt(world, newPos)) {
tank.drain(Fluid.BUCKET_VOLUME, true);
@ -95,7 +97,6 @@ public class TileEntityFunnel extends BaseTileEntity implements ITickable {
}
}
}
}
@Override
public void readFromNBT(NBTTagCompound tag) {