Search in sources :

Example 6 with INonExhaustiveDeliverable

use of com.minecolonies.api.colony.requestsystem.requestable.INonExhaustiveDeliverable 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

IDeliverable (com.minecolonies.api.colony.requestsystem.requestable.IDeliverable)6 INonExhaustiveDeliverable (com.minecolonies.api.colony.requestsystem.requestable.INonExhaustiveDeliverable)6 TileEntityWareHouse (com.minecolonies.coremod.tileentities.TileEntityWareHouse)6 ItemStack (net.minecraft.item.ItemStack)6 Tuple (com.minecolonies.api.util.Tuple)4 Colony (com.minecolonies.coremod.colony.Colony)4 BlockPos (net.minecraft.util.math.BlockPos)4 Nullable (org.jetbrains.annotations.Nullable)4 Lists (com.google.common.collect.Lists)2 TypeToken (com.google.common.reflect.TypeToken)2 IBuilding (com.minecolonies.api.colony.buildings.IBuilding)2 ILocation (com.minecolonies.api.colony.requestsystem.location.ILocation)2 IRequestManager (com.minecolonies.api.colony.requestsystem.manager.IRequestManager)2 IRequest (com.minecolonies.api.colony.requestsystem.request.IRequest)2 RequestState (com.minecolonies.api.colony.requestsystem.request.RequestState)2 IConcreteDeliverable (com.minecolonies.api.colony.requestsystem.requestable.IConcreteDeliverable)2 Stack (com.minecolonies.api.colony.requestsystem.requestable.Stack)2 AbstractDeliverymanRequestable.getDefaultDeliveryPriority (com.minecolonies.api.colony.requestsystem.requestable.deliveryman.AbstractDeliverymanRequestable.getDefaultDeliveryPriority)2 Delivery (com.minecolonies.api.colony.requestsystem.requestable.deliveryman.Delivery)2 IRequester (com.minecolonies.api.colony.requestsystem.requester.IRequester)2