aydarbiktimirov

Untitled

Aug 17th, 2012
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.78 KB | None | 0 0
  1. // GuiSawmill.java
  2. package net.minecraft.src;
  3.  
  4. import org.lwjgl.opengl.GL11;
  5.  
  6. public class GuiSawmill extends GuiContainer
  7. {
  8.  
  9.     public GuiSawmill(EntityPlayer entityPlayer, World world, int posX, int posY, int posZ)
  10.     {
  11.         super(new ContainerSawmill(entityPlayer.inventory, world, posX, posY, posZ));
  12.     }
  13.  
  14.     @Override
  15.     protected void drawGuiContainerForegroundLayer()
  16.     {
  17.         fontRenderer.drawString("Sawmill", 8, 6, 4210752);
  18.         fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, 39,
  19.             4210752);
  20.     }
  21.  
  22.     @Override
  23.     protected void drawGuiContainerBackgroundLayer(float var1, int var2, int var3)
  24.     {
  25.         int var4 = this.mc.renderEngine.getTexture("/mod/gui/sawmill.png");
  26.         GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
  27.         this.mc.renderEngine.bindTexture(var4);
  28.         int var5 = (this.width - this.xSize) / 2;
  29.         int var6 = (this.height - this.ySize) / 2;
  30.         this.drawTexturedModalRect(var5, var6, 0, 0, this.xSize, this.ySize);
  31.     }
  32.  
  33. }
  34.  
  35. // ContainerSawmill.java
  36. package net.minecraft.src;
  37.  
  38. public class ContainerSawmill extends Container
  39. {
  40.  
  41.     private InventoryCrafting craftMatrix;
  42.     private IInventory craftResult;
  43.  
  44.     private World world;
  45.     private int posX;
  46.     private int posY;
  47.     private int posZ;
  48.  
  49.     public ContainerSawmill(InventoryPlayer inventoryPlayer, World world, int posX, int posY,
  50.         int posZ)
  51.     {
  52.         craftMatrix = new InventoryCrafting(this, 3, 1);
  53.         craftResult = new InventoryCraftResult();
  54.  
  55.         this.world = world;
  56.         this.posX = posX;
  57.         this.posY = posY;
  58.         this.posZ = posZ;
  59.  
  60.         addSlotToContainer(new SlotCrafting(inventoryPlayer.player, craftMatrix, craftResult, 0,
  61.             124, 19));
  62.         for (int i = 0; i < 3; ++i)
  63.         {
  64.             addSlotToContainer(new Slot(craftMatrix, i, 33 + i * 18, 19));
  65.         }
  66.  
  67.         for (int i = 0; i < 3; ++i)
  68.         {
  69.             for (int j = 0; j < 9; ++j)
  70.             {
  71.                 addSlotToContainer(new Slot(inventoryPlayer, j + i * 9 + 9, 8 + j * 18, 52 + i * 18));
  72.             }
  73.         }
  74.  
  75.         for (int i = 0; i < 9; ++i)
  76.         {
  77.             addSlotToContainer(new Slot(inventoryPlayer, i, 8 + i * 18, 110));
  78.         }
  79.  
  80.         onCraftMatrixChanged(craftMatrix);
  81.     }
  82.  
  83.     @Override
  84.     public void onCraftMatrixChanged(IInventory inventory)
  85.     {
  86.         // TODO
  87.         this.craftResult.setInventorySlotContents(0, new ItemStack(Block.dirt));
  88.     }
  89.  
  90.     @Override
  91.     public void onCraftGuiClosed(EntityPlayer entityPlayer)
  92.     {
  93.         super.onCraftGuiClosed(entityPlayer);
  94.  
  95.         if (!world.isRemote)
  96.         {
  97.             for (int i = 0; i < 3; ++i)
  98.             {
  99.                 ItemStack item = craftMatrix.getStackInSlotOnClosing(i);
  100.  
  101.                 if (item != null)
  102.                 {
  103.                     entityPlayer.dropPlayerItem(item);
  104.                 }
  105.             }
  106.         }
  107.     }
  108.  
  109.     @Override
  110.     public boolean canInteractWith(EntityPlayer entityPlayer)
  111.     {
  112.         return world.getBlockId(posX, posY, posZ) != mod_WizardCraft.sawmill.blockID
  113.             && entityPlayer.getDistanceSq(posX + .5D, posY + .5D, posZ + .5D) <= 64D;
  114.     }
  115.  
  116. }
Advertisement
Add Comment
Please, Sign In to add comment