Jump to content

Robo51

Forge Modder
  • Posts

    53
  • Joined

  • Last visited

Converted

  • Gender
    Male
  • Personal Text
    Hello there

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Robo51's Achievements

Stone Miner

Stone Miner (3/8)

0

Reputation

  1. Okay I have the packets working, and now I'm stuck on figuring out the key state. I have the water movement working fine for climbing out but at the moment it stays that way because I haven't figured out how to properly do the unpressed part. Ive tried doing this: KeyHandler: And this is the message recevier: But it always prints out a setting to false, I'm assuming this is because I've done something weird with the logic. Also in the keyhandler I'm using KeyInputEvent but its overwriting vanilla behavior (just the space-bar, I'm not able to jump), should I be using a different event in its place?
  2. Thank you for that. I started from scratch and the keybinds work great now. I move onto the packets and I'm stuck at what I actually send in the packet. This is the KeyHandler: Now in the sendToServer(); bit what do I actually put in the parenthesis? Is it something I choose or does it need to be something specific?
  3. How would I go about properly registering the KeyInputHandler in the ClientProxy then?
  4. This is the KeyInputHandler code: package robo51.newt.handlers; import net.minecraft.client.settings.KeyBinding; import robo51.newt.proxy.ClientProxy; import cpw.mods.fml.common.eventhandler.EventPriority; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.InputEvent.KeyInputEvent; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class KeyInputHandler { @SideOnly(Side.CLIENT) @SubscribeEvent(priority=EventPriority.NORMAL, receiveCanceled=true) public void onEvent(KeyInputEvent event) { System.out.println("Key Input Event"); KeyBinding[] keyBindings = ClientProxy.keyBindings; if (keyBindings[0].isPressed()) { //line 19 System.out.println("Key binding ="+keyBindings[0].getKeyDescription()); // do stuff for this key binding here // remember you may need to send packet to server } if (keyBindings[1].isPressed()) { System.out.println("Key binding ="+keyBindings[1].getKeyDescription()); // do stuff for this key binding here // remember you may need to send packet to server } } }
  5. I feel like I'm still missing something. I've moved the register KeyInputHandler into the ClientProxy: And still get the same error from the client upon test: Am I just repeating myself at this point?
  6. Is: @EventHandler public void fmlLifeCycleEvent(FMLInitializationEvent event) Similar to: @Mod.EventHandler public void init(FMLInitializationEvent event) { Because this is what my main class looks like right now:
  7. Okay now I'm kinda confused Ive moved to the ClientProxy: And this is what in now in the KeyInputHandler: And now the client errors the moment I press any key, I feel like its going to smack me in the face when I figure it out. But I've got no idea now.
  8. So I've been working through the key binding and hit a small snag. The key binding works fine for the client but the server doesn't like it. I feel like this has to do with which side the key bindings need to be on, but one of the tutorials Ive been reading through mentioned it. This is the KeyBindingHandler: And this is the KeyInputHandler: The server doesn't like this line in the bindinghandler:
  9. Okay so I fixed up my playerTickEvent and got that all working. And now I'm working on the next bit that handles water movement and requires a packet. This is what I have so far: Inside of the event handler: And this is in the NewtMessage class: I left the response for the packet as what came out of the tutorial for the moment so I could get the packet working first. However I'm not sure what all needs to be transferred in the packet, I think I need the player? And If I do need the player how do I properly transfer that since what I'm currently using doesn't work.
  10. So I decided to redo this little section of code as I always find it easiest to start over. I've started with this: However the player takes no damage when in water or rain. Am I referencing the player wrong here?
  11. 1. What is the difference between the START and END phase? I can't seem to find anything really explaining them. 2. I do remember the keybind problem I forgot to comment it out in the version I posted as I plan to try really hard to understand packets and how they work with the help of tutorials. 3. Those numbers are somewhat arbitrary at the moment
  12. I finally got off my lazy butt and decided to work on my mod again, and I am currently working to fix all the "little" things first. So I have an event that causes the player to take damage in the water if a value is <= 0. Event: However this doesn't seem to do anything now, (it used to work but I remember changing the event a while back). I feel like I'm either using the wrong event for this or not using the current event properly. If someone could help me out with this, maybe point me in the right direction it would be much appreciated.
  13. Would anyone be able to help with this?
  14. Maybe I'll explain what I'm tying to accomplish better. I'm changing how the player reacts with water, in my EventsHandler: This block of code: if(event.player.isWet()) { int watersealing = ExtendedPlayerWater.getCurrentWaterSealing(); if(watersealing <= 0) { event.player.attackEntityFrom(DamageSource.drown, 1.0F); } else { --watersealing; ExtendedPlayerWater.newCurrentWaterSealing(watersealing); if(watersealing == 200) { if(!event.player.worldObj.isRemote) { player.addChatMessage(new ChatComponentText("5 Seconds left of WaterSealing.")); } } if(watersealing == 50) { if(!event.player.worldObj.isRemote) { player.addChatMessage(new ChatComponentText("1 Second left of WaterSealing!")); } } } } I'm using to check if the player is in contact with water. (I have an item that adds water sealing to the player via an item.) If they have no water sealing they take damage, otherwise watersealing ticks down, when the sealing hits a certain level a chat message is sent to the player to warn them of imminent failure. In this block: if(event.entity.isInWater()) { event.entity.setAir(10); if(Keyboard.isKeyDown(57)) { event.entity.motionY = 0.005D; if(event.entity.isCollidedHorizontally) { event.entity.motionY = 0.2D; } } else { event.entity.motionY = -1.0D; } } I'm modifying the players movement in water making them sink straight to the bottom. They can swim up but it's slow unless pressed up against a block for leverage. And that's where the problem came from. The server not liking the isKeyDown part. I apologize for not knowing very much about packets and the like. I'm new to java coding and I'm trying to learn through modding. Also if it helps I have a github for this, it can be found here: https://github.com/Robo51/Newt
  15. Thank you very much for the world help, It's much appreciated Would you perhaps be able to help me with the packet? I'm having trouble understanding where I would need to break off in this code: I know the server doesn't handle key-binds, does that mean the packet should contain the isKeyDown or would it be everything after?
×
×
  • Create New...

Important Information

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