Jump to content

[1.7.10]Problem with SimpleNetwork system (doesn't recognize onMessage override)


jabelar

Recommended Posts

Using either diesieben07's tutorial or similar implementation with CatDany, I keep getting the same error in Eclipse where it doesn't recognize that the onMessage() method is proper @Override.  It keeps saying I need to add unimplemented methods for the IMessageHandler or else make it abstract, and also complains that I should remove the @Override.

 

    public static class Handler implements IMessageHandler<MyMessage, IMessage> {
        
        @Override
        public IMessage onMessage(MyMessage message, MessageContext ctx) {
            System.out.println(String.format("Received %s from %s", message.text, ctx.getServerHandler().playerEntity.getDisplayName()));
            return null; // no response in this case
        }

 

I know I'm missing something fundamental...I don't think making it abstract is the answer because it is suggesting that due to not recognizing the override which seems to be a full implementation.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

Problems of missing methods have been raising lately...

Could it be that ForgeGradle is downloading Forge incorrectly? Or something else concerning Forge setup.

 

This is different than a missing method.  Eclipse is properly seeing that I'm implementing an interface, for which it knows the onMessage() method is needed, but it isn't liking the implementation -- it doesn't seem to like the generic parameters part of it.  So even though I'm creating a method that seems to have the right parameter types, it doesn't consider it an override.

 

If I wrote this myself I'd figure it was just me being dumb, but I copied this code from diesieben07s tutorial and copied a similar code from CatDany example, and both had exactly the same complaint.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

Hate to ask the obvious, but does your 'MyMessage' class implement the correct 'IMessage'?

 

Btw, did you get what you needed from here? Seems like you may not have seen it.

 

Thanks for the reply (here and on the other thread).  I just replied on that other thread.

 

On this issue, I'll need to check in the morning.  But I suppose I may have been sloppy on the imports.  I usually have Eclipse set to automatically add/delete imports and if there are multiple options it usually gives me a choice.  I don't remember it giving a choice.  But I think what you're saying is I might have imported an IMessage from some other package.

 

I'm not quite sure that would cause this problem because I think it would consider the parameter to be from that package as well (they would technically match), but I'll check.

 

I suspect that I'm doing the standard mistake of copying code without properly editing it to suit.  However, the examples (e.g. diesienben07s here http://www.minecraftforge.net/forum/index.php/topic,20135.0.html and CatDany here https://gist.github.com/CatDany/4a3df7fcb3c8270cf70b) seem to have complete example message.

 

By the way, are you still set against the SimpleNetworkWrapper approach?  I was reading through your tutorial again today and it was a valiant attempt at making it fully useable.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

EDIT: Yep, turns out I'm a noob :P

 

Problem was in my client proxy:

@Override
public EntityPlayer getPlayerEntity(MessageContext ctx) {
return Minecraft.getMinecraft().thePlayer;
}

 

Looks fine, but the client proxy method apparently ALWAYS gets called, even when the message is sent to the server (I was getting FALSE for ctx.side.isClient() but TRUE for player.worldObj.isRemote) , meaning I was ending up with a CLIENT player even though I was handling the message on the server... wtf.

 

Anyway, a quick modification to my method seems to have done the trick:

@Override
public EntityPlayer getPlayerEntity(MessageContext ctx) {
// super method in CommonProxy simply returns ctx.getServerHandler().playerEntity
return (ctx.side.isClient() ? Minecraft.getMinecraft().thePlayer : super.getPlayerEntity(ctx));
}

 

Still, it seems to be a lot of unnecessary fooling around compared to the previous system, but that's just my opinion.

 

// END EDIT

 

Yes, I am still not at all satisfied with SNW. Perhaps I just haven't figured out how to use it properly, but even without all my shenanigans and using it in the most basic way, I end up with packets that just don't work as they should, most notably with packets that need to be sent both directions, but also some that just don't work as they should. For example:

@Override
public IMessage handleServerMessage(EntityPlayer player, PlaySoundPacket message, MessageContext ctx) {
player.worldObj.playSoundEffect(message.x, message.y, message.z, message.sound, message.volume, message.pitch);
return null;
}

 

That code worked perfectly fine for playing a sound (yes, on the server) with the old PacketPipeline, but now it does absolutely nothing. It is received fine, everything looks like it should work according to my diagnostics, but no sound plays. It's not the Minecraft / Forge version, either, as using the old system the sound plays just as expected.

 

Anyway, perhaps you will have better luck than me and I can follow your (pending) tutorial :P

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.

Announcements



×
×
  • Create New...

Important Information

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