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