Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inject NBT data into items from a separate file #4114

Closed
Slarof opened this issue Nov 11, 2024 · 4 comments
Closed

Inject NBT data into items from a separate file #4114

Slarof opened this issue Nov 11, 2024 · 4 comments
Labels
type: enhancement Make a feature better. type: feature request New feature request.
Milestone

Comments

@Slarof
Copy link

Slarof commented Nov 11, 2024

Discord tag (optional)

vova_erofeev

Describe the solution you'd like

I want the components to be independent of the nbt line, like attributes (Attribute modifiers) in the configuration of items.

---- removed old examples, check this message history to read them.

@Slarof Slarof added the type: feature request New feature request. label Nov 11, 2024
@LoneDev6

This comment has been minimized.

@LoneDev6 LoneDev6 closed this as not planned Won't fix, can't repro, duplicate, stale Nov 22, 2024
@Slarof

This comment has been minimized.

@LoneDev6

This comment has been minimized.

@LoneDev6 LoneDev6 reopened this Dec 6, 2024
@LoneDev6 LoneDev6 moved this to Todo in ItemsAdder Dec 6, 2024
@LoneDev6 LoneDev6 added this to the 4.0.6 milestone Dec 6, 2024
@LoneDev6 LoneDev6 changed the title Components with a separate configuration Inject NBT data into items from a separate file Dec 6, 2024
@LoneDev6 LoneDev6 added the type: enhancement Make a feature better. label Dec 6, 2024
@LoneDev6 LoneDev6 modified the milestones: 4.0.6, 4.0.7 Dec 18, 2024
@LoneDev6 LoneDev6 modified the milestones: 4.0.7, 4.0.8 Jan 23, 2025
@LoneDev6
Copy link
Collaborator

LoneDev6 commented Jan 24, 2025

I implemented it in 4.0.8 beta-3, available on my Discord.

Example

Image

{
  "components":{
     "minecraft:item_name":"'Черепаший нагрудник'",
     "minecraft:max_damage":440,
     "minecraft:attribute_modifiers":[
        {
           "id":"turtle_chestplate",
           "type":"minecraft:armor",
           "amount":6,
           "operation":"add_value",
           "slot":"chest"
        },
        {
           "id":"turtle_chestplate",
           "type":"minecraft:oxygen_bonus",
           "amount":1,
           "operation":"add_value",
           "slot":"chest"
        },
        {
           "id":"turtle_chestplate",
           "type":"minecraft:water_movement_efficiency",
           "amount":0.3,
           "operation":"add_value",
           "slot":"chest"
        },
        {
           "id":"turtle_chestplate",
           "type":"minecraft:submerged_mining_speed",
           "amount":0.26,
           "operation":"add_value",
           "slot":"chest"
        }
     ],
     "minecraft:item_model":"equipments:turtle_chestplate",
     "minecraft:equippable":{
        "slot":"chest",
        "model":"equipments:turtle_armor",
        "allowed_entities":"minecraft:player",
        "dispensable":true
     },
     "minecraft:repairable":{
        "items":"minecraft:turtle_scute"
     }
  }
}
info:
  namespace: test
items:
  test_inject_nbt_from_file:
    display_name: "Test inject NBT from file"
    components_nbt_file: "test_inject_nbt_from_file.json"
    resource:
      material: IRON_CHESTPLATE
      generate: false
      model_path: minecraft:item/diamond

It also includes a parser for the data, so you get a precise error of where the issue is.

[ItemsAdder] [Items] 'test:test_inject_nbt_from_file'. Error parsing 'components_nbt_file' property. File: /contents/test/4114.yml
[ItemsAdder] Error: Error at line 8, column 14
...
8:             "type":"minecraft:armor",
9:             "amount":6,
10:             "operation":"add_value",
11:             "slot":"chest"
12:          }
13:    }
...

Example malformed json:

{
  "components":{
     "minecraft:item_name":"'Черепаший нагрудник'",
     "minecraft:max_damage":440,
     "minecraft:attribute_modifiers":[
        {
           "id":"turtle_chestplate",xxx
           "type":"minecraft:armor",
           "amount":6,
           "operation":"add_value",
           "slot":"chest"
        }
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement Make a feature better. type: feature request New feature request.
Projects
Status: Done
Development

No branches or pull requests

2 participants