use of com.minecolonies.api.colony.jobs.IJobWithExternalWorkStations in project minecolonies by Minecolonies.
the class BuildingResourcesModule method updateAvailableResources.
/**
* Update the available resources.
* <p>
* which are needed for the build and in the structureBuilder's chest or inventory
*/
private void updateAvailableResources() {
final Set<ICitizenData> set = building.getAllAssignedCitizen();
final ICitizenData data = set.isEmpty() ? null : set.iterator().next();
if (data == null) {
return;
}
data.getEntity().ifPresent(structureBuilder -> {
final InventoryCitizen structureBuilderInventory = data.getInventory();
if (structureBuilderInventory == null) {
return;
}
for (@NotNull final Map.Entry<String, BuildingBuilderResource> entry : neededResources.entrySet()) {
final BuildingBuilderResource resource = entry.getValue();
resource.setAvailable(0);
if (structureBuilderInventory != null) {
resource.addAvailable(InventoryUtils.getItemCountInItemHandler(structureBuilderInventory, stack -> ItemStackUtils.compareItemStacksIgnoreStackSize(stack, resource.getItemStack(), true, true)));
}
if (building.getTileEntity() != null) {
resource.addAvailable(InventoryUtils.getItemCountInItemHandler(building.getCapability(ITEM_HANDLER_CAPABILITY, null).orElseGet(null), stack -> ItemStackUtils.compareItemStacksIgnoreStackSize(stack, resource.getItemStack(), true, true)));
}
if (data.getJob() instanceof IJobWithExternalWorkStations) {
for (final IBuilding station : ((IJobWithExternalWorkStations) data.getJob()).getWorkStations()) {
resource.addAvailable(InventoryUtils.getItemCountInItemHandler(station.getCapability(ITEM_HANDLER_CAPABILITY, null).orElseGet(null), stack -> ItemStackUtils.compareItemStacksIgnoreStackSize(stack, resource.getItemStack(), true, true)));
}
}
}
});
}
use of com.minecolonies.api.colony.jobs.IJobWithExternalWorkStations in project minecolonies by ldtteam.
the class BuildingResourcesModule method updateAvailableResources.
/**
* Update the available resources.
* <p>
* which are needed for the build and in the structureBuilder's chest or inventory
*/
private void updateAvailableResources() {
final Set<ICitizenData> set = building.getAllAssignedCitizen();
final ICitizenData data = set.isEmpty() ? null : set.iterator().next();
if (data == null) {
return;
}
data.getEntity().ifPresent(structureBuilder -> {
final InventoryCitizen structureBuilderInventory = data.getInventory();
if (structureBuilderInventory == null) {
return;
}
for (@NotNull final Map.Entry<String, BuildingBuilderResource> entry : neededResources.entrySet()) {
final BuildingBuilderResource resource = entry.getValue();
resource.setAvailable(0);
if (structureBuilderInventory != null) {
resource.addAvailable(InventoryUtils.getItemCountInItemHandler(structureBuilderInventory, stack -> ItemStackUtils.compareItemStacksIgnoreStackSize(stack, resource.getItemStack(), true, true)));
}
if (building.getTileEntity() != null) {
resource.addAvailable(InventoryUtils.getItemCountInItemHandler(building.getCapability(ITEM_HANDLER_CAPABILITY, null).orElseGet(null), stack -> ItemStackUtils.compareItemStacksIgnoreStackSize(stack, resource.getItemStack(), true, true)));
}
if (data.getJob() instanceof IJobWithExternalWorkStations) {
for (final IBuilding station : ((IJobWithExternalWorkStations) data.getJob()).getWorkStations()) {
resource.addAvailable(InventoryUtils.getItemCountInItemHandler(station.getCapability(ITEM_HANDLER_CAPABILITY, null).orElseGet(null), stack -> ItemStackUtils.compareItemStacksIgnoreStackSize(stack, resource.getItemStack(), true, true)));
}
}
}
});
}
Aggregations