Search in sources :

Example 1 with IConcreteDeliverable

use of com.minecolonies.api.colony.requestsystem.requestable.IConcreteDeliverable in project minecolonies by Minecolonies.

the class WarehouseConcreteRequestResolver method internalCanResolve.

@Override
protected boolean internalCanResolve(final List<TileEntityWareHouse> wareHouses, final IRequest<? extends IDeliverable> requestToCheck) {
    final IDeliverable deliverable = requestToCheck.getRequest();
    if (deliverable instanceof IConcreteDeliverable) {
        boolean ignoreNBT = false;
        boolean ignoreDamage = false;
        if (deliverable instanceof Stack) {
            if (!((Stack) requestToCheck.getRequest()).matchNBT()) {
                ignoreNBT = true;
            }
            if (!((Stack) requestToCheck.getRequest()).matchDamage()) {
                ignoreDamage = true;
            }
        }
        for (final ItemStack possible : ((IConcreteDeliverable) deliverable).getRequestedItems()) {
            for (final TileEntityWareHouse wareHouse : wareHouses) {
                if (requestToCheck.getRequest() instanceof INonExhaustiveDeliverable) {
                    if (wareHouse.hasMatchingItemStackInWarehouse(possible, requestToCheck.getRequest().getMinimumCount(), ignoreNBT, ignoreDamage, ((INonExhaustiveDeliverable) requestToCheck.getRequest()).getLeftOver())) {
                        return true;
                    }
                } else {
                    if (wareHouse.hasMatchingItemStackInWarehouse(possible, requestToCheck.getRequest().getMinimumCount(), ignoreNBT, ignoreDamage, 0)) {
                        return true;
                    }
                }
            }
        }
    }
    return false;
}
Also used : IConcreteDeliverable(com.minecolonies.api.colony.requestsystem.requestable.IConcreteDeliverable) TileEntityWareHouse(com.minecolonies.coremod.tileentities.TileEntityWareHouse) INonExhaustiveDeliverable(com.minecolonies.api.colony.requestsystem.requestable.INonExhaustiveDeliverable) ItemStack(net.minecraft.item.ItemStack) IDeliverable(com.minecolonies.api.colony.requestsystem.requestable.IDeliverable) ItemStack(net.minecraft.item.ItemStack) Stack(com.minecolonies.api.colony.requestsystem.requestable.Stack)

Example 2 with IConcreteDeliverable

use of com.minecolonies.api.colony.requestsystem.requestable.IConcreteDeliverable in project minecolonies by ldtteam.

the class WarehouseConcreteRequestResolver method internalCanResolve.

@Override
protected boolean internalCanResolve(final List<TileEntityWareHouse> wareHouses, final IRequest<? extends IDeliverable> requestToCheck) {
    final IDeliverable deliverable = requestToCheck.getRequest();
    if (deliverable instanceof IConcreteDeliverable) {
        boolean ignoreNBT = false;
        boolean ignoreDamage = false;
        if (deliverable instanceof Stack) {
            if (!((Stack) requestToCheck.getRequest()).matchNBT()) {
                ignoreNBT = true;
            }
            if (!((Stack) requestToCheck.getRequest()).matchDamage()) {
                ignoreDamage = true;
            }
        }
        for (final ItemStack possible : ((IConcreteDeliverable) deliverable).getRequestedItems()) {
            for (final TileEntityWareHouse wareHouse : wareHouses) {
                if (requestToCheck.getRequest() instanceof INonExhaustiveDeliverable) {
                    if (wareHouse.hasMatchingItemStackInWarehouse(possible, requestToCheck.getRequest().getMinimumCount(), ignoreNBT, ignoreDamage, ((INonExhaustiveDeliverable) requestToCheck.getRequest()).getLeftOver())) {
                        return true;
                    }
                } else {
                    if (wareHouse.hasMatchingItemStackInWarehouse(possible, requestToCheck.getRequest().getMinimumCount(), ignoreNBT, ignoreDamage, 0)) {
                        return true;
                    }
                }
            }
        }
    }
    return false;
}
Also used : IConcreteDeliverable(com.minecolonies.api.colony.requestsystem.requestable.IConcreteDeliverable) TileEntityWareHouse(com.minecolonies.coremod.tileentities.TileEntityWareHouse) INonExhaustiveDeliverable(com.minecolonies.api.colony.requestsystem.requestable.INonExhaustiveDeliverable) ItemStack(net.minecraft.item.ItemStack) IDeliverable(com.minecolonies.api.colony.requestsystem.requestable.IDeliverable) ItemStack(net.minecraft.item.ItemStack) Stack(com.minecolonies.api.colony.requestsystem.requestable.Stack)

Aggregations

IConcreteDeliverable (com.minecolonies.api.colony.requestsystem.requestable.IConcreteDeliverable)2 IDeliverable (com.minecolonies.api.colony.requestsystem.requestable.IDeliverable)2 INonExhaustiveDeliverable (com.minecolonies.api.colony.requestsystem.requestable.INonExhaustiveDeliverable)2 Stack (com.minecolonies.api.colony.requestsystem.requestable.Stack)2 TileEntityWareHouse (com.minecolonies.coremod.tileentities.TileEntityWareHouse)2 ItemStack (net.minecraft.item.ItemStack)2