Advertisement
ViiRuS

Gui Tutorial #3

Dec 23rd, 2011
1,184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.84 KB | None | 0 0
  1. package net.minecraft.src;
  2.  
  3. import java.awt.image.BufferedImage;
  4.  
  5. import org.lwjgl.opengl.GL11;
  6.  
  7.  
  8. public class GuiWhatever extends GuiScreen
  9. {
  10.  
  11.     private BufferedImage img;
  12.     private int imgID = 1000;
  13.    
  14.     public GuiWhatever()
  15.     {
  16.        
  17.     }
  18.    
  19.     public void initGui()
  20.     {
  21.         try{
  22.             img = ModLoader.loadImage(mc.renderEngine, "/mods/test1.png");
  23.             mc.renderEngine.setupTexture(img, imgID);
  24.         }catch(Exception e){
  25.             e.printStackTrace();
  26.         }
  27.         controlList.clear();
  28.         controlList.add(new GuiButton(1, width / 2 - 6, height / 2 + 20, 78, 20, "Make it Rain!"));
  29.         controlList.add(new GuiButton(2, width / 2 - 90, height / 2 + 20, 78, 20, "Stop the Rain!"));
  30.     }
  31.    
  32.     protected void actionPerformed(GuiButton guibutton)
  33.     {
  34.         if(guibutton.id == 1)
  35.         {
  36.             ModLoader.getMinecraftInstance().theWorld.setRainStrength(5F);
  37.             ModLoader.getMinecraftInstance().thePlayer.addChatMessage("Rain Started!");
  38.         }
  39.         if(guibutton.id == 2)
  40.         {
  41.             ModLoader.getMinecraftInstance().theWorld.setRainStrength(0F);
  42.             ModLoader.getMinecraftInstance().thePlayer.addChatMessage("Rain Stopped!");
  43.         }
  44.     }
  45.    
  46.     public boolean doesGuiPauseGame()
  47.     {
  48.         return false;
  49.     }
  50.    
  51.     public void drawScreen(int i, int j, float f)
  52.     {
  53.         drawDefaultBackground();
  54.         int x = width / 2 - 95;
  55.         int y = height / 2 - 100;
  56.         try{
  57.             int wtf = mc.renderEngine.getTexture("/mods/test1.png");
  58.             GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
  59.             mc.renderEngine.bindTexture(wtf);
  60.             drawTexturedModalRect(x, y, 0, 0, 176, 166);
  61.         }
  62.         finally{
  63.         }
  64.         //drawGradientRect(20, 20, width - 20, height - 20, 0x60bb0000, 0xa0770055);
  65.         //drawRect(60, 60, width - 60, height - 60, 0xFF11cc00);
  66.         drawCenteredString(fontRenderer, "Weather Controller", width / 2, 45, 0x44ff11);
  67.         drawString(fontRenderer, "Rain Controller", width / 2 - 100, height / 2 - 40, 0xCCCCCC);
  68.         super.drawScreen(i, j, f);
  69.     }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement