Posted July 3, 201411 yr Hey, I've been doing many things in java and tried modding out. Ok so here it is, i'm trying some semi simple things. I want to add a simple jet pack to my mod, where when you press space bar you fly. I was trying to use simple Keyboard.isKeyPressed() which then i soon realized is that you cant use this on servers for some reason with packets. I do not have experience with packets if this is indeed the case. Nor do i know if this is whats needed. I looked in the crash report and it said something about keyboard not created so i used Keyboard.create() and then i keep getting more errors. Now is there a simple way to do this or do i have to make packet handlers, etc. Now if someone could guide me in the right direction and if needed i will attach my code i'm using, just ask. Thank you.
July 3, 201411 yr Key inputs are client side only! Try to use if(world.isRemote) above isKeyPressed(). This will ensure that code is only running client side.(It will not crash server side) Then you have to send a packet to inform the server about you pressed the button and do other things you want. For pakets i recommend you Diesieben tut. Its kinda easy! You can find it in the Modder Support top page(Tutorials sticker). Good luck!
July 3, 201411 yr Author Ive had an error fixed using this. IT WORKS thank you soo much for pointing something obvious out to me. Ive been tryinng to mess with SideOnly because i knew it was a problem similar! Now is this used with sounds server side not playing as well?
July 3, 201411 yr If you want to play sounds only for you than client side is fine. Just use world.playSound() If you want to play the sound so everyone can hear it you need that packet handler. Than just use world.playSoundAtEntity(). Glad i can help you!
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.