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.

[1.8.9] Event activates on singleplayer, but refuses to access on multiplayer

Featured Replies

Posted

I'm relatively new to the modding aspect of Minecraft. After failing my way through forums and documentation, I created a mod that detects when a player logs in and performs a keypress. Problem is that this works perfectly fine in singleplayer, but doesn't do anything in multiplayer. I've been trying to find a solution for ages, but no luck. In my package i have 4 class files, a main(dimension), a command(command), references(reference), and the event(Event). 

 

Main class:

package com.zukitsu.dimension;

import java.beans.EventHandler;
import java.util.concurrent.TimeUnit;

import net.minecraft.client.Minecraft;
import net.minecraft.command.*;
import net.minecraftforge.client.ClientCommandHandler;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.*;
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 net.minecraftforge.fml.common.gameevent.PlayerEvent.PlayerChangedDimensionEvent;

@Mod(modid = Reference.MODID, name = Reference.NAME, version = Reference.VERSION)
public class Dimension {
	
	public static void preInit(FMLPreInitializationEvent event) {	
	}
	@Mod.EventHandler
	public static void Init(FMLInitializationEvent event) {
        MinecraftForge.EVENT_BUS.register(new Event());
		ClientCommandHandler.instance.registerCommand(new Command());	
	}
		
		
	
	public static void PostInit(FMLPostInitializationEvent event) {
		
		
	}
	

	

}

 

Event:

package com.zukitsu.dimension;

import java.awt.AWTException;

import java.awt.Robot;

import net.minecraft.client.Minecraft;
import net.minecraft.entity.*;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ChatComponentText;
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent;
import net.minecraftforge.fml.common.gameevent.PlayerEvent.PlayerLoggedOutEvent;

public class Event {
	

	
	@SubscribeEvent
	public void joinWorldEvent(PlayerLoggedInEvent event) throws InterruptedException, AWTException{
		if(Command.v == 1) {
				Thread.sleep(5000);
				Minecraft.getMinecraft().thePlayer.addChatComponentMessage(new ChatComponentText("Activated"));
				Robot robot;
			    robot = new Robot();
			    robot.keyPress('P');
				robot.keyRelease('P');
		        robot.keyPress('#');
				robot.keyRelease('#');
			
			

				
				
}}}
	

	

As for References, I don't think that's necessary? And Command works fine, it is detected on multiplayer servers, but the event is not. Command.v is an integer variable in command which is set to 0 if the player does /dd false and 1 if /dd true.

  • Guest locked this topic
Guest
This topic is now closed to further replies.

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.