Skip to content

Commit

Permalink
Loot Table Cleanup
Browse files Browse the repository at this point in the history
-Rework how loot is injected into the existing cultist loot table. Remove the additional loot table used for the old method
-The maximum amount of fabric and plates that can be obtained is 3 regardless of Looting enchantment level
  • Loading branch information
IcarussOne committed Jul 6, 2024
1 parent 86768b9 commit e67cfbe
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 68 deletions.
Original file line number Diff line number Diff line change
@@ -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"));
}
}
}
}

This file was deleted.

0 comments on commit e67cfbe

Please sign in to comment.