Search in sources :

Example 1 with RequirementContextSupplier

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();
}
Also used : RequirementContextSupplier(com.codetaylor.mc.artisanworktables.api.recipe.requirement.RequirementContextSupplier) ResourceLocation(net.minecraft.util.ResourceLocation) RequirementBuilderSupplier(com.codetaylor.mc.artisanworktables.api.recipe.requirement.RequirementBuilderSupplier) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 2 with RequirementContextSupplier

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);
}
Also used : RequirementContextSupplier(com.codetaylor.mc.artisanworktables.api.recipe.requirement.RequirementContextSupplier) FluidStack(net.minecraftforge.fluids.FluidStack) ResourceLocation(net.minecraft.util.ResourceLocation) IRequirementContext(com.codetaylor.mc.artisanworktables.api.recipe.requirement.IRequirementContext)

Aggregations

RequirementContextSupplier (com.codetaylor.mc.artisanworktables.api.recipe.requirement.RequirementContextSupplier)2 ResourceLocation (net.minecraft.util.ResourceLocation)2 IRequirementContext (com.codetaylor.mc.artisanworktables.api.recipe.requirement.IRequirementContext)1 RequirementBuilderSupplier (com.codetaylor.mc.artisanworktables.api.recipe.requirement.RequirementBuilderSupplier)1 FluidStack (net.minecraftforge.fluids.FluidStack)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1