Jump to content

[SOLVED] Can't get LootTable loading event to fire.


Dartania

Recommended Posts

[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 by Dartania
Problem Solved
Link to comment
Share on other sites

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.

  • Like 1
Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I'm Murray Brenda by name, a single mom of three kid's, got scammed on forex trade, never taught of getting tricked in such a way, was convinced by a social media friend to invest on the forex platform of which i heed to, after 1 week of thinking about the proposal, i invested $5Gs, then the trade increased and i was asked to deposit so i stay on the trade and avoid running loss and i did, it was so hurtful when i realize that i have been scammed, i reached out to the directors and support service, non where responding, i was always asked for more payment after one payment has been made, after having my funds back with the help of AlienWizbot i was so happy and rejoiceful simply because it was at the edge of giving up, i gave the last trial simply because coming from a reliable source i taught of giving it  try, only then did i came to find out the truth about impostors testimony online which has ended many people losing more money to scam, you can reach out to Alienwizbot by sms (+1 6262645164) or E-mail alienwizbot(@)Gmail(.)com, best service ever experienced, do hire him for all kinds of cyber issues or hacks.  
    • so basically ive been trying to make a modded server for 1.7.10 and i follow the tutorial perfectly but every tutorial has something called a bat file in there folder when they install forge client into a folder but it doesn't show for me i only get these options in the folder config, libraries, logs, mods, eula, forge 1.7.10, minecraft server 1.7.10 and server proprieties so im not sure what to do and google hasn't really been helping
    • { "type": "magic_overhaul:rune_inscribing", "base": { "item": "//base item" }, "template": { "item": "//template item" }, "output": { "count": 1, "item": "//output item" } } ^ Ok, where is your recipe JSON placed in your file structure? What's it called? And paste the actual JSON you're testing with, because it needs to be valid.
    • I'm trying to run Forge 1.12.2 on Minecraft  so I can use certain mods, but this error popped up. I've seen multiple errors but I just can't figure this one out. Unable to locate the Java runtime. Error details: 0x00000000 - system: The operation completed successfully. Filename on disk:  Path: . Exists: Directory
    • https://mclo.gs/b422RFc
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.