use of com.codetaylor.mc.artisanworktables.api.recipe.requirement.IRequirementContext in project artisan-worktables by codetaylor.
the class ArtisanRecipe method matchesRequirements.
@Override
public boolean matchesRequirements(Map<ResourceLocation, IRequirementContext> requirementContextMap) {
// match requirements
for (IRequirement requirement : this.requirementMap.values()) {
ResourceLocation location = requirement.getResourceLocation();
IRequirementContext context = requirementContextMap.get(location);
if (context == null) {
return false;
}
// noinspection unchecked
if (!requirement.match(context)) {
return false;
}
}
return true;
}
use of com.codetaylor.mc.artisanworktables.api.recipe.requirement.IRequirementContext in project artisan-worktables by codetaylor.
the class TileEntityBase method getRecipe.
public IArtisanRecipe getRecipe(@Nonnull EntityPlayer player) {
FluidStack fluidStack = this.getTank().getFluid();
if (fluidStack != null) {
fluidStack = fluidStack.copy();
}
int playerExperience = EnchantmentHelper.getPlayerExperienceTotal(player);
int playerLevels = player.experienceLevel;
boolean isPlayerCreative = player.isCreative();
IForgeRegistry<RequirementContextSupplier> contextSupplierRegistry = ArtisanRegistries.REQUIREMENT_CONTEXT_SUPPLIER;
Map<ResourceLocation, IRequirementContext> contextMap = new HashMap<>();
ICraftingContext craftingContext = this.getCraftingContext(player);
for (Map.Entry<ResourceLocation, RequirementContextSupplier> entry : contextSupplierRegistry.getEntries()) {
RequirementContextSupplier contextSupplier = entry.getValue();
IRequirementContext context = contextSupplier.get();
context.initialize(craftingContext);
contextMap.put(entry.getKey(), context);
}
return this.getWorktableRecipeRegistry().findRecipe(playerExperience, playerLevels, isPlayerCreative, this.getTools(), this.craftingMatrixHandler, fluidStack, this.getSecondaryIngredientMatcher(), this.getTier(), contextMap);
}
Aggregations