use of com.codetaylor.mc.artisanworktables.api.recipe.requirement.RequirementContextSupplier in project artisan-worktables by codetaylor.
the class ModuleWorktables method onNewRegistryEvent.
@SubscribeEvent
public void onNewRegistryEvent(RegistryEvent.NewRegistry event) {
new RegistryBuilder<RequirementContextSupplier>().setName(new ResourceLocation(MOD_ID, "requirement_context_supplier")).setType(RequirementContextSupplier.class).create();
new RegistryBuilder<RequirementBuilderSupplier>().setName(new ResourceLocation(MOD_ID, "requirement_builder_supplier")).setType(RequirementBuilderSupplier.class).create();
new RegistryBuilder<RecipeRegistry>().setName(new ResourceLocation(MOD_ID, "recipe_registry")).setType(RecipeRegistry.class).create();
}
use of com.codetaylor.mc.artisanworktables.api.recipe.requirement.RequirementContextSupplier 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