Interface RecipeRemainderLogicHandler


@NonExtendable public interface RecipeRemainderLogicHandler
Handles most logic for stack-aware recipe remainders. This can be used by custom Recipe crafting systems.
  • Method Summary

    Static Methods
    Modifier and Type
    Method
    Description
    static net.minecraft.item.ItemStack
    getRemainder(net.minecraft.item.ItemStack original, @Nullable net.minecraft.recipe.Recipe<?> recipe, RecipeRemainderLocation location)
    Gets the stack-aware remainder of the provided ItemStack for the provided Recipe.
    static void
    handleRemainderForNonPlayerCraft(net.minecraft.item.ItemStack input, int amount, @Nullable net.minecraft.recipe.Recipe<?> recipe, RecipeRemainderLocation location, net.minecraft.util.collection.DefaultedList<net.minecraft.item.ItemStack> inventory, int index, Consumer<net.minecraft.item.ItemStack> failure)
    Handles the recipe remainder logic for crafts without a player present.
    static void
    handleRemainderForNonPlayerCraft(net.minecraft.item.ItemStack input, int amount, @Nullable net.minecraft.recipe.Recipe<?> recipe, RecipeRemainderLocation location, net.minecraft.util.collection.DefaultedList<net.minecraft.item.ItemStack> inventory, int index, net.minecraft.world.World world, net.minecraft.util.math.BlockPos pos)
    Handles the recipe remainder logic for crafts without a player present.
    static void
    handleRemainderForNonPlayerCraft(net.minecraft.item.ItemStack input, @Nullable net.minecraft.recipe.Recipe<?> recipe, RecipeRemainderLocation location, net.minecraft.util.collection.DefaultedList<net.minecraft.item.ItemStack> inventory, int index, net.minecraft.world.World world, net.minecraft.util.math.BlockPos pos)
     
    static void
    handleRemainderForScreenHandler(net.minecraft.screen.slot.Slot slot, int amount, @Nullable net.minecraft.recipe.Recipe<?> recipe, RecipeRemainderLocation location, net.minecraft.entity.player.PlayerEntity player)
    Handles the recipe remainder logic for crafts within a screen handler.
    static void
    handleRemainderForScreenHandler(net.minecraft.screen.slot.Slot slot, @Nullable net.minecraft.recipe.Recipe<?> recipe, RecipeRemainderLocation location, net.minecraft.entity.player.PlayerEntity player)
     
  • Method Details

    • getRemainder

      static net.minecraft.item.ItemStack getRemainder(net.minecraft.item.ItemStack original, @Nullable @Nullable net.minecraft.recipe.Recipe<?> recipe, RecipeRemainderLocation location)
      Gets the stack-aware remainder of the provided ItemStack for the provided Recipe.
      Parameters:
      original - the stack to decrement
      recipe - the recipe being used
      location - the remainder location
      Returns:
      the recipe remainder
    • handleRemainderForNonPlayerCraft

      @Contract(mutates="param1, param5, param7") static void handleRemainderForNonPlayerCraft(net.minecraft.item.ItemStack input, int amount, @Nullable @Nullable net.minecraft.recipe.Recipe<?> recipe, RecipeRemainderLocation location, net.minecraft.util.collection.DefaultedList<net.minecraft.item.ItemStack> inventory, int index, net.minecraft.world.World world, net.minecraft.util.math.BlockPos pos)
      Handles the recipe remainder logic for crafts without a player present. Excess items that cannot be returned to a slot are dropped in the world.
      Parameters:
      input - the original item stack
      amount - the amount by which to decrease the stack
      recipe - the recipe being used
      location - the remainder location
      inventory - the inventory
      index - the index of the original stack in the inventory
      world - the world
      pos - the location to drop excess remainders
    • handleRemainderForNonPlayerCraft

      @Contract(mutates="param1, param5, param7") static void handleRemainderForNonPlayerCraft(net.minecraft.item.ItemStack input, int amount, @Nullable @Nullable net.minecraft.recipe.Recipe<?> recipe, RecipeRemainderLocation location, net.minecraft.util.collection.DefaultedList<net.minecraft.item.ItemStack> inventory, int index, Consumer<net.minecraft.item.ItemStack> failure)
      Handles the recipe remainder logic for crafts without a player present. Excess items that cannot be returned to a slot are handled by the provided consumer.
      Parameters:
      input - the original item stack
      amount - the amount by which to decrease the stack
      recipe - the recipe being used
      location - the remainder location
      inventory - the inventory
      index - the index of the original stack in the inventory
      failure - callback that is run if excess items could not be returned to a slot
    • handleRemainderForNonPlayerCraft

      @Contract(mutates="param1, param4, param6") static void handleRemainderForNonPlayerCraft(net.minecraft.item.ItemStack input, @Nullable @Nullable net.minecraft.recipe.Recipe<?> recipe, RecipeRemainderLocation location, net.minecraft.util.collection.DefaultedList<net.minecraft.item.ItemStack> inventory, int index, net.minecraft.world.World world, net.minecraft.util.math.BlockPos pos)
      See Also:
    • handleRemainderForScreenHandler

      @Contract(mutates="param1, param5") static void handleRemainderForScreenHandler(net.minecraft.screen.slot.Slot slot, int amount, @Nullable @Nullable net.minecraft.recipe.Recipe<?> recipe, RecipeRemainderLocation location, net.minecraft.entity.player.PlayerEntity player)
      Handles the recipe remainder logic for crafts within a screen handler. Excess items that cannot be returned to a slot are offered to the player or dropped.
      Parameters:
      slot - the slot of the original stack
      amount - the amount by which to decrease the stack
      recipe - the recipe being used
      location - the remainder location
      player - the player performing the craft
    • handleRemainderForScreenHandler

      @Contract(mutates="param1, param4") static void handleRemainderForScreenHandler(net.minecraft.screen.slot.Slot slot, @Nullable @Nullable net.minecraft.recipe.Recipe<?> recipe, RecipeRemainderLocation location, net.minecraft.entity.player.PlayerEntity player)
      See Also: