Changes

Update to 1.17, needs major rewrite
Line 21: Line 21:  
Also you would need a Function to save the Tables
 
Also you would need a Function to save the Tables
 
<syntaxhighlight lang="java">
 
<syntaxhighlight lang="java">
   private void writeTables(DirectoryCache cache, Map<ResourceLocation, LootTable> tables) {
+
   private void writeTables(HashCache cache, Map<ResourceLocation, LootTable> tables) {
 
     Path outputFolder = this.generator.getOutputFolder();
 
     Path outputFolder = this.generator.getOutputFolder();
 
     tables.forEach((key, lootTable) -> {
 
     tables.forEach((key, lootTable) -> {
 
       Path path = outputFolder.resolve("data/" + key.getNamespace() + "/loot_tables/" + key.getPath() + ".json");
 
       Path path = outputFolder.resolve("data/" + key.getNamespace() + "/loot_tables/" + key.getPath() + ".json");
 
       try {
 
       try {
         IDataProvider.save(GSON, cache, LootTableManager.serialize(lootTable), path);
+
         DataProvider.save(GSON, cache, LootTables.serialize(lootTable), path);
 
       } catch (IOException e) {
 
       } catch (IOException e) {
 
         LOGGER.error("Couldn't write loot table {}", path, (Object) e);
 
         LOGGER.error("Couldn't write loot table {}", path, (Object) e);
Line 53: Line 53:  
* <code>.name</code> is used for the pool name.
 
* <code>.name</code> is used for the pool name.
 
* <code>.setRolls</code> is used for the amount.
 
* <code>.setRolls</code> is used for the amount.
* <code>.add</code> is used to add an <code>ItemLootEntry</code>. You can have multiple entries.
+
* <code>.add</code> is used to add an <code>LootPoolEntryContainer$Builder</code>. You can have multiple entries.
   −
An <code>ItemLootEntry</code> defines what item is returned, and which functions and/or conditions are applied (see [https://minecraft.fandom.com/wiki/Loot_table Loot table] for the vanilla functions and conditions).
+
A <code>LootPoolEntryContainer$Builder</code> defines what entry container is returned, and which functions and/or conditions are applied (see [https://minecraft.fandom.com/wiki/Loot_table Loot table] for the vanilla functions and conditions).
* <code>.lootTableItem</code> is used to define which item is returned.
+
* <code>.when</code> is used to apply a condition. These themselves can have multiple operations.
* <code>.apply</code> is used to apply a function or condition. These themselves can have multiple operations.
     −
After all attributes have been added the <code>LootPool.Builder</code> can be used to make a <code>LootTable.Builder</code> of the proper <code>LootParameterSets</code>. This builder can then be added to an entry in the <code>lootTables</code> map made in the previous section (you should do this in the overwritten abstract method).
+
After all attributes have been added the <code>LootPool.Builder</code> can be used to make a <code>LootTable.Builder</code> of the proper <code>LootContextParamSet</code>. This builder can then be added to an entry in the <code>lootTables</code> map made in the previous section (you should do this in the overwritten abstract method).
 
<syntaxhighlight lang="java">
 
<syntaxhighlight lang="java">
 
LootPool.Builder builder = LootPool.lootPool()
 
LootPool.Builder builder = LootPool.lootPool()
 
     .name(...)
 
     .name(...)
 
     .setRolls(...)
 
     .setRolls(...)
     .add(ItemLootEntry.lootTableItem(...)
+
     .add(LootItem.lootTableItem(...)
         .apply(Function1)
+
         .apply(function1)
         .apply(Function2
+
         .apply(function2)
             .operation(operation1)
+
             .when(condition1)
             .operation(operation2))
+
             .when(condition2))
 
     );
 
     );
 
LootTable.lootTable().withPool(builder).setParamSet(...);
 
LootTable.lootTable().withPool(builder).setParamSet(...);
 
</syntaxhighlight>[[Category:Data Generation]]
 
</syntaxhighlight>[[Category:Data Generation]]