Search in sources :

Example 1 with TileEntityEnergyStorageClusterMP

use of stevekung.mods.moreplanets.utils.tileentity.TileEntityEnergyStorageClusterMP in project MorePlanets by SteveKunG.

the class BlockTieredEnergyStorageCluster 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 TileEntityEnergyStorageClusterMP) {
        ItemStack machine = new ItemStack(this, 1, 0);
        TileEntityEnergyStorageClusterMP electric = (TileEntityEnergyStorageClusterMP) tile;
        if (electric.getEnergyStoredGC() > 0) {
            machine.setTagCompound(new NBTTagCompound());
            machine.getTagCompound().setFloat("EnergyStored", electric.getEnergyStoredGC());
        }
        Block.spawnAsEntity(world, pos, machine);
    }
}
Also used : TileEntityEnergyStorageClusterMP(stevekung.mods.moreplanets.utils.tileentity.TileEntityEnergyStorageClusterMP) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack)

Example 2 with TileEntityEnergyStorageClusterMP

use of stevekung.mods.moreplanets.utils.tileentity.TileEntityEnergyStorageClusterMP 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;
}
Also used : TileEntityEnergyStorageClusterMP(stevekung.mods.moreplanets.utils.tileentity.TileEntityEnergyStorageClusterMP) TileEntityNuclearWasteGenerator(stevekung.mods.moreplanets.planets.nibiru.tileentity.TileEntityNuclearWasteGenerator) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) TileEntityDarkEnergyCore(stevekung.mods.moreplanets.planets.diona.tileentity.TileEntityDarkEnergyCore) TileEntity(net.minecraft.tileentity.TileEntity) TileEntityNuclearWasteTank(stevekung.mods.moreplanets.planets.nibiru.tileentity.TileEntityNuclearWasteTank) Block(net.minecraft.block.Block) TileEntityDarkEnergyGenerator(stevekung.mods.moreplanets.planets.diona.tileentity.TileEntityDarkEnergyGenerator)

Example 3 with TileEntityEnergyStorageClusterMP

use of stevekung.mods.moreplanets.utils.tileentity.TileEntityEnergyStorageClusterMP 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);
}
Also used : TileEntityEnergyStorageClusterMP(stevekung.mods.moreplanets.utils.tileentity.TileEntityEnergyStorageClusterMP) TileEntityNuclearWasteGenerator(stevekung.mods.moreplanets.planets.nibiru.tileentity.TileEntityNuclearWasteGenerator) TileEntityNuclearWasteTank(stevekung.mods.moreplanets.planets.nibiru.tileentity.TileEntityNuclearWasteTank) BlockPos(net.minecraft.util.math.BlockPos) TileEntityDarkEnergyGenerator(stevekung.mods.moreplanets.planets.diona.tileentity.TileEntityDarkEnergyGenerator)

Example 4 with TileEntityEnergyStorageClusterMP

use of stevekung.mods.moreplanets.utils.tileentity.TileEntityEnergyStorageClusterMP in project MorePlanets by SteveKunG.

the class BlockTieredEnergyStorageCluster method getActualState.

@Override
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) {
    TileEntity tile = world.getTileEntity(pos);
    state = IMachineSides.addPropertyForTile(state, tile, MACHINESIDES_RENDERTYPE, SIDES);
    if (tile instanceof TileEntityEnergyStorageClusterMP) {
        TileEntityEnergyStorageClusterMP storageModule = (TileEntityEnergyStorageClusterMP) tile;
        return state.withProperty(VALUE, storageModule.scaledEnergyLevel);
    } else {
        return state.withProperty(VALUE, 0);
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityEnergyStorageClusterMP(stevekung.mods.moreplanets.utils.tileentity.TileEntityEnergyStorageClusterMP)

Example 5 with TileEntityEnergyStorageClusterMP

use of stevekung.mods.moreplanets.utils.tileentity.TileEntityEnergyStorageClusterMP in project MorePlanets by SteveKunG.

the class BlockTieredEnergyStorageCluster method onBlockPlacedBy.

@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack itemStack) {
    int angle = MathHelper.floor(placer.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
    int change = EnumFacing.byHorizontalIndex(angle).getOpposite().getHorizontalIndex();
    world.setBlockState(pos, this.getStateFromMeta(change), 3);
    if (itemStack.hasTagCompound() && itemStack.getTagCompound().hasKey("EnergyStored")) {
        if (world.getTileEntity(pos) instanceof TileEntityEnergyStorageClusterMP) {
            TileEntityEnergyStorageClusterMP electric = (TileEntityEnergyStorageClusterMP) world.getTileEntity(pos);
            electric.storage.setEnergyStored(itemStack.getTagCompound().getFloat("EnergyStored"));
        }
    }
}
Also used : TileEntityEnergyStorageClusterMP(stevekung.mods.moreplanets.utils.tileentity.TileEntityEnergyStorageClusterMP)

Aggregations

TileEntityEnergyStorageClusterMP (stevekung.mods.moreplanets.utils.tileentity.TileEntityEnergyStorageClusterMP)5 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 TileEntity (net.minecraft.tileentity.TileEntity)2 TileEntityDarkEnergyGenerator (stevekung.mods.moreplanets.planets.diona.tileentity.TileEntityDarkEnergyGenerator)2 TileEntityNuclearWasteGenerator (stevekung.mods.moreplanets.planets.nibiru.tileentity.TileEntityNuclearWasteGenerator)2 TileEntityNuclearWasteTank (stevekung.mods.moreplanets.planets.nibiru.tileentity.TileEntityNuclearWasteTank)2 Block (net.minecraft.block.Block)1 ItemStack (net.minecraft.item.ItemStack)1 BlockPos (net.minecraft.util.math.BlockPos)1 TileEntityDarkEnergyCore (stevekung.mods.moreplanets.planets.diona.tileentity.TileEntityDarkEnergyCore)1