Search in sources :

Example 1 with IDarkEnergyFuel

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"));
        }
    }
}
Also used : BlockTileMP(stevekung.mods.moreplanets.utils.blocks.BlockTileMP) TileEntity(net.minecraft.tileentity.TileEntity) NBTTagList(net.minecraft.nbt.NBTTagList) IDescription(stevekung.mods.moreplanets.utils.IDescription) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) TileEntityDarkEnergyGenerator(stevekung.mods.moreplanets.planets.diona.tileentity.TileEntityDarkEnergyGenerator) TileBaseUniversalElectrical(micdoodle8.mods.galacticraft.core.energy.tile.TileBaseUniversalElectrical) ItemStack(net.minecraft.item.ItemStack) IDarkEnergyFuel(stevekung.mods.moreplanets.utils.items.IDarkEnergyFuel) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 2 with IDarkEnergyFuel

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();
}
Also used : ItemStack(net.minecraft.item.ItemStack) IDarkEnergyFuel(stevekung.mods.moreplanets.utils.items.IDarkEnergyFuel)

Aggregations

ItemStack (net.minecraft.item.ItemStack)2 IDarkEnergyFuel (stevekung.mods.moreplanets.utils.items.IDarkEnergyFuel)2 TileBaseUniversalElectrical (micdoodle8.mods.galacticraft.core.energy.tile.TileBaseUniversalElectrical)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 NBTTagList (net.minecraft.nbt.NBTTagList)1 TileEntity (net.minecraft.tileentity.TileEntity)1 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)1 TileEntityDarkEnergyGenerator (stevekung.mods.moreplanets.planets.diona.tileentity.TileEntityDarkEnergyGenerator)1 IDescription (stevekung.mods.moreplanets.utils.IDescription)1 BlockTileMP (stevekung.mods.moreplanets.utils.blocks.BlockTileMP)1