Jump to content

Zukitsu

Members
  • Posts

    0
  • Joined

  • Last visited

Zukitsu's Achievements

Newbie

Newbie (1/8)

0

Reputation

  1. 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.
×
×
  • Create New...

Important Information

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