Search in sources :

Example 1 with PowerTypes

use of am2.api.power.PowerTypes 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 2 with PowerTypes

use of am2.api.power.PowerTypes 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);
    par3List.add(stack);
    for (PowerTypes type : PowerTypes.all()) {
        stack = new ItemStack(this, 1, type.ID());
        stack.stackTagCompound = new NBTTagCompound();
        stack.stackTagCompound.setFloat("mana_battery_charge", new TileEntityManaBattery().getCapacity());
        stack.stackTagCompound.setInteger("mana_battery_powertype", type.ID());
        par3List.add(stack);
    }
}
Also used : PowerTypes(am2.api.power.PowerTypes) TileEntityManaBattery(am2.blocks.tileentities.TileEntityManaBattery) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Example 3 with PowerTypes

use of am2.api.power.PowerTypes in project ArsMagica2 by Mithion.

the class BlockManaBattery method colorMultiplier.

@Override
public int colorMultiplier(IBlockAccess blockAccess, int x, int y, int z) {
    int metadata = blockAccess.getBlockMetadata(x, y, z);
    PowerTypes type = PowerTypes.getByID(metadata);
    if (type == PowerTypes.DARK)
        return 0x850e0e;
    else if (type == PowerTypes.LIGHT)
        return 0x61cfc3;
    else if (type == PowerTypes.NEUTRAL)
        return 0x2683d2;
    else
        return 0xFFFFFF;
}
Also used : PowerTypes(am2.api.power.PowerTypes)

Example 4 with PowerTypes

use of am2.api.power.PowerTypes in project ArsMagica2 by Mithion.

the class ClientProxy method drawPowerOnBlockHighlight.

@Override
public void drawPowerOnBlockHighlight(EntityPlayer player, MovingObjectPosition target, float partialTicks) {
    if (AMCore.proxy.getLocalPlayer().getCurrentArmor(3) != null && (AMCore.proxy.getLocalPlayer().getCurrentArmor(3).getItem() == ItemsCommonProxy.magitechGoggles || ArmorHelper.isInfusionPreset(AMCore.proxy.getLocalPlayer().getCurrentArmor(3), GenericImbuement.magitechGoggleIntegration))) {
        TileEntity te = player.worldObj.getTileEntity(target.blockX, target.blockY, target.blockZ);
        if (te != null && te instanceof IPowerNode) {
            AMCore.proxy.setTrackedLocation(new AMVector3(target.blockX, target.blockY, target.blockZ));
        } else {
            AMCore.proxy.setTrackedLocation(AMVector3.zero());
        }
        if (AMCore.proxy.hasTrackedLocationSynced()) {
            PowerNodeEntry data = AMCore.proxy.getTrackedData();
            Block block = player.worldObj.getBlock(target.blockX, target.blockY, target.blockZ);
            float yOff = 0.5f;
            if (data != null) {
                GL11.glPushAttrib(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT | GL11.GL_LIGHTING_BIT);
                for (PowerTypes type : ((IPowerNode) te).getValidPowerTypes()) {
                    float pwr = data.getPower(type);
                    float pct = pwr / ((IPowerNode) te).getCapacity() * 100;
                    RenderUtilities.drawTextInWorldAtOffset(String.format("%s%.2f (%.2f%%)", type.chatColor(), pwr, pct), target.blockX - (player.prevPosX - (player.prevPosX - player.posX) * partialTicks) + 0.5f, target.blockY + yOff - (player.prevPosY - (player.prevPosY - player.posY) * partialTicks) + block.getBlockBoundsMaxY() * 0.8f, target.blockZ - (player.prevPosZ - (player.prevPosZ - player.posZ) * partialTicks) + 0.5f, 0xFFFFFF);
                    yOff += 0.12f;
                }
                GL11.glPopAttrib();
            }
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) AMVector3(am2.api.math.AMVector3) PowerTypes(am2.api.power.PowerTypes) Block(net.minecraft.block.Block) PowerNodeEntry(am2.power.PowerNodeEntry) IPowerNode(am2.api.power.IPowerNode)

Example 5 with PowerTypes

use of am2.api.power.PowerTypes in project ArsMagica2 by Mithion.

the class SpellRecipeManager method ParseEssenceIDs.

public static int[] ParseEssenceIDs(String s) {
    if (s.toLowerCase().equals("e:*")) {
        int[] all = new int[PowerTypes.all().length];
        int count = 0;
        for (PowerTypes type : PowerTypes.all()) {
            all[count++] = type.ID();
        }
        return all;
    }
    s = s.toLowerCase().replace("e:", "");
    String[] split = s.split("\\|");
    int[] ids = new int[split.length];
    for (int i = 0; i < split.length; ++i) {
        try {
            ids[i] = Integer.parseInt(split[i]);
        } catch (NumberFormatException nex) {
            LogHelper.warn("Invalid power type ID while parsing value %s", s);
            ids[i] = 0;
        }
    }
    return ids;
}
Also used : PowerTypes(am2.api.power.PowerTypes)

Aggregations

PowerTypes (am2.api.power.PowerTypes)18 AMVector3 (am2.api.math.AMVector3)8 IPowerNode (am2.api.power.IPowerNode)6 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)6 TileEntity (net.minecraft.tileentity.TileEntity)5 ItemStack (net.minecraft.item.ItemStack)4 LinkedList (java.util.LinkedList)3 Block (net.minecraft.block.Block)3 NBTTagList (net.minecraft.nbt.NBTTagList)3 NBTTagString (net.minecraft.nbt.NBTTagString)3 TileEntityManaBattery (am2.blocks.tileentities.TileEntityManaBattery)2 PowerNodeEntry (am2.power.PowerNodeEntry)2 ArrayList (java.util.ArrayList)2 ItemBlock (net.minecraft.item.ItemBlock)2 SpellRecipeItemsEvent (am2.api.events.SpellRecipeItemsEvent)1 Affinity (am2.api.spell.enums.Affinity)1 EntityDummyCaster (am2.entities.EntityDummyCaster)1 AMLineArc (am2.particles.AMLineArc)1 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)1 SideOnly (cpw.mods.fml.relauncher.SideOnly)1