Skip to content

Commit bd5f505

Browse files
committed
add loot table
1 parent caea000 commit bd5f505

6 files changed

Lines changed: 1286 additions & 0 deletions

File tree

src/main/java/com/dse/dseMod/DseMod.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import com.dse.dseMod.block.BlockWeatherFrog;
2525
import com.dse.dseMod.entity.EntityDsecart;
2626
import com.dse.dseMod.entity.EntityDsecartEmpty;
27+
import com.dse.dseMod.event.LootHandler;
2728
import com.dse.dseMod.item.Dsecart;
2829
import com.dse.dseMod.item.ItemDirectionedSlab;
2930
import com.dse.dseMod.item.ItemKokeshi;
@@ -51,6 +52,7 @@
5152
import net.minecraftforge.fml.common.Mod;
5253
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
5354
import net.minecraftforge.fml.common.SidedProxy;
55+
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
5456
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
5557
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
5658
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
@@ -396,9 +398,15 @@ public void preInit(FMLPreInitializationEvent event) {
396398
GameRegistry.addSmelting(ITEMS.mamedol_seeds, new ItemStack(ITEMS.mamedol_seeds_irimame), 0.1f);
397399
EntityRegistry.registerModEntity(new ResourceLocation(DseMod.MODID,"Dsecart"), EntityDsecart.class, "DsecartEntity", 0, this, 250, 1, false);
398400
EntityRegistry.registerModEntity(new ResourceLocation(DseMod.MODID,"DsecartEmpty"), EntityDsecartEmpty.class, "DsecarEmptytEntity", 1, this, 250, 1, false);
401+
399402
proxy.preInit(event);
400403
}
401404

405+
@Mod.EventHandler
406+
public void init(FMLInitializationEvent event) {
407+
MinecraftForge.EVENT_BUS.register(new LootHandler());
408+
}
409+
402410
@Mod.EventHandler
403411
public void postInit(FMLPostInitializationEvent event) {
404412
MinecraftForge.addGrassSeed(new ItemStack(ITEMS.mamedol_seeds), 1);
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package com.dse.dseMod.event;
2+
3+
import net.minecraft.util.ResourceLocation;
4+
import net.minecraft.world.storage.loot.LootEntry;
5+
import net.minecraft.world.storage.loot.LootEntryTable;
6+
import net.minecraft.world.storage.loot.LootPool;
7+
import net.minecraft.world.storage.loot.LootTableList;
8+
import net.minecraft.world.storage.loot.RandomValueRange;
9+
import net.minecraft.world.storage.loot.conditions.LootCondition;
10+
import net.minecraftforge.event.LootTableLoadEvent;
11+
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
12+
13+
public final class LootHandler {
14+
public LootHandler() {
15+
LootTableList.register(new ResourceLocation("dsemod:dse_abandoned_mineshaft"));
16+
LootTableList.register(new ResourceLocation("dsemod:dse_desert_pyramid"));
17+
LootTableList.register(new ResourceLocation("dsemod:dse_jungle_temple"));
18+
LootTableList.register(new ResourceLocation("dsemod:dse_simple_dungeon"));
19+
}
20+
21+
@SubscribeEvent
22+
public void lootLoad(LootTableLoadEvent evt) {
23+
if(evt.getName().toString().equals("minecraft:chests/abandoned_mineshaft")) {
24+
LootEntry entry = new LootEntryTable(new ResourceLocation("dsemod:dse_abandoned_mineshaft"), 1, 0, new LootCondition[0], "dse_abandoned_mineshaft_entry");
25+
LootPool pool = new LootPool(new LootEntry[] {entry}, new LootCondition[0], new RandomValueRange(1), new RandomValueRange(0, 1), "dse_abndoned_mineshaft_pool");
26+
27+
evt.getTable().addPool(pool);
28+
}else if(evt.getName().toString().equals("minecraft:chests/desert_pyramid")) {
29+
LootEntry entry = new LootEntryTable(new ResourceLocation("dsemod:dse_desert_pyramid"), 1, 0, new LootCondition[0], "dse_desert_pyramid_entry");
30+
LootPool pool = new LootPool(new LootEntry[] {entry}, new LootCondition[0], new RandomValueRange(1), new RandomValueRange(0, 1), "dse_desert_pyramid_pool");
31+
32+
evt.getTable().addPool(pool);
33+
}else if(evt.getName().toString().equals("minecraft:chests/jungle_temple")) {
34+
LootEntry entry = new LootEntryTable(new ResourceLocation("dsemod:dse_jungle_temple"), 1, 0, new LootCondition[0], "dse_jungle_temple_entry");
35+
LootPool pool = new LootPool(new LootEntry[] {entry}, new LootCondition[0], new RandomValueRange(1), new RandomValueRange(0, 1), "dse_jungle_temple_pool");
36+
37+
evt.getTable().addPool(pool);
38+
}else if(evt.getName().toString().equals("minecraft:chests/simple_dungeon")) {
39+
LootEntry entry = new LootEntryTable(new ResourceLocation("dsemod:dse_simple_dungeon"), 1, 0, new LootCondition[0], "dse_simple_dungeon_entry");
40+
LootPool pool = new LootPool(new LootEntry[] {entry}, new LootCondition[0], new RandomValueRange(1), new RandomValueRange(0, 1), "dse_simple_dungeon_pool");
41+
42+
evt.getTable().addPool(pool);
43+
}
44+
}
45+
}

0 commit comments

Comments
 (0)