// GuiSawmill.java package net.minecraft.src; import org.lwjgl.opengl.GL11; public class GuiSawmill extends GuiContainer { public GuiSawmill(EntityPlayer entityPlayer, World world, int posX, int posY, int posZ) { super(new ContainerSawmill(entityPlayer.inventory, world, posX, posY, posZ)); } @Override protected void drawGuiContainerForegroundLayer() { fontRenderer.drawString("Sawmill", 8, 6, 4210752); fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, 39, 4210752); } @Override protected void drawGuiContainerBackgroundLayer(float var1, int var2, int var3) { int var4 = this.mc.renderEngine.getTexture("/mod/gui/sawmill.png"); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); this.mc.renderEngine.bindTexture(var4); int var5 = (this.width - this.xSize) / 2; int var6 = (this.height - this.ySize) / 2; this.drawTexturedModalRect(var5, var6, 0, 0, this.xSize, this.ySize); } } // ContainerSawmill.java package net.minecraft.src; public class ContainerSawmill extends Container { private InventoryCrafting craftMatrix; private IInventory craftResult; private World world; private int posX; private int posY; private int posZ; public ContainerSawmill(InventoryPlayer inventoryPlayer, World world, int posX, int posY, int posZ) { craftMatrix = new InventoryCrafting(this, 3, 1); craftResult = new InventoryCraftResult(); this.world = world; this.posX = posX; this.posY = posY; this.posZ = posZ; addSlotToContainer(new SlotCrafting(inventoryPlayer.player, craftMatrix, craftResult, 0, 124, 19)); for (int i = 0; i < 3; ++i) { addSlotToContainer(new Slot(craftMatrix, i, 33 + i * 18, 19)); } for (int i = 0; i < 3; ++i) { for (int j = 0; j < 9; ++j) { addSlotToContainer(new Slot(inventoryPlayer, j + i * 9 + 9, 8 + j * 18, 52 + i * 18)); } } for (int i = 0; i < 9; ++i) { addSlotToContainer(new Slot(inventoryPlayer, i, 8 + i * 18, 110)); } onCraftMatrixChanged(craftMatrix); } @Override public void onCraftMatrixChanged(IInventory inventory) { // TODO this.craftResult.setInventorySlotContents(0, new ItemStack(Block.dirt)); } @Override public void onCraftGuiClosed(EntityPlayer entityPlayer) { super.onCraftGuiClosed(entityPlayer); if (!world.isRemote) { for (int i = 0; i < 3; ++i) { ItemStack item = craftMatrix.getStackInSlotOnClosing(i); if (item != null) { entityPlayer.dropPlayerItem(item); } } } } @Override public boolean canInteractWith(EntityPlayer entityPlayer) { return world.getBlockId(posX, posY, posZ) != mod_WizardCraft.sawmill.blockID && entityPlayer.getDistanceSq(posX + .5D, posY + .5D, posZ + .5D) <= 64D; } }