Interface IBackpackInterface


public interface IBackpackInterface
The Backpack Interface allows you to create your own backpacks. Get the instance from IForestryApi.getBackpackInterface().

To create your own backpack, create an IBackpackDefinition. Backpack definitions have a filter, which you can create here with createBackpackFilter(TagKey, TagKey) or createNaturalistBackpackFilter(ResourceLocation) or create your own.

After you've created your backpack definition, create the item with createBackpack(IBackpackDefinition, EnumBackpackType) or createNaturalistBackpack(IBackpackDefinition, ResourceLocation) and then register the returned item like any other item.

  • Method Summary

    Modifier and Type
    Method
    Description
    net.minecraft.world.item.Item
    Creates a backpack with the given UID and type, returning the item.
    Predicate<net.minecraft.world.item.ItemStack>
    createBackpackFilter(net.minecraft.tags.TagKey<net.minecraft.world.item.Item> allowTag, net.minecraft.tags.TagKey<net.minecraft.world.item.Item> rejectTag)
    Makes a new backpack filter that accepts items in the allow tag, unless they are also in the reject tag.
    net.minecraft.world.item.Item
    createNaturalistBackpack(IBackpackDefinition definition, net.minecraft.resources.ResourceLocation speciesTypeId)
    Create a backpack that can hold items from a specific ISpeciesType.
    Predicate<net.minecraft.world.item.ItemStack>
    createNaturalistBackpackFilter(net.minecraft.resources.ResourceLocation speciesTypeId)
    Makes a new naturalist backpack filter.
  • Method Details

    • createBackpack

      net.minecraft.world.item.Item createBackpack(IBackpackDefinition definition, EnumBackpackType type)
      Creates a backpack with the given UID and type, returning the item.
      Parameters:
      definition - The backpack definition.
      type - Type of backpack.
      Returns:
      Created backpack item.
    • createNaturalistBackpack

      net.minecraft.world.item.Item createNaturalistBackpack(IBackpackDefinition definition, net.minecraft.resources.ResourceLocation speciesTypeId)
      Create a backpack that can hold items from a specific ISpeciesType.
      Parameters:
      definition - The backpack definition.
      speciesTypeId - The species root.
      Returns:
      Created backpack item.
    • createBackpackFilter

      Predicate<net.minecraft.world.item.ItemStack> createBackpackFilter(net.minecraft.tags.TagKey<net.minecraft.world.item.Item> allowTag, net.minecraft.tags.TagKey<net.minecraft.world.item.Item> rejectTag)
      Makes a new backpack filter that accepts items in the allow tag, unless they are also in the reject tag. Forestry's own backpacks use this filter with tags like forestry:backpack/allow/miner. Item tags load with data packs, so the filter reads the tags lazily on its first test.
      Parameters:
      allowTag - The tag of items the backpack accepts
      rejectTag - The tag of items the backpack rejects, even if they are in the allow tag
      Returns:
      a new backpack filter for the specified tags
      Since:
      3.0.0
    • createNaturalistBackpackFilter

      Predicate<net.minecraft.world.item.ItemStack> createNaturalistBackpackFilter(net.minecraft.resources.ResourceLocation speciesTypeId)
      Makes a new naturalist backpack filter. Only accepts items from a specific ISpeciesType. Useful for implementing IBackpackDefinition for naturalist's backpacks.
      Parameters:
      speciesTypeId - The species root's unique ID.
      Returns:
      a new backpack filter for the specified species root
      See Also: