Json
Link to json
Builder to create an arbitrary loot condition through a JSON-based structure.
This builder allows to create arbitrary JSON structures, which can reference other mod-added loot conditions that do not provide native CraftTweaker support. The given JSON structure needs to be a valid JSON-object representation, meaning it needs to be an instance of MapData. The JSON may or may not specify the type. If the type is specified then it must match the one given in the builder; otherwise the type is automatically added.
The JSON structure along with the condition type is mandatory.
Importare la Classe
Link to importare-la-classe
It might be required for you to import the package if you encounter any issues (like casting an Array), so better be safe than sorry and add the import at the very top of the file.
ZenScript Copyimport crafttweaker.api.loot.conditions.crafttweaker.Json;
Interfacce Implementate
Link to interfacce-implementate
Json implements the following interfaces. That means all methods defined in these interfaces are also available in Json
Static Methods
Link to static-methods
Name: create
Creates an ILootCondition of the given type
parsing the given json
.
The JSON must respect the constraints specified in the class documentation. It is suggested to use this method
sparingly, preferring to instead create JSON conditions as needed from within a LootConditionBuilder.
If no valid condition is found, or the JSON is invalid, an error gets thrown.
This method is equivalent to makeJson
in LootConditionBuilder.
Returns: An ILootCondition instance built according to the given data, if possible.
Return Type: ILootCondition
ZenScript CopyJson.create(type as MCResourceLocation, json as IData) as ILootCondition
Parametro | Tipo | Descrizione |
---|---|---|
Parametro type | Tipo MCResourceLocation | Descrizione A MCResourceLocation identifying the type of the loot condition to create. |
Parametro json | Tipo IData | Descrizione The JSON data, according to the given constraints. |
Name: create
Creates an ILootCondition of the given type
parsing the given json
.
The name is treated as a MCResourceLocation, lacking the type safety of the bracket handler. For this
reason, it's suggested to prefer the method with a MCResourceLocation as parameter.
The JSON must respect the constraints specified in the class documentation. It is suggested to use this method
sparingly, preferring to instead create JSON conditions as needed from within a LootConditionBuilder.
If no valid condition is found, or the JSON is invalid, an error gets thrown.
This method is equivalent to makeJson
in LootConditionBuilder.
Returns: An ILootCondition instance built according to the given data, if possible.
Return Type: ILootCondition
ZenScript CopyJson.create(type as string, json as IData) as ILootCondition
Parametro | Tipo | Descrizione |
---|---|---|
Parametro type | Tipo string | Descrizione A string in resource location format identifying the type of the loot condition to create. |
Parametro json | Tipo IData | Descrizione The JSON data, according to the given constraints. |
Metodi
Link to metodi
Name: withJson
Sets the type of the condition that will be built along with the JSON representation that will be parsed.
The JSON must respect the constraints specified in the class documentation.
Returns: This builder for chaining.
Return Type: Json
ZenScript CopyJson.withJson(type as MCResourceLocation, json as IData) as Json
Parametro | Tipo | Descrizione |
---|---|---|
Parametro type | Tipo MCResourceLocation | Descrizione A MCResourceLocation identifying the type of the loot condition. |
Parametro json | Tipo IData | Descrizione The JSON data, according to the given constraints. |
Name: withJson
Sets the type of the condition that will be built along with the JSON representation that will be parsed.
The name is treated as a MCResourceLocation, lacking the type safety of the bracket handler. For this reason, it's suggested to prefer the method with a MCResourceLocation as parameter.
The JSON must respect the constraints specified in the class documentation.
Returns: This builder for chaining.
Return Type: Json
ZenScript CopyJson.withJson(type as string, json as IData) as Json
Parametro | Tipo | Descrizione |
---|---|---|
Parametro type | Tipo string | Descrizione A string in resource location format identifying the type of the loot condition. |
Parametro json | Tipo IData | Descrizione The JSON data, according to the given constraints. |