Search in sources :

Example 1 with ISyringe

use of powercrystals.minefactoryreloaded.api.ISyringe in project MineFactoryReloaded by powercrystals.

the class TileEntityVet method activateMachine.

@Override
public boolean activateMachine() {
    List<?> entities = worldObj.getEntitiesWithinAABB(EntityLiving.class, _areaManager.getHarvestArea().toAxisAlignedBB());
    for (Object o : entities) {
        if (!(o instanceof EntityLiving) || o instanceof EntityPlayer || o instanceof EntityMob) {
            continue;
        }
        EntityLiving e = (EntityLiving) o;
        for (int i = 0; i < getSizeInventory(); i++) {
            ItemStack s = getStackInSlot(i);
            if (s != null && s.getItem() instanceof ISyringe) {
                if (((ISyringe) s.getItem()).canInject(worldObj, e, s)) {
                    if (((ISyringe) s.getItem()).inject(worldObj, e, s)) {
                        s.itemID = MineFactoryReloadedCore.syringeEmptyItem.itemID;
                        return true;
                    }
                }
            }
        }
    }
    setIdleTicks(getIdleTicksMax());
    return false;
}
Also used : EntityMob(net.minecraft.entity.monster.EntityMob) EntityLiving(net.minecraft.entity.EntityLiving) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ISyringe(powercrystals.minefactoryreloaded.api.ISyringe) ItemStack(net.minecraft.item.ItemStack)

Aggregations

EntityLiving (net.minecraft.entity.EntityLiving)1 EntityMob (net.minecraft.entity.monster.EntityMob)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 ItemStack (net.minecraft.item.ItemStack)1 ISyringe (powercrystals.minefactoryreloaded.api.ISyringe)1