Search in sources :

Example 1 with ItemCrystalPhylactery

use of am2.items.ItemCrystalPhylactery in project ArsMagica2 by Mithion.

the class TileEntityInertSpawner method updateEntity.

public void updateEntity() {
    super.updateEntity();
    if (!worldObj.isRemote && phylactery != null && ((ItemCrystalPhylactery) phylactery.getItem()).isFull(phylactery) && !worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)) {
        if (this.powerConsumed < this.SUMMON_REQ) {
            this.powerConsumed += PowerNodeRegistry.For(worldObj).consumePower(this, PowerTypes.DARK, Math.min(this.getCapacity(), this.SUMMON_REQ - this.powerConsumed));
        } else {
            this.powerConsumed = 0;
            ItemCrystalPhylactery item = (ItemCrystalPhylactery) this.phylactery.getItem();
            if (item.isFull(phylactery)) {
                String clazzName = item.getSpawnClass(phylactery);
                if (clazzName != null) {
                    Class clazz = (Class) EntityList.stringToClassMapping.get(clazzName);
                    if (clazz != null) {
                        EntityLiving entity = null;
                        try {
                            entity = (EntityLiving) clazz.getConstructor(World.class).newInstance(worldObj);
                        } catch (Throwable t) {
                            t.printStackTrace();
                            return;
                        }
                        if (entity == null)
                            return;
                        setEntityPosition(entity);
                        worldObj.spawnEntityInWorld(entity);
                    }
                }
            }
        }
    }
}
Also used : EntityLiving(net.minecraft.entity.EntityLiving) ItemCrystalPhylactery(am2.items.ItemCrystalPhylactery) World(net.minecraft.world.World)

Example 2 with ItemCrystalPhylactery

use of am2.items.ItemCrystalPhylactery in project ArsMagica2 by Mithion.

the class EntityUtilities method handleCrystalPhialAdd.

public static void handleCrystalPhialAdd(EntityCreature entityliving, EntityPlayer player) {
    for (ItemStack stack : player.inventory.mainInventory) {
        if (stack != null && stack.getItem() instanceof ItemCrystalPhylactery) {
            if (ItemsCommonProxy.crystalPhylactery.canStore(stack, entityliving)) {
                ItemsCommonProxy.crystalPhylactery.setSpawnClass(stack, entityliving.getClass());
                ItemsCommonProxy.crystalPhylactery.addFill(stack);
                return;
            }
        }
    }
}
Also used : ItemCrystalPhylactery(am2.items.ItemCrystalPhylactery) ItemStack(net.minecraft.item.ItemStack)

Aggregations

ItemCrystalPhylactery (am2.items.ItemCrystalPhylactery)2 EntityLiving (net.minecraft.entity.EntityLiving)1 ItemStack (net.minecraft.item.ItemStack)1 World (net.minecraft.world.World)1