Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Hello,

I am trying to program a small mod that is working with Pixelmon Reforged.

In the @Mod annotated class' constructor I register an EventHandler class like this:

public ExampleMod() {
     MinecraftForge.EVENT_BUS.register(new com.example.examplemod.EventHandler());
}

The EventHandler class looks like this:

package com.example.examplemod;

import com.pixelmonmod.pixelmon.api.events.DropEvent;
import com.pixelmonmod.pixelmon.api.pokemon.PokemonSpec;
import com.pixelmonmod.pixelmon.api.trading.TradePair;
import net.minecraftforge.event.entity.player.EntityItemPickupEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import org.apache.logging.log4j.Logger;

public class EventHandler {

    private Logger logger;

    @Mod.EventHandler
    public void preInit(FMLPreInitializationEvent event)
    {
        logger = event.getModLog();
        logger.info("### EXAMPLE MOD LOADED");
    }

    @SubscribeEvent
    public void ev(DropEvent event) {
        logger.info("### onEconomyEvent " + event.player);
        PokemonSpec exchange = PokemonSpec.from("glumanda");
        PokemonSpec offer = PokemonSpec.from("mewto");
        TradePair tradePair = new TradePair(offer, exchange);
        com.pixelmonmod.pixelmon.api.trading.NPCTrades.showTrade(event.player, tradePair);
    }

    @SubscribeEvent
    public void pickupItem(EntityItemPickupEvent event) {
        System.out.println("### Item picked up! " + event.getItem().getName());
    }
}

I added a test event which I found in the documentation. It gets triggered. But the DropEvent (or other Pixelmon events) does not. I checked different events but none of them are triggered. (I found them here: https://reforged.gg/docs/)

 

I put the pixelmon jar into a "lib" folder and added the dependency like this:

dependencies {
    provided fileTree(include: ['*.jar'], dir: 'lib')
}

Why aren't any of those events triggered?

Have you tried contacting the author?

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

  • Author

They have a forum, but nothing about modding for it. They also don't provide and source so it is a bit harder. The only thing they provide are the docs above. But I found threads regarding Pixelmon modding here so I thought this forum might be a good place to ask.

 

Interestingly the DropEvent (https://reforged.gg/docs/com/pixelmonmod/pixelmon/api/events/DropEvent.html) I want to listen to extends net.minecraftforge.fml.common.eventhandler.Event. This is very strange...

Pixelmon fires its evnets on its own event bus. You'll need to register your mod instance to that before you'll receive pixelmons events.

Add this to your preinit:

Pixelmon.EVENT_BUS.register(this);

 

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.