Jump to content

Recommended Posts

Posted

Hello all!

 

I'm still trying to get the hang of the 1.7 packet structure, and I think I know what the issue is here and where it occurs but I'm a bit confused as to how to actually fix it. I have other packets working but this one is being a bit of a pain.

 

I'm trying to send a packet when I press a key. When I press the button the keybinding tries to send the packet, but I get the following error: readerIndex(0) + length(4) exceeds writerIndex(1). This happens on the line which should be sending a packet. The packet should literally just contain the number 1. I read this as I'm not sending as much as the recieving code expects to see. In all the other packets I've sent I just create a new packet using the constructor and input the paramater I need. So given that my packet constructor takes in an int and saves it to a variable, shouldn't I send it like:

 

BaseClass.innerpowerChannel.sendToServer(new useAbilityPacket(keyPressed));

 

Where keyPressed is an int? Thanks in advance! I'll include the full code below:

 

Packet class:

 

  Reveal hidden contents

 

 

Packet Handler:

 

  Reveal hidden contents

 

 

Key Input Handler:

 

  Reveal hidden contents

 

Posted

Right. I forgot the default constructor. I'll fix that :P

 

Here is the full error log:

 

 

  Reveal hidden contents

 

 

Thanks again!

Posted
  On 10/7/2015 at 5:03 AM, Athire said:

I'm using Forge 10.13.0.1180. I think this is a fairly early version, were there known issues with it?

I don't remember, but when having issues that don't seem related directly to your mod, one of the first things to try is almost always updating to a more recent version of Forge. 1180 is pretty dang old.

Posted

Quick qestion relating to this (it's been awhile since I've updated Forge and all the tutorials just show the setup from scratch). I've downloaded a new version of forge and run gradlew setupDecompWorkspace and gradlew eclipse, but in eclipse the forge changelog under src still shows version 1180. How do I get my current eclipse project running with the new version Forge? (I thought thats what gradlew eclipse did).

 

Thanks again in advance. Most of the resources I'm finding show the setup from scratch but not how to update a current project.

Posted

I'm not sure I did this right. In the directory for forge 1180 I changed the build.gradle version number to:

 

version = "1.7.10-10.13.4.1448-1.7.10"

 

and ran gradlew setupDecompWorkspace in that directory. A lot of items seem to be skipping here. When I open Eclipse I still see the changelog titled "  forge-1.7.10-10.13.0.1180-changelog.txt  ". Am I changeing the version in the right place? And is there a better way to check which forge version I'm using in my eclipse project?

 

Thanks again for your help guys. I'm not too familiar with forge other than the actual coding part, so anything you can tell me is a huge help.

Posted

When you are in Eclipse, you can check which version of Forge you have referenced under 'Referenced Libraries'.

 

There should also be a 'build.gradle' file in the root directory of your project - that is the one you want to edit, though you don't have to do it from within Eclipse.

 

If, after editing that file and re-running gradlew's setup, you still do not have the updated version in your referenced libraries, try refreshing the workspace (F5) or running the setup command with the '--refresh-dependencies' argument. Sometimes even just opening up a package or file from within the Forge src (Minecraft or Forge) will cause it to update with its current version number, provided it was simply that the GUI was failing to update and not that Forge itself failed to update.

 

If both of those fail, you may have to manually set the Forge path - right click on the forgeSrc under Referenced Libraries, go to 'Build Path -> Configure Build Path', then click Edit and navigate to the build you want to use.

Posted

Thanks so much. So I am using the new version of forge now but that doesn't appear to be solving my issue here. I'll include the error log below again because it looks a little different this time (which could be due to the new forge version).

 

 

  Reveal hidden contents

 

Posted

I did add the default constructor, but here is all the relevant code:

 

Registration:

 

  Reveal hidden contents

 

 

Key Input Handler:

 

  Reveal hidden contents

 

 

Packet Class:

 

  Reveal hidden contents

 

 

Packet Handler:

 

  Reveal hidden contents

 

 

Please let me know if there is anything relevant that I've left out. Thanks again!

Posted

I figured it out! It was a super stupid mistake like I thought, but my fromBytes method was writing and my toBytes method was reading, when it should have been the other way around! I'm having other issues now but they aren't related to this so I'll try and solve it on my own and mark this as solved! Thanks again for your help guys!

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.