|
2 | 2 |
|
3 | 3 | import net.minecraft.entity.item.EntityItem;
|
4 | 4 | import net.minecraft.item.ItemStack;
|
| 5 | +import net.minecraft.util.ResourceLocation; |
| 6 | +import net.minecraft.world.storage.loot.LootEntry; |
| 7 | +import net.minecraft.world.storage.loot.LootEntryItem; |
| 8 | +import net.minecraft.world.storage.loot.LootPool; |
| 9 | +import net.minecraft.world.storage.loot.LootTable; |
| 10 | +import net.minecraft.world.storage.loot.RandomValueRange; |
| 11 | +import net.minecraft.world.storage.loot.conditions.LootCondition; |
| 12 | +import net.minecraft.world.storage.loot.functions.LootFunction; |
| 13 | +import net.minecraft.world.storage.loot.functions.SetCount; |
5 | 14 | import net.minecraftforge.common.MinecraftForge;
|
| 15 | +import net.minecraftforge.event.LootTableLoadEvent; |
6 | 16 | import net.minecraftforge.event.entity.EntityJoinWorldEvent;
|
7 | 17 | import net.minecraftforge.fml.common.Loader;
|
8 | 18 | import net.minecraftforge.fml.common.Mod;
|
|
17 | 27 | import org.apache.logging.log4j.Logger;
|
18 | 28 | import realdrops.entities.EntityItemLoot;
|
19 | 29 | import slimeknights.tconstruct.tools.ranged.RangedEvents;
|
| 30 | +import twilightforest.item.TFItems; |
20 | 31 |
|
21 | 32 | import java.util.ArrayList;
|
22 | 33 | import java.util.List;
|
@@ -71,6 +82,23 @@ public void onServerTick(TickEvent.ServerTickEvent event) {
|
71 | 82 | }
|
72 | 83 | }
|
73 | 84 |
|
| 85 | + // Temporary loot adder |
| 86 | + // TODO: remove |
| 87 | + @SubscribeEvent |
| 88 | + public void onLootTableLoad(LootTableLoadEvent event) { |
| 89 | + ResourceLocation tableName = event.getName(); |
| 90 | + if (tableName.getNamespace().equals("twilightforest") && tableName.getPath().split("/")[0].equals("structures") && !tableName.getPath().matches(".*(common|uncommon|useless|rare|ultrarare)$")) { |
| 91 | + LootTable table = event.getTable(); |
| 92 | + LootEntry liveRoot = new LootEntryItem(TFItems.liveroot, 1, 1, new LootFunction[]{new SetCount(new LootCondition[]{}, new RandomValueRange(1, 5))}, new LootCondition[]{}, "twilightforest:liveroot"); |
| 93 | + |
| 94 | + LootPool pool = new LootPool(new LootEntry[]{liveRoot}, new LootCondition[]{}, new RandomValueRange(1), new RandomValueRange(0), "liveroot"); |
| 95 | + table.addPool(pool); |
| 96 | + |
| 97 | + Logger logger = LogManager.getLogger(); |
| 98 | + logger.debug("Adding liveroot pool to {}", tableName); |
| 99 | + } |
| 100 | + } |
| 101 | + |
74 | 102 | @Mod.EventHandler
|
75 | 103 | public void onServerStopping(FMLServerStoppingEvent event) {
|
76 | 104 | itemList.clear();
|
|
0 commit comments