From 3f28d3903f4dffa9a0f05449658ccdd673d01745 Mon Sep 17 00:00:00 2001 From: Ayutac Date: Wed, 30 Mar 2022 11:23:55 +0200 Subject: [PATCH] Added fishing junk loot (#2869) Rubber and tree tap --- .../techreborn/config/TechRebornConfig.java | 3 ++ src/main/java/techreborn/init/ModLoot.java | 34 +++++++++++++------ 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/src/main/java/techreborn/config/TechRebornConfig.java b/src/main/java/techreborn/config/TechRebornConfig.java index 3341d4758..764527a81 100644 --- a/src/main/java/techreborn/config/TechRebornConfig.java +++ b/src/main/java/techreborn/config/TechRebornConfig.java @@ -605,6 +605,9 @@ public class TechRebornConfig { @Config(config = "world", category = "loot", key = "enableEndLoot", comment = "When true TechReborn will add ingots, machine frames and circuits to The End loot chests.") public static boolean enableEndLoot = true; + @Config(config = "world", category = "loot", key = "enableFishingJunkLoot", comment = "When true TechReborn will add items to fishing junk loot.") + public static boolean enableFishingJunkLoot = true; + @Config(config = "world", category = "generation", key = "enableOreGeneration", comment = "When enabled ores will generate in the world") public static boolean enableOreGeneration = true; diff --git a/src/main/java/techreborn/init/ModLoot.java b/src/main/java/techreborn/init/ModLoot.java index 1563bc43f..a16e21045 100644 --- a/src/main/java/techreborn/init/ModLoot.java +++ b/src/main/java/techreborn/init/ModLoot.java @@ -32,6 +32,7 @@ import net.minecraft.loot.LootPool; import net.minecraft.loot.entry.ItemEntry; import net.minecraft.loot.entry.LootPoolEntry; import net.minecraft.loot.function.SetCountLootFunction; +import net.minecraft.loot.function.SetDamageLootFunction; import net.minecraft.loot.provider.number.UniformLootNumberProvider; import techreborn.config.TechRebornConfig; import techreborn.init.TRContent.Ingots; @@ -51,6 +52,11 @@ public class ModLoot { LootPoolEntry basicCircuit = makeEntry(Parts.ELECTRONIC_CIRCUIT); LootPoolEntry rubberSapling = makeEntry(TRContent.RUBBER_SAPLING, 25); + LootPool poolBasic = FabricLootPoolBuilder.builder().withEntry(copperIngot).withEntry(tinIngot) + .withEntry(leadIngot).withEntry(silverIngot).withEntry(refinedIronIngot).withEntry(advancedAlloyIngot) + .withEntry(basicFrame).withEntry(basicCircuit).withEntry(rubberSapling).rolls(UniformLootNumberProvider.create(1.0f, 2.0f)) + .build(); + LootPoolEntry aluminumIngot = makeEntry(Ingots.ALUMINUM); LootPoolEntry electrumIngot = makeEntry(Ingots.ELECTRUM); LootPoolEntry invarIngot = makeEntry(Ingots.INVAR); @@ -61,6 +67,11 @@ public class ModLoot { LootPoolEntry advancedCircuit = makeEntry(Parts.ADVANCED_CIRCUIT); LootPoolEntry dataStorageChip = makeEntry(Parts.DATA_STORAGE_CHIP); + LootPool poolAdvanced = FabricLootPoolBuilder.builder().withEntry(aluminumIngot).withEntry(electrumIngot) + .withEntry(invarIngot).withEntry(nickelIngot).withEntry(steelIngot).withEntry(zincIngot) + .withEntry(advancedFrame).withEntry(advancedCircuit).withEntry(dataStorageChip).rolls(UniformLootNumberProvider.create(1.0f, 3.0f)) + .build(); + LootPoolEntry chromeIngot = makeEntry(Ingots.CHROME); LootPoolEntry iridiumIngot = makeEntry(Ingots.IRIDIUM); LootPoolEntry platinumIngot = makeEntry(Ingots.PLATINUM); @@ -71,22 +82,17 @@ public class ModLoot { LootPoolEntry industrialCircuit = makeEntry(Parts.INDUSTRIAL_CIRCUIT); LootPoolEntry energyFlowChip = makeEntry(Parts.ENERGY_FLOW_CHIP); - - LootPool poolBasic = FabricLootPoolBuilder.builder().withEntry(copperIngot).withEntry(tinIngot) - .withEntry(leadIngot).withEntry(silverIngot).withEntry(refinedIronIngot).withEntry(advancedAlloyIngot) - .withEntry(basicFrame).withEntry(basicCircuit).withEntry(rubberSapling).rolls(UniformLootNumberProvider.create(1.0f, 2.0f)) - .build(); - - LootPool poolAdvanced = FabricLootPoolBuilder.builder().withEntry(aluminumIngot).withEntry(electrumIngot) - .withEntry(invarIngot).withEntry(nickelIngot).withEntry(steelIngot).withEntry(zincIngot) - .withEntry(advancedFrame).withEntry(advancedCircuit).withEntry(dataStorageChip).rolls(UniformLootNumberProvider.create(1.0f, 3.0f)) - .build(); - LootPool poolIndustrial = FabricLootPoolBuilder.builder().withEntry(chromeIngot).withEntry(iridiumIngot) .withEntry(platinumIngot).withEntry(titaniumIngot).withEntry(tungstenIngot).withEntry(tungstensteelIngot) .withEntry(industrialFrame).withEntry(industrialCircuit).withEntry(energyFlowChip).rolls(UniformLootNumberProvider.create(1.0f, 3.0f)) .build(); + LootPoolEntry rubber = ItemEntry.builder(Parts.RUBBER).weight(10).build(); + LootPoolEntry treeTap = ItemEntry.builder(TRContent.TREE_TAP).weight(10) + .apply(SetDamageLootFunction.builder(UniformLootNumberProvider.create(0.0f, 0.9f))).build(); + + LootPool poolFishingJunk = FabricLootPoolBuilder.builder().withEntry(rubber).withEntry(treeTap).build(); + LootTableLoadingCallback.EVENT.register((resourceManager, lootManager, ident, supplier, setter) -> { String stringId = ident.toString(); if (!stringId.startsWith("minecraft:chests")) { @@ -133,6 +139,12 @@ public class ModLoot { } } + if (TechRebornConfig.enableFishingJunkLoot) { + if (stringId.equals("minecraft:gameplay/fishing/junk")) { + supplier.withPool(poolFishingJunk); + } + } + }); }