Search in sources :

Example 1 with TileEntityManaBattery

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));
    }
}
Also used : TileEntityManaBattery(am2.blocks.tileentities.TileEntityManaBattery) IBlockAccess(net.minecraft.world.IBlockAccess)

Example 2 with TileEntityManaBattery

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);
}
Also used : TileEntityManaBattery(am2.blocks.tileentities.TileEntityManaBattery) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Example 3 with TileEntityManaBattery

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);
    }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) PowerTypes(am2.api.power.PowerTypes) EntityDummyCaster(am2.entities.EntityDummyCaster) TileEntityManaBattery(am2.blocks.tileentities.TileEntityManaBattery) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) NBTTagString(net.minecraft.nbt.NBTTagString) ItemStack(net.minecraft.item.ItemStack) EntityItem(net.minecraft.entity.item.EntityItem)

Example 4 with TileEntityManaBattery

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);
}
Also used : TileEntityManaBattery(am2.blocks.tileentities.TileEntityManaBattery)

Aggregations

TileEntityManaBattery (am2.blocks.tileentities.TileEntityManaBattery)4 ItemStack (net.minecraft.item.ItemStack)2 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 PowerTypes (am2.api.power.PowerTypes)1 EntityDummyCaster (am2.entities.EntityDummyCaster)1 SideOnly (cpw.mods.fml.relauncher.SideOnly)1 EntityItem (net.minecraft.entity.item.EntityItem)1 NBTTagList (net.minecraft.nbt.NBTTagList)1 NBTTagString (net.minecraft.nbt.NBTTagString)1 IBlockAccess (net.minecraft.world.IBlockAccess)1