Jump to content

Allow client-side mod to run when connected to a server,


Tvde1

Recommended Posts

Sure, this is my `init` method:

 

@EventHandler
public void init(FMLInitializationEvent event)
{
    // some example code
    logger.info("ShockMod loaded.");

    MinecraftForge.EVENT_BUS.register(new LivingDamageEventHandler(logger));
}

 

The EventHandler is just

 

    @SubscribeEvent
    public void livingDamage(LivingDamageEvent event) {
        this.logger.info("Event entity id: " + event.getEntity().getEntityId() + " | My id: " + Minecraft.getMinecraft().player.getEntityId());
        if (event.getEntity().getEntityId() != Minecraft.getMinecraft().player.getEntityId()) {
            return;
        }

        //Do stuff
    }

 

And these are the flags(?) I supply to the @Mod flag.

 

public static final String MODID = "shockmod";
public static final String NAME = "Shock Mod";
public static final String VERSION = "1.0";
public static final boolean CLIENTSIDEONLY = true;
public static final boolean CANBEDEACTIVATED = true;
Edited by Tvde1
Link to comment
Share on other sites

2 minutes ago, diesieben07 said:

Minecraft is a client-only class. What are you trying to achieve by checking for Minecraft::player? There is no "the player" on a server. There are many players.

This mod is running on the client. I want it to work when connected to a server.

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.



×
×
  • Create New...

Important Information

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