Posted September 25, 20187 yr [SOLVED] I know this will probably seem like a dumb question. I'm trying to modify the vanilla loot table to make bats drop a custom item. I am following the tutorial at mcforge.readthedocs, and it says... @SubscribeEvent public void lootLoad(LootTableLoadEvent evt) { if (evt.getName().toString().equals("minecraft:chests/simple_dungeon")) { // do stuff with evt.getTable() } } Well... that doesn't work. I originally put it in its own class called LootTables, and tried adding `@Mod.EventBusSubscriber`, but then I moved it to the main class to better troubleshoot it, so I could be sure it wasn't because the class wasn't being grabbed. I've looked at a lot of various tutorials and Q/A sites regarding this topic, and none of the layouts they have have worked for me. I'm trying to figure out what I'm doing wrong. I've attached (and put in the spoiler below) my main class file. The one where the `@EventHandler` on the preInit and postInit and init functions definitely work. None of the `@SubscribeEvent` things I try work. The logger does not log anything from those SubscribeEvent pieces, so I assume that the methods have not fired. Spoiler package thornecraft.apothecary; import net.minecraft.item.Item; import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.init.Blocks; import net.minecraftforge.event.LootTableLoadEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.SidedProxy; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import org.apache.logging.log4j.Logger; @Mod.EventBusSubscriber @Mod(modid = Apothecary.MODID, name = Apothecary.NAME, version = Apothecary.VERSION) public class Apothecary { public static final String MODID = "apothecary"; public static final String NAME = "ThorneCraft Apothecary"; public static final String VERSION = "1.12.2-0.0.0.0"; public static Logger logger; @SidedProxy(clientSide="thornecraft.apothecary.proxies.ClientOnlyProxy", serverSide="thornecraft.apothecary.proxies.DedicatedServerProxy") public static thornecraft.apothecary.proxies.CommonProxy proxy; @SubscribeEvent public void lootLoad(LootTableLoadEvent event) { logger.warn("lootLoad"); } @SubscribeEvent public void lootLoadEvent(LootTableLoadEvent event) { logger.warn("lootLoadEvent"); } @SubscribeEvent public void onLootTableLoaded(LootTableLoadEvent event) { logger.warn("onLootTableLoaded"); } @SubscribeEvent public void onLootTableLoadedEvent (LootTableLoadEvent event) { logger.warn("onLootTableLoadedEvent"); } @SubscribeEvent public void lootTableLoad(LootTableLoadEvent event) { logger.warn("lootTableLoad"); } @SubscribeEvent public void lootTableLoadEvent(LootTableLoadEvent event) { logger.warn("lootTableLoadEvent"); } @SubscribeEvent public void LootTableLoad(LootTableLoadEvent event) { logger.warn("LootTableLoad"); } @SubscribeEvent public void LootTableLoadEvent(LootTableLoadEvent event) { logger.warn("LootTableLoadEvent"); } @SubscribeEvent public void loadLootTable(LootTableLoadEvent event) { logger.warn("loadLootTable"); } @SubscribeEvent public void loadLootTableEvent(LootTableLoadEvent event) { logger.warn("loadLootTableEvent"); } @SubscribeEvent public void LoadLootTable(LootTableLoadEvent event) { logger.warn("LoadLootTable"); } @SubscribeEvent public void LoadLootTableEvent(LootTableLoadEvent event) { logger.warn("LoadLootTableEvent"); } @EventHandler public void preInit(FMLPreInitializationEvent event) { logger = event.getModLog(); proxy.preInit(); } @EventHandler public void init(FMLInitializationEvent event) { // some example code logger.info("DIRT BLOCK >> {}", Blocks.DIRT.getRegistryName()); proxy.init(); } @EventHandler public void postInit(FMLPostInitializationEvent event) { //proxy.postInit(); } } I'm using Minecraft/Forge version 1.12.2-14.23.4.2705 and mappings version stable_39 Apothecary.java Edited September 25, 20187 yr by Dartania Problem Solved
September 25, 20187 yr How did you register the event handling class? If you used the EventHandler annotation then you need to make the method static. In any case you need to have it properly registered as well. Check out my tutorials here: http://jabelarminecraft.blogspot.com/
September 25, 20187 yr Author Oh my gods! Thank you! None of my methods were static. I went and updated them to be static. All five of these event methods triggered (like a thousand times) [20:26:46] [Server thread/WARN] [apothecary]: loadLootTable [20:26:46] [Server thread/WARN] [apothecary]: lootLoad [20:26:46] [Server thread/WARN] [apothecary]: lootLoadEvent [20:26:46] [Server thread/WARN] [apothecary]: onLootTableLoaded [20:26:46] [Server thread/WARN] [apothecary]: onLootTableLoadedEvent I was using `@SubscribeEvent`, btw.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.