Implement new chisel GUI

This commit is contained in:
tterrag1098 committed 2015-01-12 19:24:29 -05:00
1 parent 0420b1655c
commit 53c13c48c4
5 files changed
+43 -32

No files matched your search

@@ -4,11 +4,13 @@ import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import org.lwjgl.opengl.GL11;
import com.cricketcraft.chisel.inventory.ContainerChisel;
import com.cricketcraft.chisel.inventory.InventoryChiselSelection;
import com.cricketcraft.chisel.inventory.SlotChiselInput;
import com.cricketcraft.chisel.utils.GeneralClient;
public class GuiChisel extends GuiContainer {
@@ -20,6 +22,7 @@ public class GuiChisel extends GuiContainer {
super(new ContainerChisel(iinventory, menu));
player = iinventory.player;
height = 177;
xSize = 252;
container = (ContainerChisel) inventorySlots;
}
@@ -30,16 +33,12 @@ public class GuiChisel extends GuiContainer {
inventorySlots.onContainerClosed(player);
}
boolean isExtended() {
return container.inventory.activeVariations > 16;
}
@Override
protected void drawGuiContainerForegroundLayer(int j, int i) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
String line = isExtended() ? I18n.format(this.container.inventory.getInventoryName() + ".titleShort") : I18n.format(this.container.inventory.getInventoryName() + ".title");
fontRendererObj.drawString(line, 88 - fontRendererObj.getStringWidth(line) / 2, 13, 0x404040);
String line = I18n.format(this.container.inventory.getInventoryName() + ".title");
fontRendererObj.drawSplitString(line, 50 - fontRendererObj.getStringWidth(line) / 2, 60, 40, 0x404040);
}
@Override
@@ -50,9 +49,25 @@ public class GuiChisel extends GuiContainer {
int i = width - xSize >> 1;
int j = height - ySize >> 1;
String texture = isExtended() ? "chisel:textures/chisel-gui-24.png" : "chisel:textures/chisel-gui.png";
String texture = "chisel:textures/chisel2Gui.png";
GeneralClient.bind(texture);
drawTexturedModalRect(i, j, 0, 0, xSize, ySize);
}
@Override
protected void func_146977_a(Slot slot) {
if (slot instanceof SlotChiselInput) {
GL11.glPushMatrix();
GL11.glScalef(2, 2, 2);
slot.xDisplayPosition -= 16;
slot.yDisplayPosition -= 16;
super.func_146977_a(slot);
slot.xDisplayPosition += 16;
slot.yDisplayPosition += 16;
GL11.glPopMatrix();
} else {
super.func_146977_a(slot);
}
}
}
@@ -26,33 +26,26 @@ public class ContainerChisel extends Container {
currentIndex = playerInventory.currentItem;
inv.container = this;
int[] leftOffsets = { 8, 26, 134, 152, 44, 116 };
int[] topOffsets = { 8, 26, 44, 62 };
int top = 8, left = 62;
for (int i = 0; i < 2; i++) {
for (int y = 0; y < 4; y++) {
for (int x = 0; x < 2; x++) {
addSlotToContainer(new SlotChiselSelection(this, inventory, inventory, x + i * 8 + y * 2, leftOffsets[x + i * 2], topOffsets[y]));
}
}
// selection slots
for (int i = 0; i < 40; i++) {
addSlotToContainer(new SlotChiselSelection(this, inventory, inventory, i, left + ((i % 10) * 18), top + ((i / 10) * 18)));
}
// main slot
addSlotToContainer(new SlotChiselInput(this, inventory, InventoryChiselSelection.normalSlots, 24, 24));
for (int y = 0; y < 4; y++) {
for (int x = 0; x < 2; x++) {
addSlotToContainer(new SlotChiselSelection(this, inventory, inventory, 16 + x + y * 2, leftOffsets[4 + x], topOffsets[3 - y]));
}
top = 84;
left = 71;
// main inv
for (int i = 0; i < 27; i++) {
addSlotToContainer(new Slot(inventoryplayer, i + 9, left + ((i % 9) * 18), top + (i / 9) * 18));
}
addSlotToContainer(new SlotChiselInput(this, inventory, InventoryChiselSelection.normalSlots, 80, 35));
for (int k = 0; k < 3; k++) {
for (int j1 = 0; j1 < 9; j1++) {
addSlotToContainer(new Slot(inventoryplayer, j1 + k * 9 + 9, 8 + j1 * 18, 102 + k * 18 - 18));
}
}
for (int l = 0; l < 9; l++) {
addSlotToContainer(l == currentIndex ? new SlotChiselPlayer(this, inventoryplayer, l, 8 + l * 18, 160 - 18) : new Slot(inventoryplayer, l, 8 + l * 18, 160 - 18));
top = 142;
for (int i = 0; i < 9; i++) {
addSlotToContainer(new Slot(inventoryplayer, i, left + ((i % 9) * 18), top + (i / 9) * 18));
}
chisel = inventoryplayer.getCurrentItem();
@@ -143,7 +136,7 @@ public class ContainerChisel extends Container {
return;
General.setChiselTarget(chisel, inventory.getStackInSpecialSlot());
playerInventory.mainInventory[currentIndex] = chisel;
}
}
@@ -13,7 +13,7 @@ import com.cricketcraft.chisel.item.chisel.ItemChisel;
public class InventoryChiselSelection implements IInventory {
ItemStack chisel = null;
public final static int normalSlots = 32;
public final static int normalSlots = 40;
public int activeVariations = 0;
ContainerChisel container;
ItemStack[] inventory;