use of stevekung.mods.moreplanets.planets.nibiru.tileentity.TileEntityNuclearWasteTank in project MorePlanets by SteveKunG.
the class BlockNuclearWasteTank method onBlockPlacedBy.
@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack itemStack) {
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileEntityNuclearWasteTank) {
TileEntityNuclearWasteTank tank = (TileEntityNuclearWasteTank) tile;
tank.onCreate(world, pos);
if (itemStack.hasTagCompound()) {
NBTTagCompound nbt = itemStack.getTagCompound();
tank.rodCreateTime = nbt.getInteger("RodCreateTime");
tank.time = nbt.getInteger("Time");
tank.hasRod = nbt.getBoolean("HasRod");
tank.createRod = nbt.getBoolean("CreateRod");
tank.fluidTank.readFromNBT(nbt.getCompoundTag("FluidTank"));
}
}
}
use of stevekung.mods.moreplanets.planets.nibiru.tileentity.TileEntityNuclearWasteTank in project MorePlanets by SteveKunG.
the class BlockNuclearWasteTank method breakBlock.
@Override
public void breakBlock(World world, BlockPos pos, IBlockState state) {
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileEntityNuclearWasteTank) {
((TileEntityNuclearWasteTank) tile).onDestroy(tile);
}
super.breakBlock(world, pos, state);
}
use of stevekung.mods.moreplanets.planets.nibiru.tileentity.TileEntityNuclearWasteTank in project MorePlanets by SteveKunG.
the class BlockDummy method onNuclearTankActivated.
private boolean onNuclearTankActivated(World world, BlockPos pos, BlockPos detectPos, EntityPlayer player, ItemStack heldStack) {
if (world.getTileEntity(detectPos) instanceof TileEntityNuclearWasteTank && world.getBlockState(detectPos) == MPBlocks.NUCLEAR_WASTE_TANK.getDefaultState()) {
TileEntityNuclearWasteTank tank = (TileEntityNuclearWasteTank) world.getTileEntity(detectPos);
if (!heldStack.isEmpty()) {
if (tank.hasRod && !tank.createRod) {
if (heldStack.getItem() == MPItems.WASTE_ROD_PICKER) {
if (!player.capabilities.isCreativeMode) {
heldStack.damageItem(1, player);
}
Block.spawnAsEntity(world, pos, new ItemStack(MPItems.NUCLEAR_WASTE_ROD));
tank.hasRod = 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 WailaTileEntityProviderMP method getWailaHead.
@Override
public List<String> getWailaHead(ItemStack itemStack, List<String> tooltip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
TileEntity tile = accessor.getTileEntity();
Block block = accessor.getBlock();
NBTTagCompound nbt = accessor.getNBTData();
if (nbt.hasKey("EnergyF") && !(block == MPBlocks.NWT_MIDDLE_DUMMY || block == MPBlocks.NWT_TOP_DUMMY) && !(tile instanceof TileEntityNuclearWasteTank)) {
tooltip.add(TextFormatting.GREEN + LangUtils.translate("gui.message.energy") + ": " + EnergyDisplayHelper.getEnergyDisplayS(nbt.getFloat("EnergyF")));
}
// block
if (block == MPBlocks.DER_SOLAR1_DUMMY || block == MPBlocks.DER_SOLAR2_DUMMY || block == MPBlocks.DER_SOLAR3_DUMMY || block == MPBlocks.DER_SOLAR4_DUMMY) {
int process = nbt.getInteger("ActivatedTick") * 100 / 12000;
int destruct = nbt.getInteger("FailedTick");
if (destruct > 0) {
destruct = 600 - destruct;
tooltip.add(TextFormatting.DARK_RED + LangUtils.translate("gui.status.destruct.name") + ": " + CommonUtils.ticksToElapsedTime(destruct));
} else {
tooltip.add(LangUtils.translate("gui.message.status.name") + ": " + nbt.getString("Status"));
}
if (process > 0 && process < 100) {
tooltip.add("Process: " + process + "%");
}
}
if (block == MPBlocks.WARP_PAD_DUMMY) {
if (tile instanceof TileEntityDummy) {
TileEntityDummy dummy = (TileEntityDummy) tile;
TileEntitySpaceWarpPadFull warp = (TileEntitySpaceWarpPadFull) accessor.getWorld().getTileEntity(dummy.mainBlockPosition);
String dimension = LangUtils.translate("gui.status.unknown.name");
String name = LangUtils.translate("gui.status.unknown.name");
String dest = LangUtils.translate("gui.status.unknown.name");
if (warp.hasWarpCore() && warp.getInventory().get(1).hasTagCompound()) {
NBTTagCompound compound = warp.getInventory().get(1).getTagCompound();
dimension = String.valueOf(compound.getInteger("DimensionID"));
name = WorldUtil.getProviderForDimensionClient(compound.getInteger("DimensionID")).getDimensionType().getName();
dest = compound.getInteger("X") + " " + compound.getInteger("Y") + " " + compound.getInteger("Z");
}
tooltip.add(LangUtils.translate("gui.status.dimension.name") + ": " + dimension + " ");
tooltip.add(LangUtils.translate("gui.status.name.name") + ": " + name);
tooltip.add(LangUtils.translate("gui.status.destination.name") + ": " + dest);
}
}
if (block == MPBlocks.SHIELD_GENERATOR_DUMMY) {
int chargeCooldown = nbt.getInteger("ShieldChargeCooldown");
tooltip.add(LangUtils.translate("gui.message.status.name") + ": " + nbt.getString("Status"));
tooltip.add(LangUtils.translate("gui.status.shield_damage.name") + ": " + nbt.getInteger("ShieldDamage"));
tooltip.add(LangUtils.translate("gui.status.shield_size.name") + ": " + nbt.getInteger("MaxShieldSize"));
tooltip.add(LangUtils.translate("gui.status.shield_capacity.name") + ": " + nbt.getInteger("ShieldCapacity") + "/" + nbt.getInteger("MaxShieldCapacity"));
if (chargeCooldown > 0) {
tooltip.add(LangUtils.translate("gui.status.shield_charge_cooldown.name") + ": " + chargeCooldown / 20);
}
}
if (block == MPBlocks.NWT_MIDDLE_DUMMY || block == MPBlocks.NWT_TOP_DUMMY) {
if (!nbt.getBoolean("HasRod") && !nbt.getBoolean("CreateRod")) {
tooltip.add(LangUtils.translate("gui.status.no_waste_rod"));
}
if (nbt.getCompoundTag("FluidTank").getInteger("Amount") > 0 && nbt.getCompoundTag("FluidTank").getInteger("Amount") < 3000) {
int amount = nbt.getCompoundTag("FluidTank").getInteger("Amount") * 100 / 3000;
tooltip.add(LangUtils.translate("gui.status.has_waste"));
tooltip.add(LangUtils.translate("gui.status.waste_fluid_amount") + ": " + amount + "%");
}
if (nbt.getInteger("Time") > 0 && nbt.getCompoundTag("FluidTank").getInteger("Amount") == 3000) {
int cooldown = nbt.getInteger("RodCreateTime") * 100 / nbt.getInteger("Time");
tooltip.add(LangUtils.translate("gui.status.rod_processing"));
tooltip.add(LangUtils.translate("gui.status.create_rod_progress.name") + ": " + cooldown + "%");
}
}
// tile
if (tile instanceof TileEntityDarkEnergyReceiver) {
int process = nbt.getInteger("ActivatedTick") * 100 / 12000;
int destruct = nbt.getInteger("FailedTick");
if (destruct > 0) {
destruct = 600 - destruct;
tooltip.add(TextFormatting.DARK_RED + LangUtils.translate("gui.status.destruct.name") + ": " + CommonUtils.ticksToElapsedTime(destruct));
} else {
tooltip.add(LangUtils.translate("gui.message.status.name") + ": " + nbt.getString("Status"));
}
if (process > 0 && process < 100) {
tooltip.add(LangUtils.translate("gui.status.process.name") + ": " + process + "%");
}
}
if (tile instanceof TileEntityDarkEnergyCore) {
int transform = nbt.getInteger("ProduceTime");
if (transform > 0) {
tooltip.add(LangUtils.translate("gui.status.transform_time.name") + ": " + CommonUtils.ticksToElapsedTime(transform));
}
}
if (tile instanceof TileEntityDarkEnergyGenerator) {
int generateWatts = nbt.getInteger("GenerateWatts");
int fuel = nbt.getInteger("DarkEnergyFuel");
tooltip.add(LangUtils.translate("gui.message.generating.name") + ": " + (generateWatts > 0 ? EnergyDisplayHelper.getEnergyDisplayS(generateWatts) + "/t" : LangUtils.translate("gui.status.not_generating.name")));
tooltip.add(LangUtils.translate("gui.status.dark_energy_fuel.name") + ": " + (fuel > 0 ? String.valueOf(fuel * 100 / 1000) + "%" : TextFormatting.GOLD + LangUtils.translate("gui.status.empty.name")));
}
if (tile instanceof TileEntitySpaceWarpPadFull) {
TileEntitySpaceWarpPadFull warp = (TileEntitySpaceWarpPadFull) tile;
String dimension = LangUtils.translate("gui.status.unknown.name");
String name = LangUtils.translate("gui.status.unknown.name");
String dest = LangUtils.translate("gui.status.unknown.name");
if (warp.hasWarpCore() && warp.getInventory().get(1).hasTagCompound()) {
NBTTagCompound compound = warp.getInventory().get(1).getTagCompound();
dimension = String.valueOf(compound.getInteger("DimensionID"));
name = WorldUtil.getProviderForDimensionClient(compound.getInteger("DimensionID")).getDimensionType().getName();
dest = compound.getInteger("X") + " " + compound.getInteger("Y") + " " + compound.getInteger("Z");
}
tooltip.add(LangUtils.translate("gui.status.dimension.name") + ": " + dimension + " ");
tooltip.add(LangUtils.translate("gui.status.name.name") + ": " + name);
tooltip.add(LangUtils.translate("gui.status.destination.name") + ": " + dest);
}
if (tile instanceof TileEntityEnergyStorageClusterMP || tile instanceof TileEntityNuclearWasteGenerator) {
tooltip.add(TextFormatting.GREEN + LangUtils.translate("gui.message.max_energy") + ": " + EnergyDisplayHelper.getEnergyDisplayS(nbt.getFloat("MaxEnergy")));
tooltip.add(LangUtils.translate("gui.max_output.desc") + ": " + EnergyDisplayHelper.getEnergyDisplayS(nbt.getFloat("MaxOutput")) + "/t");
if (nbt.hasKey("Status")) {
tooltip.add(LangUtils.translate("gui.message.status.name") + ": " + nbt.getString("Status"));
}
}
if (tile instanceof TileEntityBlackHoleStorage) {
String owner = LangUtils.translate("gui.status.unknown.name");
String collectMode = nbt.getString("CollectMode").equals("item") ? LangUtils.translate("gui.status.collect_item.name") : nbt.getString("CollectMode").equals("item_and_xp") ? LangUtils.translate("gui.status.collect_item_and_xp.name") : LangUtils.translate("gui.status.collect_xp.name");
try {
owner = accessor.getWorld().getPlayerEntityByUUID(UUID.fromString(nbt.getString("OwnerUUID"))).getName();
} catch (Exception e) {
owner = "";
}
int xp = nbt.hasKey("XpFluid", Constants.NBT.TAG_COMPOUND) ? nbt.getCompoundTag("XpFluid").getInteger("Amount") : 0;
tooltip.add(LangUtils.translate("gui.status.owner.name") + ": " + owner);
tooltip.add(LangUtils.translate("gui.status.mode.name") + ": " + collectMode);
tooltip.add(LangUtils.translate("desc.bhs_xp.name") + ": " + xp + "/" + 1000000);
}
if (tile instanceof TileEntityShieldGenerator) {
int chargeCooldown = nbt.getInteger("ShieldChargeCooldown");
tooltip.add(LangUtils.translate("gui.message.status.name") + ": " + nbt.getString("Status"));
tooltip.add(LangUtils.translate("gui.status.shield_damage.name") + ": " + nbt.getInteger("ShieldDamage"));
tooltip.add(LangUtils.translate("gui.status.shield_size.name") + ": " + nbt.getInteger("MaxShieldSize"));
tooltip.add(LangUtils.translate("gui.status.shield_capacity.name") + ": " + nbt.getInteger("ShieldCapacity") + "/" + nbt.getInteger("MaxShieldCapacity"));
if (chargeCooldown > 0) {
tooltip.add(LangUtils.translate("gui.status.shield_charge_cooldown.name") + ": " + chargeCooldown / 20);
}
}
if (tile instanceof TileEntityNuclearWasteTank) {
if (!nbt.getBoolean("HasRod") && !nbt.getBoolean("CreateRod")) {
tooltip.add(LangUtils.translate("gui.status.no_waste_rod"));
}
if (nbt.getCompoundTag("FluidTank").getInteger("Amount") > 0 && nbt.getCompoundTag("FluidTank").getInteger("Amount") < 3000) {
int amount = nbt.getCompoundTag("FluidTank").getInteger("Amount") * 100 / 3000;
tooltip.add(LangUtils.translate("gui.status.has_waste"));
tooltip.add(LangUtils.translate("gui.status.waste_fluid_amount") + ": " + amount + "%");
}
if (nbt.getInteger("Time") > 0 && nbt.getCompoundTag("FluidTank").getInteger("Amount") == 3000) {
int cooldown = nbt.getInteger("RodCreateTime") * 100 / nbt.getInteger("Time");
tooltip.add(LangUtils.translate("gui.status.rod_processing"));
tooltip.add(LangUtils.translate("gui.status.create_rod_progress.name") + ": " + cooldown + "%");
}
}
return tooltip;
}
use of stevekung.mods.moreplanets.planets.nibiru.tileentity.TileEntityNuclearWasteTank in project MorePlanets by SteveKunG.
the class WailaTileEntityProviderMP method getNBTData.
@Override
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity tile, NBTTagCompound nbt, World world, BlockPos pos) {
if (tile instanceof TileEntityDummy) {
TileEntityDummy dummy = (TileEntityDummy) tile;
if (dummy.mainBlockPosition != null) {
BlockPos dummyPos = dummy.mainBlockPosition;
if (world.getTileEntity(dummyPos) instanceof TileEntityDarkEnergyReceiver) {
TileEntityDarkEnergyReceiver receiver = (TileEntityDarkEnergyReceiver) world.getTileEntity(dummy.mainBlockPosition);
nbt.setString("Status", receiver.getGuiStatusWaila());
return receiver.writeToNBT(nbt);
}
if (world.getTileEntity(dummyPos) instanceof TileEntityShieldGenerator) {
TileEntityShieldGenerator shield = (TileEntityShieldGenerator) world.getTileEntity(dummy.mainBlockPosition);
nbt.setString("Status", shield.getStatus());
return shield.writeToNBT(nbt);
}
if (world.getTileEntity(dummyPos) instanceof TileEntityNuclearWasteTank) {
TileEntityNuclearWasteTank tank = (TileEntityNuclearWasteTank) world.getTileEntity(dummy.mainBlockPosition);
return tank.writeToNBT(nbt);
}
if (world.getTileEntity(dummyPos) instanceof TileEntitySpaceWarpPadFull) {
TileEntitySpaceWarpPadFull pad = (TileEntitySpaceWarpPadFull) world.getTileEntity(dummy.mainBlockPosition);
return pad.writeToNBT(nbt);
}
}
}
if (tile instanceof TileEntityDarkEnergyReceiver) {
TileEntityDarkEnergyReceiver receiver = (TileEntityDarkEnergyReceiver) tile;
nbt.setString("Status", receiver.getGuiStatusWaila());
return receiver.writeToNBT(nbt);
}
if (tile instanceof TileEntityDarkEnergyGenerator) {
TileEntityDarkEnergyGenerator generator = (TileEntityDarkEnergyGenerator) tile;
nbt.setInteger("GenerateWatts", generator.generateWatts);
return generator.writeToNBT(nbt);
}
if (tile instanceof TileEntityEnergyStorageClusterMP) {
TileEntityEnergyStorageClusterMP energy = (TileEntityEnergyStorageClusterMP) tile;
nbt.setFloat("MaxEnergy", energy.getMaxEnergyStoredGC());
nbt.setFloat("MaxOutput", energy.storage.getMaxExtract());
return energy.writeToNBT(nbt);
}
if (tile instanceof TileEntityShieldGenerator) {
TileEntityShieldGenerator shield = (TileEntityShieldGenerator) tile;
nbt.setString("Status", shield.getStatus());
return shield.writeToNBT(nbt);
}
if (tile instanceof TileEntityNuclearWasteGenerator) {
TileEntityNuclearWasteGenerator generator = (TileEntityNuclearWasteGenerator) tile;
nbt.setString("Status", generator.getStatus());
nbt.setFloat("MaxEnergy", generator.getMaxEnergyStoredGC());
nbt.setFloat("MaxOutput", generator.storage.getMaxExtract());
return generator.writeToNBT(nbt);
}
if (tile instanceof TileEntityNuclearWasteTank) {
TileEntityNuclearWasteTank tank = (TileEntityNuclearWasteTank) tile;
return tank.writeToNBT(nbt);
}
return tile.writeToNBT(nbt);
}
Aggregations