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

[1.20.1] tag inheritance #57

Merged
merged 18 commits into from
Aug 5, 2023
Merged

[1.20.1] tag inheritance #57

merged 18 commits into from
Aug 5, 2023

Conversation

rlnt
Copy link
Member

@rlnt rlnt commented Jul 30, 2023

This pull request implements tag inheritance. Preferred items will be able to inherit item and block tags from the unified items.

This allows obtaining tags from unified items that are required for gameplay mechanics. A good example would be beacon payment items or mods that use block tags for specifying valid blocks for multiblock structures.

The feature is config-controlled. By default, it does nothing. Two new config options will be populated automatically. This will not break existing configs.

Implementation notes

  • the whole reload logic was redesigned to fix timing issues and the required data order
  • tag reloading is now piped through the TagReloadHandler in order to populate the tag maps that are dropped after the process
  • the TagMap was abstracted and generified in order to support blocks as well
    • there is still a clear distinction between item and block tag maps since block tag maps are only used for inheritance right now
  • TagMap creation no longer uses the TagManager and is directly created with the raw tags received from the TagLoader
    • thus the TagManagerMixin is no longer required
  • TagReloadHandler#resolveRelations will work on a filtered tag map meaning all tags, that should allow inheriting from, need to be in the unification tags
  • there is no validation for inheritance tags since they support RegEx
  • after inheritance is applied, all data objects required to build the AlmostUnifiedRuntime are rebuilt in order to reflect changes by inheritance
    • this only happens when item tags are changed, block tags are not used elsewhere
  • item inheritance tags are a map from item tags to item tags
  • block inheritance tags are a map from block tags to item tags

Example

A really cursed example just to show the functionality. Keep in mind that at least two different namespaces are required or the items won't be unified.

{
  "tagOwnerships": {
    "c:iron_ingots": [  // treat silicon and coal as if they were iron ingots
      "c:silicon",
      "c:coal"
    ],
    "minecraft:planks": [  // treat budding blocks as if they were planks
      "c:budding_blocks"
    ]
  },
  "itemTagInheritance": {  // allow inheriting the beacon payment item tag on the dominant item of the coal tag
    "minecraft:beacon_payment_items": [
      "c:coal"
    ]
  },
  "blockTagInheritance": { // allow inheriting the pickaxe mineable block tag on the dominant item of the planks tag
    "minecraft:mineable/pickaxe": [
      "minecraft:planks"
    ]
  }
}

@rlnt rlnt self-assigned this Jul 30, 2023
@rlnt rlnt requested a review from LLytho July 30, 2023 21:19
@rlnt rlnt removed the request for review from LLytho August 5, 2023 22:31
@rlnt rlnt merged commit 47b50f9 into 1.20.1 Aug 5, 2023
1 check passed
@rlnt rlnt deleted the feature/tag-inheritance branch August 5, 2023 22:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants