001 package net.minecraft.client.gui;
002
003 import cpw.mods.fml.relauncher.Side;
004 import cpw.mods.fml.relauncher.SideOnly;
005 import net.minecraft.client.multiplayer.NetClientHandler;
006 import net.minecraft.network.packet.Packet19EntityAction;
007 import net.minecraft.util.StringTranslate;
008
009 @SideOnly(Side.CLIENT)
010 public class GuiSleepMP extends GuiChat
011 {
012 /**
013 * Adds the buttons (and other controls) to the screen in question.
014 */
015 public void initGui()
016 {
017 super.initGui();
018 StringTranslate var1 = StringTranslate.getInstance();
019 this.controlList.add(new GuiButton(1, this.width / 2 - 100, this.height - 40, var1.translateKey("multiplayer.stopSleeping")));
020 }
021
022 /**
023 * Fired when a key is typed. This is the equivalent of KeyListener.keyTyped(KeyEvent e).
024 */
025 protected void keyTyped(char par1, int par2)
026 {
027 if (par2 == 1)
028 {
029 this.wakeEntity();
030 }
031 else if (par2 == 28)
032 {
033 String var3 = this.inputField.getText().trim();
034
035 if (var3.length() > 0)
036 {
037 this.mc.thePlayer.sendChatMessage(var3);
038 }
039
040 this.inputField.setText("");
041 this.mc.ingameGUI.getChatGUI().resetScroll();
042 }
043 else
044 {
045 super.keyTyped(par1, par2);
046 }
047 }
048
049 /**
050 * Fired when a control is clicked. This is the equivalent of ActionListener.actionPerformed(ActionEvent e).
051 */
052 protected void actionPerformed(GuiButton par1GuiButton)
053 {
054 if (par1GuiButton.id == 1)
055 {
056 this.wakeEntity();
057 }
058 else
059 {
060 super.actionPerformed(par1GuiButton);
061 }
062 }
063
064 /**
065 * Wakes the entity from the bed
066 */
067 private void wakeEntity()
068 {
069 NetClientHandler var1 = this.mc.thePlayer.sendQueue;
070 var1.addToSendQueue(new Packet19EntityAction(this.mc.thePlayer, 3));
071 }
072 }