diff --git a/src/main/java/mod/icarus/crimsonrevelations/init/LootTableHandler.java b/src/main/java/mod/icarus/crimsonrevelations/init/LootTableHandler.java index bcf8214..04b7482 100644 --- a/src/main/java/mod/icarus/crimsonrevelations/init/LootTableHandler.java +++ b/src/main/java/mod/icarus/crimsonrevelations/init/LootTableHandler.java @@ -1,27 +1,49 @@ package mod.icarus.crimsonrevelations.init; import mod.icarus.crimsonrevelations.CrimsonRevelations; +import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; -import net.minecraft.world.storage.loot.LootTable; +import net.minecraft.world.storage.loot.LootEntry; +import net.minecraft.world.storage.loot.LootEntryItem; +import net.minecraft.world.storage.loot.LootPool; +import net.minecraft.world.storage.loot.RandomValueRange; +import net.minecraft.world.storage.loot.conditions.KilledByPlayer; +import net.minecraft.world.storage.loot.conditions.LootCondition; +import net.minecraft.world.storage.loot.functions.LootFunction; +import net.minecraft.world.storage.loot.functions.LootingEnchantBonus; +import net.minecraft.world.storage.loot.functions.SetCount; import net.minecraftforge.event.LootTableLoadEvent; import net.minecraftforge.fml.common.Mod.EventBusSubscriber; -import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import thaumcraft.Thaumcraft; @EventBusSubscriber(modid = CrimsonRevelations.MODID) public class LootTableHandler { - public static final ResourceLocation CULTIST = new ResourceLocation(CrimsonRevelations.MODID, ("entities/cultist")); public static final ResourceLocation LESSER_CULTIST_PORTAL = new ResourceLocation(CrimsonRevelations.MODID, ("entities/lesser_cultist_portal")); // Bosses public static final ResourceLocation OVERGROWN_TAINTACLE = new ResourceLocation(CrimsonRevelations.MODID, ("entities/boss/overgrown_taintacle")); - @SubscribeEvent(priority = EventPriority.LOWEST) + @SubscribeEvent public static void onLootTableLoad(LootTableLoadEvent event) { if (event.getName().equals(new ResourceLocation(Thaumcraft.MODID, "cultist"))) { - LootTable lootCultist = event.getLootTableManager().getLootTableFromLocation(CULTIST); - event.getTable().addPool(lootCultist.getPool("crimson_material")); + LootPool crimson_material_pool = event.getTable().getPool("crimson_material"); + + if (crimson_material_pool == null) { + crimson_material_pool = new LootPool(new LootEntry[0], new LootCondition[0], new RandomValueRange(1, 1), new RandomValueRange(1, 1), "crimson_material"); + event.getTable().addPool(crimson_material_pool); + } + + if (crimson_material_pool != null) { + crimson_material_pool.addEntry(new LootEntryItem(new ItemStack(RegistryHandler.crimsonFabric).getItem(), 1, 0, + new LootFunction[]{new SetCount(new LootCondition[]{new KilledByPlayer(false)}, new RandomValueRange(0, 1)), + new LootingEnchantBonus(new LootCondition[0], new RandomValueRange(0, 1), 3)}, + new LootCondition[0], "crimsonrevelations:crimson_fabric")); + crimson_material_pool.addEntry(new LootEntryItem(new ItemStack(RegistryHandler.crimsonPlate).getItem(), 1, 0, + new LootFunction[]{new SetCount(new LootCondition[]{new KilledByPlayer(false)}, new RandomValueRange(0, 1)), + new LootingEnchantBonus(new LootCondition[0], new RandomValueRange(0, 1), 3)}, + new LootCondition[0], "crimsonrevelations:crimson_plate")); + } } } } diff --git a/src/main/resources/assets/crimsonrevelations/loot_tables/entities/cultist.json b/src/main/resources/assets/crimsonrevelations/loot_tables/entities/cultist.json deleted file mode 100644 index 35f06a2..0000000 --- a/src/main/resources/assets/crimsonrevelations/loot_tables/entities/cultist.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "pools": [ - { - "name": "crimson_material", - "rolls": 1, - "entries": [ - { - "type": "item", - "name": "crimsonrevelations:crimson_fabric", - "weight": 1, - "conditions": [ - { - "condition": "killed_by_player" - } - ], - "functions": [ - { - "function": "set_count", - "count": { - "min": 0, - "max": 1 - } - }, - { - "function": "looting_enchant", - "count": { - "min": 0, - "max": 1 - } - } - ] - }, - { - "type": "item", - "name": "crimsonrevelations:crimson_plate", - "weight": 1, - "conditions": [ - { - "condition": "killed_by_player" - } - ], - "functions": [ - { - "function": "set_count", - "count": { - "min": 0, - "max": 1 - } - }, - { - "function": "looting_enchant", - "count": { - "min": 0, - "max": 1 - } - } - ] - } - ] - } - ] -} \ No newline at end of file