Search in sources :

Example 6 with TileEntityDarkEnergyGenerator

use of stevekung.mods.moreplanets.module.planets.diona.tileentity.TileEntityDarkEnergyGenerator in project MorePlanets by SteveKunG.

the class BlockDarkEnergyGenerator 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.getHorizontal(angle).getOpposite().getHorizontalIndex();
    int direction = 0;
    if (change == 0) {
        direction = 90;
    }
    if (change == 1) {
        direction = 0;
    }
    if (change == 2) {
        direction = -90;
    }
    if (change == 3) {
        direction = -180;
    }
    world.setBlockState(pos, this.getDefaultState().withProperty(BlockStateHelper.FACING_HORIZON, placer.getHorizontalFacing().getOpposite()));
    TileEntity tile = world.getTileEntity(pos);
    if (tile instanceof TileEntityDarkEnergyGenerator) {
        TileEntityDarkEnergyGenerator energy = (TileEntityDarkEnergyGenerator) world.getTileEntity(pos);
        energy.setFacing(direction);
        if (itemStack.hasTagCompound()) {
            NBTTagCompound nbt = itemStack.getTagCompound();
            energy.storage.setEnergyStored(nbt.getFloat("EnergyStored"));
            energy.darkEnergyFuel = nbt.getInteger("DarkEnergyFuel");
            energy.containingItems = NonNullList.withSize(energy.getSizeInventory(), ItemStack.EMPTY);
            ItemStackHelper.loadAllItems(nbt, energy.containingItems);
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) TileEntityDarkEnergyGenerator(stevekung.mods.moreplanets.module.planets.diona.tileentity.TileEntityDarkEnergyGenerator)

Example 7 with TileEntityDarkEnergyGenerator

use of stevekung.mods.moreplanets.module.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 (tileEntity.facing == 90 || tileEntity.facing == -90) {
                    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);
                }
            }
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityDarkEnergyGenerator(stevekung.mods.moreplanets.module.planets.diona.tileentity.TileEntityDarkEnergyGenerator) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 8 with TileEntityDarkEnergyGenerator

use of stevekung.mods.moreplanets.module.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.containingItems);
        itemStack.setTagCompound(nbt);
        Block.spawnAsEntity(world, pos, itemStack);
    }
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) TileEntityDarkEnergyGenerator(stevekung.mods.moreplanets.module.planets.diona.tileentity.TileEntityDarkEnergyGenerator) ItemStack(net.minecraft.item.ItemStack)

Aggregations

TileEntityDarkEnergyGenerator (stevekung.mods.moreplanets.module.planets.diona.tileentity.TileEntityDarkEnergyGenerator)8 TileEntity (net.minecraft.tileentity.TileEntity)6 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)3 TileEntityNuclearWasteGenerator (stevekung.mods.moreplanets.module.planets.nibiru.tileentity.TileEntityNuclearWasteGenerator)3 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)2 BlockAdvancedTile (micdoodle8.mods.galacticraft.core.blocks.BlockAdvancedTile)1 BlockTileGC (micdoodle8.mods.galacticraft.core.blocks.BlockTileGC)1 TileBaseElectricBlock (micdoodle8.mods.galacticraft.core.energy.tile.TileBaseElectricBlock)1 TileBaseUniversalElectrical (micdoodle8.mods.galacticraft.core.energy.tile.TileBaseUniversalElectrical)1 Block (net.minecraft.block.Block)1 IBlockState (net.minecraft.block.state.IBlockState)1 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)1 ItemStack (net.minecraft.item.ItemStack)1 BlockPos (net.minecraft.util.math.BlockPos)1 BlockDummy (stevekung.mods.moreplanets.blocks.BlockDummy)1 ContainerCrashedAlienProbe (stevekung.mods.moreplanets.module.planets.diona.inventory.ContainerCrashedAlienProbe)1 ContainerDarkEnergyGenerator (stevekung.mods.moreplanets.module.planets.diona.inventory.ContainerDarkEnergyGenerator)1 TileEntityCrashedAlienProbe (stevekung.mods.moreplanets.module.planets.diona.tileentity.TileEntityCrashedAlienProbe)1 TileEntityDarkEnergyCore (stevekung.mods.moreplanets.module.planets.diona.tileentity.TileEntityDarkEnergyCore)1 ContainerNuclearWasteGenerator (stevekung.mods.moreplanets.module.planets.nibiru.inventory.ContainerNuclearWasteGenerator)1