Class RecipeFilterContext

java.lang.Object
com.portingdeadmods.researchd.api.RecipeFilterContext

public final class RecipeFilterContext extends Object
Thread-local stack of who called frames pushed around code paths that may invoke recipe lookups. The RecipeManagerMixin reads the current frame and filters out recipes blocked for that team.

Pushers (in core): BoundTickingBlockEntityMixin for every ticking BE, CraftingMenuMixin for player crafting. Addons may push their own frames for code paths that don't tick through a BE.

Addons that need to filter recipe lookups which bypass the vanilla RecipeManager (e.g. mods with their own cached recipe finders) should not re-implement the blocking rules. Instead they mixin into the foreign finder and call isBlocked(RecipeHolder) per result, and, if that finder caches a prebuilt structure, scope its cache key with scopedKey(Object) so each team keeps its own entry.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final record 
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static @Nullable RecipeFilterContext.Frame
     
    static boolean
    isBlocked(net.minecraft.world.item.crafting.RecipeHolder<?> holder)
     
    static boolean
    isBlocked(net.minecraft.world.item.crafting.RecipeHolder<?> holder, RecipeFilterContext.Frame frame)
    Single source of truth for whether a recipe is blocked for a given frame: the recipe id is blocked, or its result / any of its ingredients is a blocked item.
    static void
    pop()
     
    static void
    push(UUID teamId, net.minecraft.world.level.Level level)
     
    static Object
    scopedKey(Object delegate)
    Scopes a foreign cache key to the current frame's team, so addon finders that cache a prebuilt structure (filtered recipe lists, tries, ...) keep a separate entry per team instead of letting whichever team searched first decide the result for everyone.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • push

      public static void push(UUID teamId, net.minecraft.world.level.Level level)
    • pop

      public static void pop()
    • current

      @Nullable public static @Nullable RecipeFilterContext.Frame current()
    • isBlocked

      public static boolean isBlocked(net.minecraft.world.item.crafting.RecipeHolder<?> holder)
      Returns:
      true if holder is blocked for the team of the current frame. Returns false when there is no active frame (no filtering in progress).
    • isBlocked

      public static boolean isBlocked(net.minecraft.world.item.crafting.RecipeHolder<?> holder, RecipeFilterContext.Frame frame)
      Single source of truth for whether a recipe is blocked for a given frame: the recipe id is blocked, or its result / any of its ingredients is a blocked item.
    • scopedKey

      public static Object scopedKey(Object delegate)
      Scopes a foreign cache key to the current frame's team, so addon finders that cache a prebuilt structure (filtered recipe lists, tries, ...) keep a separate entry per team instead of letting whichever team searched first decide the result for everyone.
      Returns:
      a team-scoped key while a frame is active, otherwise delegate unchanged.