Advertisement
Guest User

Untitled

a guest
Sep 9th, 2016
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.64 KB | None | 0 0
  1. package com.mrzorse.startrek.gui;
  2.  
  3. import org.apache.commons.lang3.StringUtils;
  4. import org.lwjgl.input.Keyboard;
  5. import org.lwjgl.opengl.GL11;
  6.  
  7. import com.mrzorse.startrek.StarTrek;
  8. import com.mrzorse.startrek.inventory.ContainerTransportControlBlock;
  9. import com.mrzorse.startrek.inventory.ContainerTransportInterlock;
  10. import com.mrzorse.startrek.packets.InterlockPacket;
  11. import com.mrzorse.startrek.packets.TransporterPacket;
  12. import com.mrzorse.startrek.tileentity.tileentities.TileEntityTransportControlBlock;
  13. import com.mrzorse.startrek.tileentity.tileentities.TileEntityTransportInterlock;
  14.  
  15. import net.minecraft.client.gui.GuiButton;
  16. import net.minecraft.client.gui.GuiTextField;
  17. import net.minecraft.client.gui.inventory.GuiContainer;
  18. import net.minecraft.entity.player.InventoryPlayer;
  19. import net.minecraft.util.ResourceLocation;
  20. import net.minecraft.world.World;
  21.  
  22. public class GuiTransportInterlock extends GuiContainer{
  23.  
  24.     private TileEntityTransportInterlock tile; 
  25.     private GuiTextField coordX;
  26.     private GuiTextField playerBeam;
  27.  
  28.    
  29.     public World mworld;
  30.  
  31.     private static final ResourceLocation transportControlTexture = new ResourceLocation("st:textures/gui/TransportInterlockGui.png");
  32.     public GuiTransportInterlock(InventoryPlayer invPlayer, TileEntityTransportInterlock tile) {
  33.         super(new ContainerTransportInterlock(invPlayer, tile));
  34.         this.tile = tile;
  35.    
  36.        
  37.     }
  38.  
  39.     @Override
  40.     public void initGui(){
  41.         this.coordX = new GuiTextField(this.fontRendererObj, 18, 6, 137, 20);
  42.    
  43.         coordX.setMaxStringLength(40);
  44.    
  45.         coordX.setText("");
  46.  
  47.         this.coordX.setFocused(true);
  48.        
  49.  
  50.          super.initGui();
  51.          
  52.     }
  53.  
  54.     @Override
  55.     protected void drawGuiContainerBackgroundLayer(float f,
  56.             int i, int j) {
  57.         GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
  58.         this.mc.getTextureManager().bindTexture(transportControlTexture);
  59.         int k = (this.width - this.xSize) / 2;
  60.         int l = (this.height - this.ySize)/2;
  61.         this.drawTexturedModalRect(k, l-20, 0, 20-20, this.xSize, this.ySize+30);
  62.        
  63.     }
  64.      @Override
  65.      protected void drawGuiContainerForegroundLayer(int par1, int par2)
  66.      {
  67.          
  68.          this.buttonList.add(new GuiButton( 1, this.width/2-72, this.height/2-49, 145, 20, "Change Interlock ID"));
  69.  
  70.          this.coordX.drawTextBox();
  71.          
  72.            
  73.          
  74.      }
  75.  
  76.      
  77.    
  78.     protected void keyTyped(char par1, int par2)
  79.     {
  80.         this.coordX.textboxKeyTyped(par1, par2);
  81.         if(!( par2== Keyboard.KEY_E  &&  this.coordX.isFocused())) super.keyTyped(par1, par2);
  82.         if(!(par2 == Keyboard.KEY_E)){
  83.             super.keyTyped(par1, par2);
  84.         }
  85.        
  86.                
  87.        
  88.          
  89.        
  90.            
  91.        
  92.        
  93.  
  94.     }
  95.    
  96.     public void updateScreen()
  97.     {
  98.         super.updateScreen();
  99.         if(coordX.isFocused()){
  100.             this.coordX.updateCursorCounter();
  101.         }
  102.        
  103.        
  104.  
  105.     }
  106.     public void drawScreen(int par1, int par2, float par3)
  107.     {
  108.         this.drawDefaultBackground();
  109.        
  110.      
  111.         super.drawScreen(par1, par2, par3);
  112.     }
  113.     protected void mouseClicked(int x, int y, int btn) {
  114.         super.mouseClicked(x, y, btn);
  115.      
  116.          
  117.    
  118.         if(this.coordX.isFocused() == true){
  119.             this.coordX.mouseClicked(x, y, btn);
  120.         }
  121.        
  122.        
  123.  
  124.     }
  125.    
  126.      @Override
  127.      protected void actionPerformed(GuiButton b) {
  128.          if(b.id == 1)
  129.          {
  130.        
  131.          String command = this.coordX.getText().toString();
  132.          String finalcommand = command + " " +tile.xCoord + " " + tile.yCoord + " " + tile.zCoord;
  133. //       tile.id = command;
  134. //       System.out.println(tile.id);
  135.          
  136.          StarTrek.network.sendToServer(new InterlockPacket(finalcommand));
  137.          
  138.          
  139.          
  140.              
  141.            
  142.            
  143.        
  144.          }
  145.          
  146.          }
  147.        
  148.      
  149. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement