use of am2.blocks.tileentities.TileEntityManaBattery in project ArsMagica2 by Mithion.
the class SimpleBlockRenderHandler method renderManaBattery.
private void renderManaBattery(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
GL11.glColor4f(1, 1, 1, 1);
TileEntityManaBattery te = (TileEntityManaBattery) world.getTileEntity(x, y, z);
if (te != null) {
IBlockAccess old = renderer.blockAccess;
renderer.blockAccess = this.blockAccess;
this.blockAccess.setControllingTileEntity(te);
this.blockAccess.setFakeBlockAndMeta(BlocksCommonProxy.manaBattery, 0);
this.blockAccess.setOuterBlockAccess(world);
this.blockAccess.setOverrideCoords(x, y, z);
renderer.renderStandardBlock(BlocksCommonProxy.manaBattery, x, y, z);
this.blockAccess.setOuterBlockAccess(null);
renderer.blockAccess = old;
Tessellator.instance.setColorOpaque_I(0xFFFFFF);
renderer.renderFaceYPos(block, x, y, z, BlocksCommonProxy.manaBattery.getIcon(1, 15));
renderer.renderFaceYNeg(block, x, y, z, BlocksCommonProxy.manaBattery.getIcon(0, 15));
renderer.renderFaceXPos(block, x, y, z, BlocksCommonProxy.manaBattery.getIcon(2, 15));
renderer.renderFaceXNeg(block, x, y, z, BlocksCommonProxy.manaBattery.getIcon(3, 15));
renderer.renderFaceZPos(block, x, y, z, BlocksCommonProxy.manaBattery.getIcon(4, 15));
renderer.renderFaceZNeg(block, x, y, z, BlocksCommonProxy.manaBattery.getIcon(5, 15));
}
}
use of am2.blocks.tileentities.TileEntityManaBattery in project ArsMagica2 by Mithion.
the class BlockManaBattery method getSubBlocks.
@Override
@SideOnly(Side.CLIENT)
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) {
ItemStack stack = new ItemStack(this);
stack.stackTagCompound = new NBTTagCompound();
stack.stackTagCompound.setFloat("mana_battery_charge", new TileEntityManaBattery().getCapacity());
par3List.add(stack);
}
use of am2.blocks.tileentities.TileEntityManaBattery in project ArsMagica2 by Mithion.
the class BlockManaBattery method destroy.
private void destroy(World world, int i, int j, int k) {
TileEntityManaBattery te = getTileEntity(world, i, j, k);
if (te != null && !world.isRemote) {
float f = world.rand.nextFloat() * 0.8F + 0.1F;
float f1 = world.rand.nextFloat() * 0.8F + 0.1F;
float f2 = world.rand.nextFloat() * 0.8F + 0.1F;
int dmg = (int) ((PowerNodeRegistry.For(world).getPower(te, te.getPowerType()) / te.getCapacity()) * 100);
if (dmg == 0)
dmg = 1;
ItemStack stack = new ItemStack(this);
stack.damageItem(stack.getMaxDamage() - dmg, new EntityDummyCaster(world));
stack.stackTagCompound = new NBTTagCompound();
stack.stackTagCompound.setFloat("mana_battery_charge", PowerNodeRegistry.For(world).getPower(te, te.getPowerType()));
stack.stackTagCompound.setInteger("mana_battery_powertype", te.getPowerType().ID());
if (!stack.stackTagCompound.hasKey("Lore"))
stack.stackTagCompound.setTag("Lore", new NBTTagList());
NBTTagList tagList = new NBTTagList();
PowerTypes powerType = te.getPowerType();
float amt = PowerNodeRegistry.For(world).getPower(te, powerType);
tagList.appendTag(new NBTTagString(String.format("Contains %.2f %s%s etherium", amt, powerType.chatColor(), powerType.name())));
stack.stackTagCompound.setTag("Lore", tagList);
EntityItem entityitem = new EntityItem(world, i + f, j + f1, k + f2, stack);
float f3 = 0.05F;
entityitem.motionX = (float) world.rand.nextGaussian() * f3;
entityitem.motionY = (float) world.rand.nextGaussian() * f3 + 0.2F;
entityitem.motionZ = (float) world.rand.nextGaussian() * f3;
world.spawnEntityInWorld(entityitem);
}
}
use of am2.blocks.tileentities.TileEntityManaBattery in project ArsMagica2 by Mithion.
the class BlockManaBattery method getComparatorInputOverride.
@Override
public int getComparatorInputOverride(World world, int x, int y, int z, int meta) {
TileEntityManaBattery batt = getTileEntity(world, x, y, z);
if (batt == null)
return 0;
//can simply use getHighest, as batteries can only have *one* type.
//the only time they have more, is when they are at zero, but then it doesn't matter
//as all power types are zero.
//Once they get power a single time, they lock to that power type.
float pct = PowerNodeRegistry.For(world).getHighestPower(batt) / batt.getCapacity();
return (int) Math.floor(15.0f * pct);
}
Aggregations