-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path05_nbt_checking_setting.html
More file actions
168 lines (168 loc) · 9.86 KB
/
05_nbt_checking_setting.html
File metadata and controls
168 lines (168 loc) · 9.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
<!DOCTYPE html>
<html>
<head>
<title>NBT Checking & Setting - Modular Machinery Offline Reference</title>
<link href="./css/site.css" rel="stylesheet">
<link href="./css/colouramber.css" rel="stylesheet">
<link href="./css/font.css" rel="stylesheet">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
</head>
<body>
<div class="row border" id="main">
<div class="col border border-right menu">
<h2>MENU</h2>
<ul class="menu">
<li> <a href=".\index.html" class="link">\Home</a> </li>
<li><a href="./00_keynotes.html" class="link">\Important notes</a></li>
<li><a href="./01_machine_format.html" class="link">\Machine format</a></li>
<li><a href="./02_variables.html" class="link">\Variables</a></li>
<li><a href="./03_machine_recipes.html" class="link">\Recipes</a></li>
<li><a href="./04_recipe_adapters.html" class="link">\Recipe Adapters</a></li>
<li><a href="./05_nbt_checking_setting.html" class="link">\NBT Checking & Setting</a></li>
<li><a href="./06_recipe_sorting.html" class="link">\Recipe Sorting</a></li>
<li><a href="./07_machine_format_postition_permutations.html" class="link">\Machine Format Position Permutations</a></li>
<li><a href="./08_machine_colors.html" class="link">\Machine Colors</a></li>
<li><a href="./09_structure_to_json_tool.html" class="link">\Structure To JSON Tool [Advanced]</a></li>
<li><a href="./010_furnace_fuel_as_item_input.html" class="link">\Furnace Fuel as Item-Input</a></li>
<li><a href="./011_craftweaker_recipe_definitions.html" class="link">\Crafttweaker Recipe definitions</a></li>
<li><a href="./012_recipe_modifiers.html" class="link">\Recipe Modifiers</a></li>
<li><a href="./100_ct_modular_machinery.html" class="link">\CT Modular Machinery</a></li>
<li><a href="./101_ct_recipebuilder.html" class="link">\CT Recipe Builder</a></li>
<li><a href="./102_ct_recipeprimer.html" class="link">\CT Recipe Primer</a></li>
</ul>
</div>
<div class="col">
<div class="col">
<h1 class="border border-bottom">Custom Machines: NBT Checking & Setting [Advanced]</h1>
</div>
<div class="row border border-bottom">
<p>From <a href="https://github.com/HellFirePvP/ModularMachinery/wiki/6.-Custom-Machines:-NBT-Checking-&-Setting-%5BAdvanced%5D">https://github.com/HellFirePvP/ModularMachinery/wiki/6.-Custom-Machines:-NBT-Checking-&-Setting-%5BAdvanced%5D</a> </p>
</div>
<div class="col">
<p>NBT Tags, if present,
hold significant information about an item that you might need to check against when using an item as input OR set a specific NBT tag on an item output.
NBT Tags can be insanely complex and recursive.
Maybe you just need to check if a specific value is present or if a number in the NBT tag is inside a specific range.
So most of the tag might be unnecessary to check at all.</p>
<p><span class="bold">Checking or setting the NBT-tag is not always visible to the user!</span> So keep that in mind when thinking about complex checks that are not obvious.</p>
<p>You can get the nbt-tag of the itemstack you're currently holding with /mm-hand. The message sent back to you in chat will also be copied to your clipboard (if possible) in the expected JSON format.</p>
<p>NBT checks are lazy-checks so the mod will only check if the NBT data you specified is at least present/acceptable. The mod ignores additional tags/entries on the itemstack.
The NBT-tag to check is defined as JSON in an item input/output definition with the tag "nbt" (examples down below).</p>
<p>When defining a String in the NBT tag you can also define it as a <a href="https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html">regular expression</a> instead of just the plain string you want to match against.
(Be careful what you define here, as it is not only used to match the string against the string on the itemstack,
but also set on the itemstack for the preview in JEI!)</p>
<p>When defining a number in the NBT tag you can prefix that number directly with "<", "<=", "==", "=>" or ">" so you're not directly checking if the number specified is equal to the number on the itemstack,
but is less, less & equal, equal, greater & equal or greater than the number on the itemstack.</p>
<p>The NBT-tag defined in an input, eventhough it is meant for checking/matching the NBT-tag or values in it against a potential input item,
is also applied to the itemstack directly when the preview for JEI is built.
In order to use regular expressions when matching strings AND have the preview in JEI not mess up, you can define additionally for item inputs a 'nbt-display' entry alongside 'nbt' - there you can remove all the NBT-checks like regular expressions since that NBT-tag will be preferred over 'nbt' when applying the NBT-tag to the itemstack for the recipe-preview in JEI.</p>
<p>Example #1:</p>
<div class="code">
<pre class="code">
[...]
{
"type": "item",
"io-type": "input",
"item": "forge:bucketfilled",
"amount": 1,
"nbt": {
"FluidName": "ic2uu_matter",
"Amount": ">=1000"
}
},
[...]</pre>
</div>
<p>The input will only be successful if the item is a forge bucket with 1000 or more mb of 'ic2uu_matter' in it.</p>
<p>Example #2:</p>
<div class="code">
<pre class="code">
[...]
{
"type": "item",
"io-type": "input",
"item": "forge:bucketfilled",
"amount": 1,
"nbt": {
"FluidName": "^.*water.*$",
"Amount": "1000"
}
},
[...]</pre>
</div>
<p>This will now only accept if the item in question is a forge-bucket with exactly 1000mb of some fluid that contains 'water' in its name. Defining neither one of the number-comparison methods (<, <=, ==, >=, >) means it'll always mean the same as an exact-match (==).
However, Defining "^.water.$" as FluidName will also set that as FluidName for JEI recipe previews,
which will (not surprisingly) mess up the rendering. See the last few sentences above the 1st example for more information on how to avoid that.</p>
<p>Example #3:</p>
<div class="code">
<pre class="code">
[...]
{
"type": "item",
"io-type": "input",
"item": "forge:bucketfilled",
"amount": 1,
"nbt": {
"SomeWeirdTagName": {
"SomeWeirdNumber": ">5000",
"SomeWeirdList": [
"AListEntry"
]
}
}
},
[...]</pre>
</div>
<p>This kind of NBT matching can be applied as deep and complex as it needs to be.
For the item in Example #3 to be accepted, it needs to be a forge-bucket,
has to have a NBTTagCompound at 'SomeWeirdTagName'.
In that NBTTagCompound there needs to be a integer number at the key 'SomeWeirdNumber' which has to be bigger than 5000.
Additionally, there needs to be a String-List at key 'SomeWeirdList' that has at least 1 entry which is called 'AListEntry'.</p>
<p>Example #4:</p>
<div class="code">
<pre class="code">
[...]
{
"type": "item",
"io-type": "output",
"item": "forge:bucketfilled",
"amount": 1,
"nbt": {
"FluidName": "ic2uu_matter",
"Amount": "1000"
}
},
[...]</pre>
</div>
<p>The output is more straight-forward since there is no matching being done,
only setting the NBT-tag. So whatever you define in the 'nbt' in the item output will be applied to the output stack.</p>
<p>You can however not only apply NBT-checks to itemstack inputs,
but also to TileEntities that are part of your structure,
so you can ask for specifically a spider-spawner for example.
The NBT-tag to check against has to be defined alongside the coordinates for a specific position.
The NBT-Tag will be matched against the TileEntity's NBT-tag,
equal to the one it'd save into a chunk when saving & loading the world.
The NBT-tag follows the same syntax & options as the item-input's NBT-check.</p>
<p>Example #1:</p>
<div class="code">
<pre class="code">
[...]
{
"x": 1,
"y": 1,
"z": 1,
"nbt": {
...
},
"elements": [
...
]
}
[...]</pre>
</div>
<p>If something is unclear - since this indeed can be complex - you can also ask on AstralSorcery/ModularMachinery's discord: </p>
<p><a href="https://discord.gg/q37VRcT">Discord-Invite-Link</a></p>
</div>
</div>
</div>
</body>
</html>