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);
}
}
}
}
}
}
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;
}
}
}
}
Aggregations