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