Skip to content

References

BeansGalaxy edited this page Sep 25, 2026 · 14 revisions

References are where all of the data driven aspects of this mod come together. The beansbackpacks:reference Component holds a reference to a .json file which declares a Trait Component and optionally a; Display Component, Filter Component, and Attribute Modifier Component.

This section brings all of the prior technical aspects of the mod into one. Play around with the commands and understand how to write Traits, Display, and Filter Components first before beginning this section. Its a doosy...

Creating A Reference

The Reference Component is simply written as [beansbackpacks:reference="namespace:example"]

namespace:example would reference a .json file at data/namespace/trait_ids/example.json where all the information about the reference is stored. Inside of that file we need to now describe the Trait, Display, Filter, and Attribute Components.

Traits

Traits are written similar to how they are seen in the /give command with a few key differences. Since we are specifically looking for a trait, there's no need for the beansbackpacks: prefix. Also instead of an = to begin the fields, we'll use :. Here are examples of the bundle, lunch box, and backpack traits.

Bundle Lunch Box Backpack
  "bundle": {
    "size": 3,
    "sound": "soft"
  }
  "lunch": {
    "size": 1,
    "sound": "clay"
  }
  "parent": "beansbackpacks:iron_backpack",
  "backpack": {
    "texture": "beansbackpacks:copper"
  }

Parented Traits

As you noticed in the Backpack example above, we have the field parent. With that field, the current .json file will overlay the existing fields on top of the parent. The Iron and Gold Backpacks, for example, function identically in game. Below are the References for each Backpack where you see the Gold Backpack is a copy of the Iron one with the exception of the texture field.

data/beansbackpacks/trait_ids/iron_backpack.json data/beansbackpacks/trait_ids/gold_backpack.json
  "backpack": {
    "size": 9,
    "texture": "beansbackpacks:iron",
    "sound": "hard"
  },
  "utilities": 1
  "parent": "beansbackpacks:iron_backpack",
  "backpack": {
    "texture": "beansbackpacks:gold"
  }

Item Whitelists

The Filter Component can be used in the references to whitelist a list of Items or an entire Item Tag. For a few Items simply listing them may be quicker, but for larger groups, and to stay organized, you may want to create your own custom Item Tag within data-packs. Below are examples of creating a list of Items and using a Item Tag.

List of Items Item Tag
  "filter": [
    "minecraft:activator_rail",
    "minecraft:detector_rail",
    "minecraft:powered_rail",
    "minecraft:rail"
  ]
  "filter": "#minecraft:rails"

Custom Display

The display field redirects a Item's Model. For instance, the Item Model for an Iron Ingot is minecraft:iron_ingot. To redirect our Reference to display as an Iron Ingot, use the example below. With a Resource Pack you are able to create custom Item Models and can re-texture items depending on which reference is present. Place any extra models you'd like to load into assets/beansbackpacks/models/backpacks/ folder. Any other folder, and the Model will not be found.

  "display": "minecraft:iron_ingot"

Attribute Modifiers

Modifiers are something we have not covered yet. They are a vanilla feature responsible for Armor Protection, Weapon Damage, Health, and able to change a mobs Scale, Speed, or Gravity. You can read more about them on The Minecraft Wiki. In our case lets make the player feel like they're on the moon by decreasing Gravity by half, and adding to the distance they can safely fall from.

  "modifiers": [
    {
      "type": "generic.gravity",
      "amount": -0.5,
      "slot": "feet",
      "id": "namespace:example_modifier",
      "operation": "add_multiplied_base"
    },
    {
      "type": "generic.safe_fall_distance",
      "amount": 4,
      "slot": "feet",
      "id": "rose_boot_step",
      "operation": "add_value"
    }
  ]

Using The Reference

To finish our reference, we'll save it to data/namespace/trait_ids/example.json. The final file should look something like this once it's all together.

{
  "parent": "beansbackpacks:iron_backpack"
  "backpack": {
    "slot": "chest"
  },
  "display": "minecraft:bucket"
  "filter": "#minecraft:fishes"
  "modifiers": [
    {
      "type": "generic.gravity",
      "amount": -0.5,
      "slot": "chest",
      "id": "example_modifier",
      "operation": "add_multiplied_base"
    },
    {
      "type": "generic.safe_fall_distance",
      "amount": 4,
      "slot": "chest",
      "id": "example_modifier",
      "operation": "add_value"
    }
  ]
}

Running the command /give @p iron_ingot[beansbackapcks:reference="namespace:example"] will give us an Iron Ingot that looks like a Bucket. Once equipped in the Chestplate Slot, it grants us moon-like gravity and acts just like a iron backpack except only types of fish can be stored... cool! Take a look at the built-in trait_ids that are responsible for all the items added by the mod.

If by chance you'd like to modify existing values, just create a .json file with a matching name and file path in your data-pack to override it.

Ender Traits

Ender items allow for traits to be accessed globally. All Ender Items referencing the same trait and created by the same player will access the same inventory. Similar to Ender Chests, but your friend could access your items if you create one and give it to them. By default, the Empty Ender Pouch works like a bundle and references the trait_id "vanilla_bundle". The beansbackpacks:bundle item references the exact same vanilla_bundle.json but because of the component and being on the beansbackapcks:ender_pouch item, the inventory is synced between all Ender Pouches with the matching component.

Lets walk though an example to make this more clear. The Lunch Box item holds 2 stacks of edible items because it references the Trait ID beansbackpacks:lunchbox. Running this give command will give the player an Empty Ender Pouch item which references that same Trait ID that the Lunch Box references.
/give @a beansbackpacks:empty_ender_pouch[beansbackpacks:empty_ender="beansbackpacks:lunch_box"]

The Empty Ender Pouch item we've just created can now see the Traits of the reference. In order to point it to any data like Item Stacks or Fluid Amounts we'll also need a player to specify where that data is. Right-Clicking the item while holding it will create an entry for your player and allow you to start using the Ender Pouch just like the Lunch Box. Unlike the other Components in this mod, beansbackpacks:empty_ender only works while on the Empty Ender Pouch Item.

Removing a Reference

If you would like to outright remove references you are able to by writing your trait_id file like

"non":{}

The non traits are a blank default with no fields that acts like no traits have been given at all. For example, in the traits.json5 config file, you are able to completely remove the traits from leather leggings by adding the line


"minecraft:leggings":{"non":{}}

Technical Overview
Config Options