Skip to content

Commit 60179b6

Browse files
committed
Custom tag prefixes
1 parent 9167fec commit 60179b6

File tree

1 file changed

+36
-26
lines changed

1 file changed

+36
-26
lines changed
Lines changed: 36 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,36 @@
11
---
2-
title: TagPrefixes and .setIgnored()
2+
title: TagPrefixes and The Power of .setIgnored()
33
---
44

5-
6-
# TagPrefixes And The Power Of `.setIgnored()`
7-
85
## What is a TagPrefix?
96

107
TagPrefixes are GTCEu Modern's way of streamlining applying item and block tags to Materials, along with some other
118
functions. The `TagPrefix` class, available for use in startup and server scripts, contains a number of predefined
12-
TagPrefixes that associate potentially everything from drill heads to flawless gemstones with a material.
9+
prefixes that associate potentially everything from drill heads to flawless gemstones with a material.
1310

1411
A common and easy-to-understand example is `TagPrefix.ingot`, which associates with all Materials that have an
15-
IngotProperty and thus an associated ingot item, including custom ones defined via KubeJS.
16-
TagPrefixes provide localization, item and block tagging, and influence many crafting recipes, and are integral to the
17-
functioning of GTCEu's material definition system.
12+
IngotProperty and thus an associated ingot item, including custom ones defined by addons or KubeJS.
13+
14+
TagPrefixes provide localization, item and block tagging, influence many crafting recipes, and are integral to the
15+
functioning of GregTech's material definition system.
1816

19-
!!! tip "What TagPrefixes are there?"
20-
A list of all available TagPrefixes can be found in GTCEu Modern's GitHub, in the class `TagPrefix`. You can also quickly navigate to GTM's classes by in your External Libraries
17+
!!! tip "What TagPrefixes exist by default?"
18+
A list of all available TagPrefixes can be found in GTCEu Modern's GitHub, in the class [TagPrefix](https://github.com/GregTechCEu/GregTech-Modern/blob/1.20.1/src/main/java/com/gregtechceu/gtceu/api/data/tag/TagPrefix.java). You can also quickly navigate to GTM's classes in your External Libraries
2119

2220

2321
## What is `.setIgnored()`?
2422

25-
While trawling through GTCEu Modern's codebase, or simply by playing Minecraft, you may have noticed that GTCEu Modern
26-
treats some vanilla materials differently. For example, iron ingots are a vanilla item, yet GTCEu Modern does not create
27-
a duplicate iron ingot, as its Material definition would suggest it is meant to do.
23+
While trawling through GTM's codebase, or simply by playing Minecraft, you may have noticed that some vanilla materials are treated differently. For example, iron ingots are added by vanilla, and GTM does not create a duplicate iron ingot, as its Material definition would suggest.
24+
25+
Instead, the Material entry for iron treats the vanilla iron ingot as the material's ingot, and thus produces no duplicates.
2826

29-
Instead, the GTCEu Modern Material entry for iron treats the vanilla iron ingot as the material's ingot, and thus
30-
produces no duplicates.
3127
This functionality is governed by TagPrefixes, and can also be harnessed by addon developers for their own custom items, or
32-
when writing compatibility between GTCEu Modern and another mod.
28+
when writing compatibility between GregTech and other mods.
3329

3430

35-
## Okay, but how do I use this?
31+
### Okay, but how do I use this?
3632

37-
The material modification event occurs in Minecraft's boot sequence after Material registration is finalized, but before
33+
`MaterialModificationEvent` occurs in Minecraft's boot sequence after Material registration is finalized, but before
3834
the Material registry is closed; you won't be able to define any new Materials using it.
3935

4036
The following calls are available for each TagPrefix:
@@ -58,11 +54,25 @@ TagPrefix.ingot.removeIgnored(GTMaterials.Iron); // (3)
5854
TagPrefix.dust.setIgnored(GTMaterials.Blaze, Items.BLAZE_POWDER); // (4)
5955
```
6056

61-
1. This call prevents GTCEu Modern from creating a chipped gem variant of the custom `fluix_crystal` Material.
62-
2. This call makes GTCEu Modern associate AE2's Sky Stone block as a rock type (like vanilla stone is associated with
63-
the GTCEu Modern stone `Material`) with the custom `sky_stone` Material. It may be necessary to manually load
64-
whatever data definition class contains the `ItemLike` you wish to associate with your `Material`, depending on how
65-
the mod's author has provided KubeJS access to the mod's classes.
66-
3. This call makes GTCEu Modern de-associate vanilla iron ingots from GTCEu Modern's iron Material entry, causing it to
67-
generate a duplicate iron ingot.
68-
4. This call makes GTCEu Modern remove the dust TagPrefix for the material Blaze and replace it with Blaze Powder from Vanilla Minecraft
57+
1. Prevents a chipped gem variant for `fluix_crystal` from being generated.
58+
2. Sets AE2's Sky Stone block as the rock for the `sky_stone` material (similar to how vanilla stone block is associated with the `stone` material).
59+
3. Removes vanilla iron ingots from the `iron` material causing it to generate a duplicate iron ingot.
60+
4. Sets blaze powder as the dust for the `blaze` material
61+
62+
## Creating custom TagPrefixes
63+
64+
<!--TODO-->
65+
66+
Custom TagPrefixes can also be created by addon devs. Once created, custom TagPrefixes must be registered via `IGTAddon#registerTagPrefixes`.
67+
68+
```java title="ModTagPrefixes.java"
69+
public static VeryLongRod = new TagPrefix("very_long_rod")
70+
.idPattern("very_long_%s_rod")
71+
.defaultTagPath("very_long_rod")
72+
.materialIconType(ModMaterialIconTypes.very_long_rod)
73+
.unificationEnabled(true)
74+
.generateItem(true)
75+
.generationCondition(material -> material.hasProperty(PropertyKey.LONG_ROD));
76+
```
77+
78+
All TagPrefixes added by GTM and their definitions can be viewed in the [TagPrefix class](https://github.com/GregTechCEu/GregTech-Modern/blob/1.20.1/src/main/java/com/gregtechceu/gtceu/api/data/tag/TagPrefix.java)

0 commit comments

Comments
 (0)