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;
}
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);
}
}
Aggregations