use of net.minecraft.world.storage.loot.LootPool in project MinecraftForge by MinecraftForge.
the class LootTablesDebug method lootLoad.
@SubscribeEvent
public void lootLoad(LootTableLoadEvent event) {
if (!event.getName().equals(LootTableList.CHESTS_SPAWN_BONUS_CHEST))
return;
// Remove axes and replace with chestpeice, First vanilla entry is always called "main"
//Note: This CAN NPE if another mod removes things
LootPool main = event.getTable().getPool("main");
main.removeEntry("minecraft:wooden_axe");
main.removeEntry("minecraft:stone_axe");
main.addEntry(new LootEntryItem(Items.DIAMOND_CHESTPLATE, 1, 0, new LootFunction[0], new LootCondition[0], MODID + ":diamond_chestplate"));
// Get rid of all building mats. Which is pool #3, index starts at 0, but 0 is named "main"
event.getTable().removePool("pool3");
}
use of net.minecraft.world.storage.loot.LootPool in project ImmersiveEngineering by BluSunrize.
the class EventHandler method lootLoad.
@SubscribeEvent
public void lootLoad(LootTableLoadEvent event) {
if (event.getName().getResourceDomain().equals("minecraft"))
for (ResourceLocation inject : lootInjections) if (event.getName().getResourcePath().equals(inject.getResourcePath())) {
LootPool injectPool = Utils.loadBuiltinLootTable(inject).getPool("immersiveengineering_loot_inject");
LootPool mainPool = event.getTable().getPool("main");
if (injectPool != null && mainPool != null)
try {
if (f_lootEntries == null) {
//field_186453_a is srg for lootEntries
f_lootEntries = LootPool.class.getDeclaredField(ObfuscationReflectionHelper.remapFieldNames(LootPool.class.getName(), "field_186453_a")[0]);
f_lootEntries.setAccessible(true);
}
if (f_lootEntries != null) {
List<LootEntry> entryList = (List<LootEntry>) f_lootEntries.get(injectPool);
for (LootEntry entry : entryList) mainPool.addEntry(entry);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
Aggregations