From 87db72abddad6fc1ed386ca850657c9316c8bb4b Mon Sep 17 00:00:00 2001 From: Robert Date: Sat, 9 Nov 2013 19:57:26 -0500 Subject: [PATCH] Changed the key event to stop when key is used Forgot to add this when i created the handler. This will cut down a bit of CPU time when keys are received though i might be able to cut this down more by sending this with the entity id. That way it goes directly to the entity that is going to use it. --- src/dark/core/network/PacketManagerKeyEvent.java | 5 ++++- src/dark/core/prefab/vehicles/EntityDrivable.java | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/dark/core/network/PacketManagerKeyEvent.java b/src/dark/core/network/PacketManagerKeyEvent.java index 18bea4f11..376625477 100644 --- a/src/dark/core/network/PacketManagerKeyEvent.java +++ b/src/dark/core/network/PacketManagerKeyEvent.java @@ -68,7 +68,10 @@ public class PacketManagerKeyEvent implements IPacketManager int key = data.readInt(); for (IControlReceiver receiver : instance().receivers) { - receiver.keyTyped((EntityPlayer) player, key); + if(receiver.keyTyped((EntityPlayer) player, key)) + { + break; + } } } catch (Exception e) diff --git a/src/dark/core/prefab/vehicles/EntityDrivable.java b/src/dark/core/prefab/vehicles/EntityDrivable.java index 454c47a38..493a20c51 100644 --- a/src/dark/core/prefab/vehicles/EntityDrivable.java +++ b/src/dark/core/prefab/vehicles/EntityDrivable.java @@ -48,18 +48,22 @@ public class EntityDrivable extends EntityAdvanced implements IControlReceiver { player.sendChatToPlayer(ChatMessageComponent.createFromText("Forward we go!")); this.accelerate(true); + return true; } if (keycode == Minecraft.getMinecraft().gameSettings.keyBindBack.keyCode) { this.accelerate(false); + return true; } if (keycode == Minecraft.getMinecraft().gameSettings.keyBindLeft.keyCode) { this.turn(true); + return true; } if (keycode == Minecraft.getMinecraft().gameSettings.keyBindRight.keyCode) { this.turn(false); + return true; } //Power brakes if (keycode == Minecraft.getMinecraft().gameSettings.keyBindJump.keyCode) @@ -69,6 +73,7 @@ public class EntityDrivable extends EntityAdvanced implements IControlReceiver { speed = 0; } + return true; } } return false;