Search in sources :

Example 16 with PowerTypes

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

the class TileEntityManaBattery method updateEntity.

@Override
public void updateEntity() {
    if (worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)) {
        this.setPowerRequests();
    } else {
        this.setNoPowerRequests();
    }
    if (this.outputPowerType == PowerTypes.NONE && !this.worldObj.isRemote) {
        PowerTypes highest = PowerNodeRegistry.For(worldObj).getHighestPowerType(this);
        float amt = PowerNodeRegistry.For(worldObj).getPower(this, highest);
        if (amt > 0) {
            this.outputPowerType = highest;
            worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
        }
    }
    tickCounter++;
    if (tickCounter % 600 == 0) {
        worldObj.notifyBlockChange(xCoord, yCoord, zCoord, BlocksCommonProxy.manaBattery);
        tickCounter = 0;
    }
    super.updateEntity();
}
Also used : PowerTypes(am2.api.power.PowerTypes)

Example 17 with PowerTypes

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

the class ItemSpellStaff method onItemUseFirst.

@Override
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
    if (isMagiTechStaff()) {
        if (!world.isRemote) {
            TileEntity te = world.getTileEntity(x, y, z);
            if (te != null && te instanceof IPowerNode) {
                if (player.isSneaking()) {
                    AMNetHandler.INSTANCE.syncPowerPaths((IPowerNode) te, (EntityPlayerMP) player);
                } else {
                    PowerTypes[] types = ((IPowerNode) te).getValidPowerTypes();
                    for (PowerTypes type : types) {
                        float power = PowerNodeRegistry.For(world).getPower((IPowerNode) te, type);
                        player.addChatMessage(new ChatComponentText(String.format(StatCollector.translateToLocal("am2.tooltip.det_eth"), type.chatColor(), type.name(), String.format("%.2f", power))));
                    }
                }
                return true;
            }
        }
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) PowerTypes(am2.api.power.PowerTypes) ChatComponentText(net.minecraft.util.ChatComponentText) IPowerNode(am2.api.power.IPowerNode)

Aggregations

PowerTypes (am2.api.power.PowerTypes)15 AMVector3 (am2.api.math.AMVector3)8 IPowerNode (am2.api.power.IPowerNode)6 TileEntity (net.minecraft.tileentity.TileEntity)5 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)4 LinkedList (java.util.LinkedList)3 Block (net.minecraft.block.Block)3 NBTTagList (net.minecraft.nbt.NBTTagList)3 PowerNodeEntry (am2.power.PowerNodeEntry)2 ArrayList (java.util.ArrayList)2 ItemStack (net.minecraft.item.ItemStack)2 NBTTagString (net.minecraft.nbt.NBTTagString)2 SpellRecipeItemsEvent (am2.api.events.SpellRecipeItemsEvent)1 Affinity (am2.api.spell.enums.Affinity)1 TileEntityManaBattery (am2.blocks.tileentities.TileEntityManaBattery)1 EntityDummyCaster (am2.entities.EntityDummyCaster)1 AMLineArc (am2.particles.AMLineArc)1 EntityItem (net.minecraft.entity.item.EntityItem)1 Item (net.minecraft.item.Item)1 ItemBlock (net.minecraft.item.ItemBlock)1