use of lumien.randomthings.tileentity.TileEntityFluidDisplay in project Random-Things by lumien231.
the class BlockFluidDisplay method onBlockActivated.
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
TileEntityFluidDisplay te = (TileEntityFluidDisplay) worldIn.getTileEntity(pos);
ItemStack heldItem = playerIn.getHeldItemMainhand();
if (!heldItem.isEmpty() && heldItem.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null)) {
IFluidHandlerItem handler = heldItem.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null);
IFluidTankProperties[] tanks = handler.getTankProperties();
if (tanks.length > 0) {
FluidStack liquid = tanks[0].getContents();
if (liquid != null) {
if (!worldIn.isRemote) {
te.setFluidStack(new FluidStack(liquid.getFluid(), 1000, liquid.tag));
te.syncTE();
}
return true;
}
}
} else {
if (!worldIn.isRemote) {
if (playerIn.isSneaking()) {
te.cycleRotation();
} else {
te.toggleFlowing();
}
}
return true;
}
return false;
}
use of lumien.randomthings.tileentity.TileEntityFluidDisplay in project Random-Things by lumien231.
the class BlockFluidDisplay method getExtendedState.
@Override
public IBlockState getExtendedState(IBlockState state, IBlockAccess worldIn, BlockPos pos) {
TileEntityFluidDisplay te = (TileEntityFluidDisplay) worldIn.getTileEntity(pos);
IExtendedBlockState actualState = (IExtendedBlockState) state;
if (te == null) {
return actualState.withProperty(FLUID, null).withProperty(FLOWING, false);
}
return actualState.withProperty(FLUID, te.getFluidStack()).withProperty(FLOWING, te.flowing()).withProperty(ROTATION, te.getRotation());
}
Aggregations