Search in sources :

Example 6 with TileEntityNuclearWasteTank

use of stevekung.mods.moreplanets.planets.nibiru.tileentity.TileEntityNuclearWasteTank in project MorePlanets by SteveKunG.

the class BlockNuclearWasteTank method onBlockActivated.

@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    ItemStack itemStack = player.getHeldItem(hand);
    TileEntity tile = world.getTileEntity(pos);
    if (tile instanceof TileEntityNuclearWasteTank) {
        TileEntityNuclearWasteTank tank = (TileEntityNuclearWasteTank) tile;
        if (!itemStack.isEmpty()) {
            if (tank.hasRod && !tank.createRod) {
                if (itemStack.getItem() == MPItems.WASTE_ROD_PICKER) {
                    if (!player.capabilities.isCreativeMode) {
                        itemStack.damageItem(1, player);
                    }
                    Block.spawnAsEntity(world, pos, new ItemStack(MPItems.NUCLEAR_WASTE_ROD));
                    tank.hasRod = false;
                    tank.createRod = false;
                    return true;
                }
            } else {
                int slot = player.inventory.currentItem;
                FluidActionResult result = FluidUtil.interactWithFluidHandler(player.inventory.getCurrentItem(), tank.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, null), player);
                if (result.isSuccess()) {
                    tank.createRod = true;
                    tank.setTime();
                    player.inventory.setInventorySlotContents(slot, result.result);
                    if (player.inventoryContainer != null) {
                        player.inventoryContainer.detectAndSendChanges();
                    }
                    return true;
                }
            }
        }
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityNuclearWasteTank(stevekung.mods.moreplanets.planets.nibiru.tileentity.TileEntityNuclearWasteTank) ItemStack(net.minecraft.item.ItemStack) FluidActionResult(net.minecraftforge.fluids.FluidActionResult)

Example 7 with TileEntityNuclearWasteTank

use of stevekung.mods.moreplanets.planets.nibiru.tileentity.TileEntityNuclearWasteTank in project MorePlanets by SteveKunG.

the class BlockNuclearWasteTank method harvestBlock.

@Override
public void harvestBlock(World world, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity tile, ItemStack heldStack) {
    player.addExhaustion(0.025F);
    if (tile instanceof TileEntityNuclearWasteTank) {
        ItemStack machine = new ItemStack(this);
        TileEntityNuclearWasteTank tank = (TileEntityNuclearWasteTank) tile;
        NBTTagCompound nbt = new NBTTagCompound();
        nbt.setInteger("RodCreateTime", tank.rodCreateTime);
        nbt.setInteger("Time", tank.time);
        nbt.setBoolean("HasRod", tank.hasRod);
        nbt.setBoolean("CreateRod", tank.createRod);
        if (tank.fluidTank.getFluid() != null) {
            nbt.setTag("FluidTank", tank.fluidTank.writeToNBT(new NBTTagCompound()));
        }
        if (!tank.hasRod) {
            machine.setTagCompound(nbt);
        }
        Block.spawnAsEntity(world, pos, machine);
    }
}
Also used : TileEntityNuclearWasteTank(stevekung.mods.moreplanets.planets.nibiru.tileentity.TileEntityNuclearWasteTank) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack)

Aggregations

TileEntityNuclearWasteTank (stevekung.mods.moreplanets.planets.nibiru.tileentity.TileEntityNuclearWasteTank)7 TileEntity (net.minecraft.tileentity.TileEntity)4 ItemStack (net.minecraft.item.ItemStack)3 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)3 FluidActionResult (net.minecraftforge.fluids.FluidActionResult)2 TileEntityDarkEnergyGenerator (stevekung.mods.moreplanets.planets.diona.tileentity.TileEntityDarkEnergyGenerator)2 TileEntityNuclearWasteGenerator (stevekung.mods.moreplanets.planets.nibiru.tileentity.TileEntityNuclearWasteGenerator)2 TileEntityEnergyStorageClusterMP (stevekung.mods.moreplanets.utils.tileentity.TileEntityEnergyStorageClusterMP)2 Block (net.minecraft.block.Block)1 BlockPos (net.minecraft.util.math.BlockPos)1 TileEntityDarkEnergyCore (stevekung.mods.moreplanets.planets.diona.tileentity.TileEntityDarkEnergyCore)1