Created
August 9, 2014 13:07
-
-
Save kevingoos/68639bdd168232d98c6d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class MessageKeyPressed implements IMessage, IMessageHandler<MessageKeyPressed, IMessage> { | |
| private byte keyPressed; | |
| public MessageKeyPressed() { | |
| } | |
| public MessageKeyPressed(Key key) { | |
| if (key == Key.TRADE) { | |
| this.keyPressed = (byte) key.TRADE.ordinal(); | |
| } else { | |
| this.keyPressed = (byte) key.UNKNOWN.ordinal(); | |
| } | |
| } | |
| @Override | |
| public void fromBytes(ByteBuf buf) { | |
| this.keyPressed = buf.readByte(); | |
| } | |
| @Override | |
| public void toBytes(ByteBuf buf) { | |
| buf.writeByte(keyPressed); | |
| } | |
| @Override | |
| public IMessage onMessage(MessageKeyPressed message, MessageContext ctx) { | |
| LogHelper.info("Keypressed!"); | |
| EntityPlayer entityPlayer = ctx.getServerHandler().playerEntity; | |
| if (entityPlayer != null) | |
| { | |
| if (message.keyPressed == Key.TRADE.ordinal()) | |
| { | |
| LogHelper.info("Starting GUI!"); | |
| entityPlayer.openGui(TradeMC.instance, GuiId.TRADE_PLAYER.ordinal(), Minecraft.getMinecraft().theWorld, 0, 0, 0); | |
| } | |
| } | |
| return null; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment