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"));
}
}
}
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);
}
}
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() });
}
}
}
}
Aggregations