Jump to content

Recommended Posts

Posted

Hello,

I've written my mod now that it works on Servers too (added proxies and such), but now I get an error everytime I try to call a method with Keyboard.isKeyDown() saying I need to create a keyboard before querying key states.

Weird enough it works in my AddInformation method.

Here's the error:

 

  Reveal hidden contents

 

 

And here is the source:

  Reveal hidden contents

 

Anybody knows a solution to this? Tried already using Keyboard.create() and Display.create() but it still won't work...

 

Posted

Keyboard is CLIENT side only; #addInformation is also CLIENT side only, so it works. Almost all of the other Item methods, however, are called on both client AND server, and when they are processing on the server side, the Keyboard does not exist and thus your error.

 

You cannot use client-side classes and methods on the server. Send packets and don't use direct keyboard values, especially not as magic numbers (which key is 54, for example? Do you know without looking?) - registering KeyBindings for your custom keys also allows users to remap them to their own liking or even use something like a gamepad.

Posted

Well uhh thanks guys^^

Didn't know that it's so easy to make custom KeyBinds and get the states of those...

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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