Search in sources :

Example 1 with TileEntityRocketCrusher

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

the class BlockRocketCrusher 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();
    world.setBlockState(pos, this.getStateFromMeta((this.getMetaFromState(state) & 12) + change), 3);
    if (itemStack.hasTagCompound() && itemStack.getTagCompound().hasKey("EnergyStored")) {
        if (world.getTileEntity(pos) instanceof TileEntityRocketCrusher) {
            TileEntityRocketCrusher electric = (TileEntityRocketCrusher) world.getTileEntity(pos);
            electric.storage.setEnergyStored(itemStack.getTagCompound().getFloat("EnergyStored"));
        }
    }
}
Also used : TileEntityRocketCrusher(stevekung.mods.moreplanets.tileentity.TileEntityRocketCrusher)

Example 2 with TileEntityRocketCrusher

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

the class BlockRocketCrusher method harvestBlock.

@Override
public void harvestBlock(World world, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity tile, ItemStack heldStack) {
    if (tile instanceof TileEntityRocketCrusher) {
        TileEntityRocketCrusher electric = (TileEntityRocketCrusher) tile;
        ItemStack itemStack = new ItemStack(this);
        if (electric.getEnergyStoredGC() > 0) {
            itemStack.setTagCompound(new NBTTagCompound());
            itemStack.getTagCompound().setFloat("EnergyStored", electric.getEnergyStoredGC());
        }
        Block.spawnAsEntity(world, pos, itemStack);
    }
}
Also used : TileEntityRocketCrusher(stevekung.mods.moreplanets.tileentity.TileEntityRocketCrusher) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack)

Example 3 with TileEntityRocketCrusher

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

the class BlockRocketCrusher method randomDisplayTick.

@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random rand) {
    TileEntity tile = world.getTileEntity(pos);
    if (tile instanceof TileEntityRocketCrusher) {
        TileEntityRocketCrusher tileEntity = (TileEntityRocketCrusher) tile;
        ItemStack itemStack = new ItemStack(AsteroidsItems.basicItem, 1, 0);
        if (tileEntity.processTicks > 20) {
            for (int i = 0; i < 2; i++) {
                world.spawnParticle(EnumParticleTypes.ITEM_CRACK, pos.getX() + (double) rand.nextFloat(), pos.getY() + 1.0D, pos.getZ() + (double) rand.nextFloat(), 0.1D * (rand.nextFloat() - 0.5D), 0.2D, (rand.nextFloat() - 0.5D) * 0.1D, new int[] { Item.getIdFromItem(itemStack.getItem()), itemStack.getMetadata() });
            }
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityRocketCrusher(stevekung.mods.moreplanets.tileentity.TileEntityRocketCrusher) ItemStack(net.minecraft.item.ItemStack) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

TileEntityRocketCrusher (stevekung.mods.moreplanets.tileentity.TileEntityRocketCrusher)3 ItemStack (net.minecraft.item.ItemStack)2 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 TileEntity (net.minecraft.tileentity.TileEntity)1 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)1