use of com.minecolonies.coremod.colony.buildings.modules.BuildingResourcesModule in project minecolonies by Minecolonies.
the class AbstractEntityAIStructure method pickUpMaterial.
/**
* State to pick up material before going back to work.
*
* @return the next state to go to.
*/
public IAIState pickUpMaterial() {
if (structurePlacer == null || !structurePlacer.getB().hasBluePrint()) {
return IDLE;
}
if (structurePlacer.getB().getStage() == null || structurePlacer.getB().getStage() == BuildingStructureHandler.Stage.CLEAR) {
pickUpCount = 0;
return START_WORKING;
}
final List<Tuple<Predicate<ItemStack>, Integer>> neededItemsList = new ArrayList<>();
final BuilderBucket neededRessourcesMap = getOwnBuilding().getRequiredResources();
final BuildingResourcesModule module = getOwnBuilding().getFirstModuleOccurance(BuildingResourcesModule.class);
if (neededRessourcesMap != null) {
for (final Map.Entry<String, Integer> entry : neededRessourcesMap.getResourceMap().entrySet()) {
final BuildingBuilderResource res = module.getResourceFromIdentifier(entry.getKey());
if (res != null) {
int amount = entry.getValue();
neededItemsList.add(new Tuple<>(itemstack -> ItemStackUtils.compareItemStacksIgnoreStackSize(res.getItemStack(), itemstack, true, true), amount));
}
}
}
if (neededItemsList.size() <= pickUpCount || InventoryUtils.openSlotCount(worker.getInventoryCitizen()) <= MIN_OPEN_SLOTS) {
getOwnBuilding().checkOrRequestBucket(getOwnBuilding().getRequiredResources(), worker.getCitizenData(), true);
getOwnBuilding().checkOrRequestBucket(getOwnBuilding().getNextBucket(), worker.getCitizenData(), false);
pickUpCount = 0;
return START_WORKING;
}
needsCurrently = neededItemsList.get(pickUpCount);
pickUpCount++;
if (InventoryUtils.hasItemInProvider(getOwnBuilding().getTileEntity(), needsCurrently.getA())) {
return GATHERING_REQUIRED_MATERIALS;
}
return pickUpMaterial();
}
use of com.minecolonies.coremod.colony.buildings.modules.BuildingResourcesModule in project minecolonies by ldtteam.
the class AbstractEntityAIStructure method pickUpMaterial.
/**
* State to pick up material before going back to work.
*
* @return the next state to go to.
*/
public IAIState pickUpMaterial() {
if (structurePlacer == null || !structurePlacer.getB().hasBluePrint()) {
return IDLE;
}
if (structurePlacer.getB().getStage() == null || structurePlacer.getB().getStage() == BuildingStructureHandler.Stage.CLEAR) {
pickUpCount = 0;
return START_WORKING;
}
final List<Tuple<Predicate<ItemStack>, Integer>> neededItemsList = new ArrayList<>();
final BuilderBucket neededRessourcesMap = getOwnBuilding().getRequiredResources();
final BuildingResourcesModule module = getOwnBuilding().getFirstModuleOccurance(BuildingResourcesModule.class);
if (neededRessourcesMap != null) {
for (final Map.Entry<String, Integer> entry : neededRessourcesMap.getResourceMap().entrySet()) {
final BuildingBuilderResource res = module.getResourceFromIdentifier(entry.getKey());
if (res != null) {
int amount = entry.getValue();
neededItemsList.add(new Tuple<>(itemstack -> ItemStackUtils.compareItemStacksIgnoreStackSize(res.getItemStack(), itemstack, true, true), amount));
}
}
}
if (neededItemsList.size() <= pickUpCount || InventoryUtils.openSlotCount(worker.getInventoryCitizen()) <= MIN_OPEN_SLOTS) {
getOwnBuilding().checkOrRequestBucket(getOwnBuilding().getRequiredResources(), worker.getCitizenData(), true);
getOwnBuilding().checkOrRequestBucket(getOwnBuilding().getNextBucket(), worker.getCitizenData(), false);
pickUpCount = 0;
return START_WORKING;
}
needsCurrently = neededItemsList.get(pickUpCount);
pickUpCount++;
if (InventoryUtils.hasItemInProvider(getOwnBuilding().getTileEntity(), needsCurrently.getA())) {
return GATHERING_REQUIRED_MATERIALS;
}
return pickUpMaterial();
}
Aggregations