use of com.minecolonies.api.colony.jobs.registry.JobEntry in project minecolonies by Minecolonies.
the class BuildingCook method buildingRequiresCertainAmountOfItem.
@Override
public int buildingRequiresCertainAmountOfItem(final ItemStack stack, final List<ItemStorage> localAlreadyKept, final boolean inventory, final JobEntry jobEntry) {
if (stack.isEmpty()) {
return 0;
}
if (inventory && getFirstModuleOccurance(MinimumStockModule.class).isStocked(stack)) {
return stack.getCount();
}
// Neither like the cook does here, nor how the average worker does in the super call.
if (jobEntry == ModJobs.cookassistant) {
return stack.getCount();
}
if (isAllowedFood(stack) && (localAlreadyKept.stream().filter(storage -> ISFOOD.test(storage.getItemStack())).mapToInt(ItemStorage::getAmount).sum() < STACKSIZE || !inventory)) {
final ItemStorage kept = new ItemStorage(stack);
if (localAlreadyKept.contains(kept)) {
kept.setAmount(localAlreadyKept.remove(localAlreadyKept.indexOf(kept)).getAmount());
}
localAlreadyKept.add(kept);
return 0;
}
final Predicate<ItemStack> allowedFuel = theStack -> getModuleMatching(ItemListModule.class, m -> m.getId().equals(FUEL_LIST)).isItemInList(new ItemStorage(theStack));
if (allowedFuel.test(stack) && (localAlreadyKept.stream().filter(storage -> allowedFuel.test(storage.getItemStack())).mapToInt(ItemStorage::getAmount).sum() < STACKSIZE || !inventory)) {
final ItemStorage kept = new ItemStorage(stack);
if (localAlreadyKept.contains(kept)) {
kept.setAmount(localAlreadyKept.remove(localAlreadyKept.indexOf(kept)).getAmount());
}
localAlreadyKept.add(kept);
return 0;
}
return super.buildingRequiresCertainAmountOfItem(stack, localAlreadyKept, inventory, jobEntry);
}
use of com.minecolonies.api.colony.jobs.registry.JobEntry in project minecolonies by Minecolonies.
the class PrivateWorkerCraftingProductionResolverFactory method deserialize.
@NotNull
@Override
public PrivateWorkerCraftingProductionResolver deserialize(@NotNull final IFactoryController controller, @NotNull final CompoundNBT nbt) {
final IToken<?> token = controller.deserialize(nbt.getCompound(NBT_TOKEN));
final ILocation location = controller.deserialize(nbt.getCompound(NBT_LOCATION));
final JobEntry entry = IJobRegistry.getInstance().getValue(new ResourceLocation(nbt.getString(NBT_JOB)));
return new PrivateWorkerCraftingProductionResolver(location, token, entry);
}
use of com.minecolonies.api.colony.jobs.registry.JobEntry in project minecolonies by Minecolonies.
the class PublicWorkerCraftingProductionResolverFactory method deserialize.
@Override
public PublicWorkerCraftingProductionResolver deserialize(IFactoryController controller, PacketBuffer buffer) throws Throwable {
final IToken<?> token = controller.deserialize(buffer);
final ILocation location = controller.deserialize(buffer);
final JobEntry entry = buffer.readRegistryId();
return new PublicWorkerCraftingProductionResolver(location, token, entry);
}
use of com.minecolonies.api.colony.jobs.registry.JobEntry in project minecolonies by Minecolonies.
the class PublicWorkerCraftingRequestResolverFactory method deserialize.
@Override
public PublicWorkerCraftingRequestResolver deserialize(IFactoryController controller, PacketBuffer buffer) throws Throwable {
final IToken<?> token = controller.deserialize(buffer);
final ILocation location = controller.deserialize(buffer);
final JobEntry entry = buffer.readRegistryId();
return new PublicWorkerCraftingRequestResolver(location, token, entry);
}
use of com.minecolonies.api.colony.jobs.registry.JobEntry in project minecolonies by Minecolonies.
the class PublicWorkerCraftingRequestResolverFactory method deserialize.
@NotNull
@Override
public PublicWorkerCraftingRequestResolver deserialize(@NotNull final IFactoryController controller, @NotNull final CompoundNBT nbt) {
final IToken<?> token = controller.deserialize(nbt.getCompound(NBT_TOKEN));
final ILocation location = controller.deserialize(nbt.getCompound(NBT_LOCATION));
final JobEntry entry = IJobRegistry.getInstance().getValue(new ResourceLocation(nbt.getString(NBT_JOB)));
return new PublicWorkerCraftingRequestResolver(location, token, entry);
}
Aggregations