use of stevekung.mods.moreplanets.planets.diona.tileentity.TileEntityDarkEnergyGenerator in project MorePlanets by SteveKunG.
the class ItemBlockDarkEnergyGenerator method addInformation.
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack itemStack, @Nullable World world, List<String> list, ITooltipFlag flag) {
if (this.getBlock() instanceof IDescription) {
if (ClientUtils.isShiftKeyDown()) {
((IDescription) this.block).getDescription().addDescription(itemStack, list);
} else {
if (this.getBlock() instanceof BlockTileMP) {
TileEntity tile = ((BlockTileMP) this.getBlock()).createNewTileEntity(null, 0);
if (tile instanceof TileBaseUniversalElectrical) {
if (itemStack.hasTagCompound() && itemStack.getTagCompound().hasKey("EnergyStored")) {
int power = (int) itemStack.getTagCompound().getFloat("EnergyStored");
list.add(TextFormatting.GREEN + LangUtils.translate("desc.energy_stored.name", EnergyDisplayHelper.getEnergyDisplayS(power)));
}
}
if (tile instanceof TileEntityDarkEnergyGenerator) {
if (itemStack.hasTagCompound() && itemStack.getTagCompound().hasKey("DarkEnergyFuel") && itemStack.getTagCompound().hasKey("Items")) {
int fuelValue = 0;
NBTTagList listTag = itemStack.getTagCompound().getTagList("Items", NBT.TAG_COMPOUND);
for (int i = 0; i < listTag.tagCount(); ++i) {
NBTTagCompound compound = listTag.getCompoundTagAt(i);
int slot = compound.getByte("Slot") & 255;
ItemStack darkEnergyFuel = new ItemStack(compound);
if (slot == 2 && darkEnergyFuel.getItem() instanceof IDarkEnergyFuel) {
IDarkEnergyFuel fuel = (IDarkEnergyFuel) darkEnergyFuel.getItem();
fuelValue = fuel.getDarkEnergyFuel();
}
}
int power = itemStack.getTagCompound().getInteger("DarkEnergyFuel");
power = power * 100 / fuelValue;
list.add(TextFormatting.GREEN + LangUtils.translate("desc.dark_energy_fuel.name", power) + "%");
}
}
}
list.add(LangUtils.translate("desc.shift_info.name"));
}
}
}
use of stevekung.mods.moreplanets.planets.diona.tileentity.TileEntityDarkEnergyGenerator in project MorePlanets by SteveKunG.
the class BlockDarkEnergyGenerator method randomDisplayTick.
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random rand) {
float particlePosX = pos.getX() + 0.5F;
float particlePosY = pos.getY() + 0.0F + rand.nextFloat() * 6.0F / 16.0F;
float particlePosZ = pos.getZ() + 0.5F;
float particleSize0 = 0.52F;
float particleSize1 = rand.nextFloat() * 0.4F - 0.25F;
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileEntityDarkEnergyGenerator) {
TileEntityDarkEnergyGenerator tileEntity = (TileEntityDarkEnergyGenerator) tile;
if (!tileEntity.disabled && tileEntity.darkEnergyFuel > 0) {
for (int i = 0; i < 16; i++) {
if (state.getValue(BlockStateProperty.FACING_HORIZON) == EnumFacing.NORTH || state.getValue(BlockStateProperty.FACING_HORIZON) == EnumFacing.SOUTH) {
world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, particlePosX + particleSize0, particlePosY, particlePosZ + particleSize1, 0.0D, 0.0D, 0.0D);
world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, particlePosX - particleSize0, particlePosY, particlePosZ + particleSize1, 0.0D, 0.0D, 0.0D);
} else {
world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, particlePosX + particleSize1, particlePosY, particlePosZ - particleSize0, 0.0D, 0.0D, 0.0D);
world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, particlePosX + particleSize1, particlePosY, particlePosZ + particleSize0, 0.0D, 0.0D, 0.0D);
}
}
}
}
}
use of stevekung.mods.moreplanets.planets.diona.tileentity.TileEntityDarkEnergyGenerator in project MorePlanets by SteveKunG.
the class BlockDarkEnergyGenerator method harvestBlock.
@Override
public void harvestBlock(World world, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity tile, ItemStack heldStack) {
if (tile instanceof TileEntityDarkEnergyGenerator) {
TileEntityDarkEnergyGenerator electric = (TileEntityDarkEnergyGenerator) tile;
ItemStack itemStack = new ItemStack(this);
NBTTagCompound nbt = new NBTTagCompound();
if (electric.getEnergyStoredGC() > 0) {
nbt.setFloat("EnergyStored", electric.getEnergyStoredGC());
}
if (electric.darkEnergyFuel > 0) {
nbt.setInteger("DarkEnergyFuel", electric.darkEnergyFuel);
}
ItemStackHelper.saveAllItems(nbt, electric.inventory);
itemStack.setTagCompound(nbt);
Block.spawnAsEntity(world, pos, itemStack);
}
}
use of stevekung.mods.moreplanets.planets.diona.tileentity.TileEntityDarkEnergyGenerator 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.diona.tileentity.TileEntityDarkEnergyGenerator 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