Search in sources :

Example 1 with TileEntityFluidDisplay

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;
}
Also used : IFluidTankProperties(net.minecraftforge.fluids.capability.IFluidTankProperties) IFluidHandlerItem(net.minecraftforge.fluids.capability.IFluidHandlerItem) FluidStack(net.minecraftforge.fluids.FluidStack) ItemStack(net.minecraft.item.ItemStack) TileEntityFluidDisplay(lumien.randomthings.tileentity.TileEntityFluidDisplay)

Example 2 with TileEntityFluidDisplay

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());
}
Also used : IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState) TileEntityFluidDisplay(lumien.randomthings.tileentity.TileEntityFluidDisplay)

Aggregations

TileEntityFluidDisplay (lumien.randomthings.tileentity.TileEntityFluidDisplay)2 ItemStack (net.minecraft.item.ItemStack)1 IExtendedBlockState (net.minecraftforge.common.property.IExtendedBlockState)1 FluidStack (net.minecraftforge.fluids.FluidStack)1 IFluidHandlerItem (net.minecraftforge.fluids.capability.IFluidHandlerItem)1 IFluidTankProperties (net.minecraftforge.fluids.capability.IFluidTankProperties)1