You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/paper/dev/api/command-api/arguments/paper.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -102,7 +102,7 @@ The time argument allows the user to define a time frame, similar to the Vanilla
102
102
103
103
If you choose to use this argument, it is advised to explain to the users what these suffixes mean, as real time (`s` suffix) is mixed with in-game time (`t` and `d` suffix).
104
104
105
-
The `ArgumentType.time()` method has one additional overload: `ArgumentType.time(int mintime)`. This allows to set the minimum required amount of ticks this argument has to resolve to.
105
+
The `ArgumentTypes.time()` method has one additional overload: `ArgumentTypes.time(int mintime)`. This allows to set the minimum required amount of ticks this argument has to resolve to.
Copy file name to clipboardExpand all lines: docs/paper/dev/api/command-api/arguments/registry.mdx
+17-9Lines changed: 17 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -117,7 +117,17 @@ Here is the tab completion when using `ArgumentTypes.resource(RegistryKey.ITEM)`
117
117
And here is the tab completion when using `ArgumentTypes.resourceKey(RegistryKey.ITEM)`:
118
118
<FullWidthVideosrc={ResourceKeyItem}/><br/>
119
119
120
-
The resource argument provides a much cleaner user experience, whilst the `resourceKey` argument has one very important usecase: You get the raw
120
+
:::note
121
+
122
+
In the example given above, due to an unhandled null pointer exception, the command does not successfully run. The code for that command is directly trying to use the value retrieved
123
+
by the registry access by doing `ItemType item = RegistryAccess.registryAccess().getRegistry(itemKey.registryKey()).get(itemKey.key())`. If you try to do any
124
+
operation with the result, it might be null and error.
125
+
126
+
You should **always** check the result of a registry retrieval operation. An example for that is given below in the [direct code comparison](#direct-code-comparison).
127
+
128
+
:::
129
+
130
+
The resource argument provides a much cleaner user experience, whilst the `resourceKey` argument has one very important use case: You get the raw
121
131
`TypedKey<T>` returned as an argument result. This object is particularly useful, as it provides all information required to be able to retrieve
First, in order to get the correct registry, you can run `RegistryAccess#getregistry(RegistryKey)`. In order to get a `RegistryAccess`, you can just use the static
171
-
`RegistryAccess.registryAccess()` method. The `RegistryKey` is retrieved using `TypedKey#registryKey`.
172
-
Now, in order to get the final value `T`, you can run `Registry#get(Key)`, where the key can be retrieved using `TypedKey#key`. This will return the backing instance
180
+
First, in order to get the correct registry, you can run `RegistryAccess#getRegistry(RegistryKey)`. In order to get a `RegistryAccess`, you can just use the static
181
+
`RegistryAccess.registryAccess()` method. The `RegistryKey` is retrieved using `TypedKey#registryKey()`.
182
+
Now, in order to get the final value `T`, you can run `Registry#get(Key)`, where the key can be retrieved using `TypedKey#key()`. This will return the backing instance
173
183
from that resource key or null, if no value has been found.
174
184
175
-
### Usecase over resource argument
176
-
The main usecase for this argument type is the ability to store the key (the value returned to you by `TypedKey#key`). If you want to be able to store the exact user
177
-
input and be able to retrieve the backed instance without much throuble, that is the way to do it.
185
+
### Use case over resource argument
186
+
The main use case for this argument type is the ability to store the key (the value returned to you by `TypedKey#key`). If you want to be able to store the exact user
187
+
input and be able to retrieve the backed instance without much trouble, that is the way to do it.
178
188
179
189
## Registry key previews
180
190
@@ -213,8 +223,6 @@ At the time of writing, the following RegistryKeys exist:
0 commit comments