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.
This commit is contained in:
Robert 2013-11-09 19:57:26 -05:00
parent 893ccb49d1
commit 87db72abdd
2 changed files with 9 additions and 1 deletions

View file

@ -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)

View file

@ -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;