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

Question: Is there any tool to autoconvert JSON strings to IData format? #40

Closed
vico93 opened this issue Feb 21, 2018 · 2 comments
Closed

Comments

@vico93
Copy link

vico93 commented Feb 21, 2018

After vanilla.loot.Functions.parse(string) became deprecated i became worryied because i use extensively this method to add new items to vanilla loot tables. Specifically this script.

I wasnt able to find a good tutorial about this format, so i'm asking if there's any tool to auto convert the string JSON to IData.

Thanks in advance!

@Daomephsta
Copy link
Owner

Daomephsta commented Feb 21, 2018

There's information about IData here and an example at the bottom of this page. It is near identical to the old string based format, it's pretty much just putting double quotes(") around all the keys, and wrapping the whole thing with curly braces({}) instead of double quotes("). The main difference is that it parses much better.

On another note, your script puzzles me. You use the Functions helper class, but instead of using the methods it provides for the set count and set metadata functions, you parse them from JSON. You have set count functions which are pointless, as they set the count to 1, which is the default. The below script should be functionally identical to yours. You don't even need to use JSON in your script.

/*
 *  @Script: BonusChest++
 *  @Description: Adiciona algumas coisas a mais no loot table do BonusChest
 *  @Dependencies: CraftTweaker e LootTweaker
 */
 
import loottweaker.vanilla.loot.LootTables;
import loottweaker.vanilla.loot.LootTable;
import loottweaker.vanilla.loot.LootPool;
import loottweaker.vanilla.loot.Conditions;
import loottweaker.vanilla.loot.Functions;


val bonuschest = LootTables.getTable("minecraft:chests/spawn_bonus_chest");

val bed_gens = bonuschest.addPool("bed_gens", 1, 2, 0, 1);
val compass_gens = bonuschest.addPool("compass_gens", 1, 1, 0, 1);
val map_gens = bonuschest.addPool("map_gens", 1, 3, 0, 1);
val shovel_gens = bonuschest.addPool("shovel_gens", 1, 1, 0, 1);
val sword_gens = bonuschest.addPool("sword_gens", 1, 1, 0, 1);

bed_gens.addItemEntryHelper(<minecraft:bed>, 4, 2, [Functions.setMetadata(0, 15)], []);
compass_gens.addItemEntry(<minecraft:compass>, 3, 1);

map_gens.addItemEntryHelper(<minecraft:map>, 3, 2, [Functions.setCount(1, 4)], []);

shovel_gens.addItemEntry(<minecraft:stone_shovel>, 1, 1);
shovel_gens.addItemEntry(<minecraft:wooden_shovel>, 3, 1);

sword_gens.addItemEntry(<minecraft:stone_sword>, 1, 1);
sword_gens.addItemEntry(<minecraft:wooden_sword>, 3, 1);

@vico93
Copy link
Author

vico93 commented Feb 21, 2018

😨 I didnt knew it was so simple. I followed your tutorials and thought the only way to set count was using JSON.

Thanks for this tip!

@vico93 vico93 closed this as completed Feb 21, 2018
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

No branches or pull requests

2 participants