Jump to content

freethought78

Members
  • Posts

    5
  • Joined

  • Last visited

Converted

  • Gender
    Undisclosed
  • Personal Text
    I am new!

freethought78's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Ernio, you were absolutely right. I thought that I was detecting the player login on the client side, and that the area that the packet was being called from was on the client side only, as it seemed I was only referencing it from the client proxy, but I was dead wrong. The problem was corrected and for those interested this was my solution: I created a new packet type that is sent from the server to the client that just logged in when the server detected a client logging in. When that packet was received on the client, it fired back a GetQuest packet to the server, which then ran the code. Thank you all for your assistance and sorry for the confusion, +1 thanks to ernio!!
  2. here are the changes i made In the mod base class: public void preInit(FMLPreInitializationEvent event) { network = NetworkRegistry.INSTANCE.newSimpleChannel("EpicScavengerQuest"); if (network == null){ System.out.println("null"); }else { System.out.println("Not Null"); } System.out.println(network.toString()); network.registerMessage(GetQuest.class, GetQuest.class, 0, Side.SERVER); network.registerMessage(GetQuest.class, GetQuest.class, 0, Side.CLIENT); FMLCommonHandler.instance().bus().register(new ServerLoginHandler()); FMLCommonHandler.instance().bus().register(new ClientLoginHandler()); } in the GetQuest class: public class GetQuest implements IMessage, IMessageHandler<GetQuest, IMessage> { private int value; public GetQuest(){ } public GetQuest(int quest) { this.value = quest; } @Override public void fromBytes(ByteBuf buf) { this.value = buf.readInt(); } @Override public void toBytes(ByteBuf buf) { buf.writeInt(this.value); } @Override public IMessage onMessage(GetQuest message, MessageContext ctx) { System.out.println("This message never displays"); ctx.getServerHandler().playerEntity.addChatMessage(new ChatComponentText("neither does this one")); return null; } } results in console include: [20:32:36] [Client thread/INFO]: [ft.epicscavengerquest.common.EpicScavengerQuest:preInit:34]: Not Null [20:32:36] [Client thread/INFO]: [ft.epicscavengerquest.common.EpicScavengerQuest:preInit:35]: cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper@2223878 but none of the debug messages from GetQuest are displayed the last console messages shown are: [20:50:18] [Client thread/INFO]: [Client thread] Client side modded connection established [20:50:18] [server thread/INFO]: [server thread] Server side modded connection established [20:50:18] [server thread/INFO]: Player456[local:E:a354cb32] logged in with entity id 335 at (-227.5, 76.26202533778098, 46.5) [20:50:18] [server thread/INFO]: Player456 joined the game [20:50:18] [server thread/INFO]: [ft.epicscavengerquest.client.ClientLoginHandler:onPlayerLogin:17]: This message is being displayed, but the code in the packet below is never executed
  3. Thanks for your response, however that gives the same result. No code is being executed in the onMessage event.
  4. Am I somehow missing something regarding registering the channel? It looks correct to me but does not work.
  5. Hi, this is my first post. Been struggling through development of my first mod. I can't seem to figure out why my packets are not sending. Any help would be appreciated. In the main mod class I am creating a reference to the channel for sending packets and registering my packet handlers. Main Class @Mod(modid = "EpicScavengerQuest", name = "Epic Scavenger Quest", version = "1.7.10 - 0.1") public class EpicScavengerQuest { public static SimpleNetworkWrapper network; @SidedProxy(clientSide ="ft.epicscavengerquest.client.ClientProxy", serverSide = "ft.epicscavengerquest.server.ServerProxy") public static CommonProxy proxy; @EventHandler public void load(FMLInitializationEvent event) { proxy.registerRenderInformation(); } @EventHandler public void preInit(FMLPreInitializationEvent event) { network = NetworkRegistry.INSTANCE.newSimpleChannel("EpicScavengerQuest"); network.registerMessage(GetQuest.Handler.class, GetQuest.class, 0, Side.SERVER); FMLCommonHandler.instance().bus().register(new ServerLoginHandler()); FMLCommonHandler.instance().bus().register(new ClientLoginHandler()); } public EpicScavengerQuest(){ } } ClientLoginHandler The debug message below is sent correctly but the code from the packet does not execute public class ClientLoginHandler { public ClientLoginHandler() { } @SubscribeEvent public void onPlayerLogin(PlayerEvent.PlayerLoggedInEvent event) { System.out.println("This message is being displayed, but the code in the packet below is never executed"); EpicScavengerQuest.network.sendToServer(new GetQuest(1)); } } This is the packet class, no errors are reported, no debug messages are sent, other code is not executed. GetQuest public class GetQuest implements IMessage { private int value; public GetQuest(){ } public GetQuest(int quest) { this.value = quest; } @Override public void fromBytes(ByteBuf buf) { this.value = buf.readInt(); } @Override public void toBytes(ByteBuf buf) { buf.writeInt(this.value); } public static class Handler implements IMessageHandler<GetQuest, IMessage> { @Override public IMessage onMessage(GetQuest message, MessageContext ctx) { SendQuest completed = null; ctx.getServerHandler().playerEntity.addChatMessage(new ChatComponentText("testing GetQuest")); System.out.println("testin"); /* try { completed = new SendQuest(ctx.getServerHandler().playerEntity.getDisplayName(), message.value); } catch (ClassNotFoundException | IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return completed; */ return null; } } } I've Commented out additional code that is unnecessary to demonstrate the point, but left it in to illustrate what the purpose of the code will be. onmessage is never called and I'm trying to figure out why. There are no error messages being sent and everything looks correct to me. thanks in advance.
×
×
  • Create New...

Important Information

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