Search in sources :

Example 1 with IFactoryRanchable

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

the class TileEntityRancher method activateMachine.

@Override
public boolean activateMachine() {
    MFRLiquidMover.pumpLiquid(_tank, this);
    boolean didDrop = false;
    List<?> entities = worldObj.getEntitiesWithinAABB(EntityLiving.class, _areaManager.getHarvestArea().toAxisAlignedBB());
    for (Object o : entities) {
        EntityLiving e = (EntityLiving) o;
        if (MFRRegistry.getRanchables().containsKey(e.getClass())) {
            IFactoryRanchable r = MFRRegistry.getRanchables().get(e.getClass());
            List<ItemStack> drops = r.ranch(worldObj, e, this);
            if (drops != null) {
                for (ItemStack s : drops) {
                    if (LiquidContainerRegistry.isLiquid(s)) {
                        _tank.fill(new LiquidStack(s.itemID, LiquidContainerRegistry.BUCKET_VOLUME, s.getItemDamage()), true);
                        didDrop = true;
                        continue;
                    }
                    doDrop(s);
                    didDrop = true;
                }
                if (didDrop) {
                    setIdleTicks(20);
                    return true;
                }
            }
        }
    }
    setIdleTicks(getIdleTicksMax());
    return false;
}
Also used : LiquidStack(net.minecraftforge.liquids.LiquidStack) EntityLiving(net.minecraft.entity.EntityLiving) ItemStack(net.minecraft.item.ItemStack) IFactoryRanchable(powercrystals.minefactoryreloaded.api.IFactoryRanchable)

Aggregations

EntityLiving (net.minecraft.entity.EntityLiving)1 ItemStack (net.minecraft.item.ItemStack)1 LiquidStack (net.minecraftforge.liquids.LiquidStack)1 IFactoryRanchable (powercrystals.minefactoryreloaded.api.IFactoryRanchable)1