use of stevekung.mods.moreplanets.utils.items.IDarkEnergyFuel 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.utils.items.IDarkEnergyFuel in project MorePlanets by SteveKunG.
the class TileEntityDarkEnergyGenerator method update.
@Override
public void update() {
super.update();
this.renderTicks++;
if (this.initialize) {
this.renderTicks = this.renderTicks + this.world.rand.nextInt(100);
this.initialize = false;
}
if (!this.world.isRemote) {
this.receiveEnergyGC(null, this.generateWatts, false);
this.recharge(this.getInventory().get(0));
this.recharge(this.getInventory().get(1));
ItemStack darkEnergy = this.getInventory().get(2);
if (!this.disabled) {
if (this.ticks % 20 == 0 && this.darkEnergyFuel > 0) {
this.darkEnergyFuel--;
}
if (!darkEnergy.isEmpty() && this.darkEnergyFuel <= 0) {
if (darkEnergy.getItem() instanceof IDarkEnergyFuel) {
this.darkEnergyFuel = ((IDarkEnergyFuel) darkEnergy.getItem()).getDarkEnergyFuel();
this.prevDarkEnergyFuel = this.darkEnergyFuel;
darkEnergy.shrink(1);
}
}
}
if (this.disableCooldown > 0) {
this.disableCooldown--;
}
if (this.getGenerate() > 0.0F) {
this.ticks = this.ticks + this.world.rand.nextInt(2);
if (this.ticks % 33 == 0) {
this.world.playSound(null, this.getPos(), MPSounds.MACHINE_GENERATOR_AMBIENT, SoundCategory.BLOCKS, 0.05F, 1.0F);
}
this.generateWatts = Math.min(Math.max(this.getGenerate(), 0), 1500);
} else {
this.generateWatts = 0;
}
}
this.produce();
}
Aggregations