diff --git a/client/src/main/java/client/gui/container/GuiContainer.java b/client/src/main/java/client/gui/container/GuiContainer.java index 3c106894..69e0dde3 100755 --- a/client/src/main/java/client/gui/container/GuiContainer.java +++ b/client/src/main/java/client/gui/container/GuiContainer.java @@ -76,6 +76,8 @@ public abstract class GuiContainer extends Gui private boolean isScrolling; private boolean wasClicking; private ItemStack cheatStack; + private int cheatWidth; + private int cheatHeight; public void drawString(String text, int x, int y) { x = x * 2 + this.container_x; @@ -183,6 +185,8 @@ public abstract class GuiContainer extends Gui // this.guiTop = (this.height - this.ySize) / 2; // this.addButtons(); if(this.gm.itemCheat) { + this.cheatWidth = Math.max((this.gm.fb_x - this.container_x - this.container_w - 32) / 2 / 18, 1); + this.cheatHeight = Math.max((this.gm.fb_y - this.container_y - 20 * 2 * ((CheatTab.values().length + (this.cheatWidth - 1)) / this.cheatWidth) - 64) / 2 / 18, 1); // CheatTab i = selectedTab; // selectedTab = null; this.setCurrentTab(selectedTab); @@ -198,14 +202,14 @@ public abstract class GuiContainer extends Gui } } if(this.gm.itemCheat) { - for (int k = 0; k < 9; ++k) + for (int k = 0; k < this.cheatHeight; ++k) { - for (int l = 0; l < 12; ++l) { + for (int l = 0; l < this.cheatWidth; ++l) { this.button(this.xSize + 2 + 18 * l, k * 18, 18, 18); } } for(CheatTab tab : CheatTab.values()) { - this.button(this.xSize + 2 + 18 * tab.getHorizontal(), 9 * 18 + 4 + 20 * tab.getVertical(), 18, 18); + this.button(this.xSize + 2 + 18 * (tab.getIndex() % this.cheatWidth), this.cheatHeight * 18 + 4 + 20 * (tab.getIndex() / this.cheatWidth), 18, 18); } } } @@ -223,7 +227,7 @@ public abstract class GuiContainer extends Gui } if(this.gm.itemCheat) { - int i = (ITEM_LIST.size() + 12 - 1) / 12 - 9; + int i = (ITEM_LIST.size() + this.cheatWidth - 1) / this.cheatWidth - this.cheatHeight; int j = (int)((double)(this.currentScroll * (float)i) + 0.5D); if (j < 0) @@ -231,11 +235,11 @@ public abstract class GuiContainer extends Gui j = 0; } - for (int k = 0; k < 9; ++k) + for (int k = 0; k < this.cheatHeight; ++k) { - for (int l = 0; l < 12; ++l) + for (int l = 0; l < this.cheatWidth; ++l) { - int i1 = l + (k + j) * 12; + int i1 = l + (k + j) * this.cheatWidth; if (i1 >= 0 && i1 < ITEM_LIST.size()) { @@ -277,7 +281,7 @@ public abstract class GuiContainer extends Gui return; if(this.gm.itemCheat) { boolean flag = Button.MOUSE_LEFT.isDown(); //TODO: remove? - int x1 = this.xSize + 2 + 12 * 18 + 1; + int x1 = this.xSize + 2 + this.cheatWidth * 18 + 1; int y1 = 1; int x2 = x1 + 10; int y2 = y1 + 112 + 18 * 4; @@ -419,20 +423,20 @@ public abstract class GuiContainer extends Gui super.draw(); if(this.gm.itemCheat) { if(this.needsScrollBars()) { - int i = this.xSize + 2 + 12 * 18 + 1; + int i = this.xSize + 2 + this.cheatWidth * 18 + 1; int j = 1; int k = j + 184; this.rect(i, j, 8, 182, 0x000000); this.grad(i, j + (int)((float)(k - j - 17) * this.currentScroll), 8, 15, this.gm.style.fill_top, this.gm.style.fill_btm, this.gm.style.brdr_top, this.gm.style.brdr_btm); } - this.rect(this.xSize + 2 + 18 * selectedTab.getHorizontal(), 9 * 18 + 4 + 20 * selectedTab.getVertical() - 2, 18, 2, 0xffffff); + this.rect(this.xSize + 2 + 18 * (selectedTab.getIndex() % this.cheatWidth), this.cheatHeight * 18 + 4 + 20 * (selectedTab.getIndex() / this.cheatWidth) - 2, 18, 2, 0xffffff); } this.drawGuiContainerBackgroundLayer(); if(this.gm.itemCheat) { // CheatTab tab = CheatTab.TABS[selectedTab]; this.drawString(selectedTab.getName(), this.xSize + 2 + 4, -10); - this.drawString("Vorsicht: Schummeln wird mit Keule bestraft", this.xSize + 2 + 4, 18 * (9 + (CheatTab.values().length + 11) / 12) + 10); - this.drawString("(Halte Strg beim Klick für vollen Stapel)", this.xSize + 2 + 4, 18 * (9 + (CheatTab.values().length + 11) / 12) + 20); + this.drawString("Vorsicht: Schummeln wird mit Keule bestraft", this.xSize + 2 + 4, 18 * this.cheatHeight + 20 * ((CheatTab.values().length + (this.cheatWidth - 1)) / this.cheatWidth) + 10); + this.drawString("(Halte Strg beim Klick für vollen Stapel)", this.xSize + 2 + 4, 18 * this.cheatHeight + 20 * ((CheatTab.values().length + (this.cheatWidth - 1)) / this.cheatWidth) + 20); } this.drawGuiContainerForegroundLayer(); } @@ -1066,13 +1070,13 @@ public abstract class GuiContainer extends Gui protected boolean isInsideTab(CheatTab tab, int x, int y) { - return x >= this.xSize + 2 + 18 * tab.getHorizontal() && x < this.xSize + 2 + 18 * tab.getHorizontal() + 18 && - y >= 9 * 18 + 4 + 20 * tab.getVertical() && y < 9 * 18 + 4 + 20 * tab.getVertical() + 18; + return x >= this.xSize + 2 + 18 * (tab.getIndex() % this.cheatWidth) && x < this.xSize + 2 + 18 * (tab.getIndex() % this.cheatWidth) + 18 && + y >= this.cheatHeight * 18 + 4 + 20 * (tab.getIndex() / this.cheatWidth) && y < this.cheatHeight * 18 + 4 + 20 * (tab.getIndex() / this.cheatWidth) + 18; } protected boolean renderInventoryHoveringText(CheatTab tab, int x, int z) { - if (this.isPointInRegion(this.xSize + 2 + 18 * tab.getHorizontal(), 9 * 18 + 4 + 20 * tab.getVertical(), 18, 18, x, z)) + if (this.isPointInRegion(this.xSize + 2 + 18 * (tab.getIndex() % this.cheatWidth), this.cheatHeight * 18 + 4 + 20 * (tab.getIndex() / this.cheatWidth), 18, 18, x, z)) { this.hover(tab.getName(), x, z); return true; @@ -1088,14 +1092,14 @@ public abstract class GuiContainer extends Gui this.itemRender.zLevel = 100.0F; ItemStack itemstack = tab.getIcon(); GlState.enableDepth(); - this.itemRender.renderItemAndEffectIntoGUI(itemstack, this.xSize + 2 + 18 * tab.getHorizontal() + 1, 9 * 18 + 4 + 20 * tab.getVertical() + 1); + this.itemRender.renderItemAndEffectIntoGUI(itemstack, this.xSize + 2 + 18 * (tab.getIndex() % this.cheatWidth) + 1, this.cheatHeight * 18 + 4 + 20 * (tab.getIndex() / this.cheatWidth) + 1); this.itemRender.zLevel = 0.0F; } public void scroll(int scr_x, int scr_y, int x, int y, boolean ctrl, boolean shift) { super.scroll(scr_x, scr_y, x, y, ctrl, shift); if(this.gm.itemCheat && scr_y != 0 && this.needsScrollBars()) { - int len = ITEM_LIST.size() / 12 - 5; + int len = ITEM_LIST.size() / this.cheatWidth - 5; this.currentScroll = (float)((double)this.currentScroll - (double)scr_y / (double)len); this.currentScroll = ExtMath.clampf(this.currentScroll, 0.0F, 1.0F); } @@ -1103,7 +1107,7 @@ public abstract class GuiContainer extends Gui private boolean needsScrollBars() { - return ITEM_LIST.size() > 12 * 9; + return ITEM_LIST.size() > this.cheatWidth * this.cheatHeight; } private void setCurrentTab(CheatTab tab) @@ -1117,8 +1121,8 @@ public abstract class GuiContainer extends Gui } private boolean clickSide(int mouseX, int mouseY, int slot, boolean instant, boolean full) { - if(this.gm.itemCheat && this.isPointInRegion(this.xSize + 2, 0, 18 * 12, 18 * 9, mouseX, mouseY) && this.gm.player != null && this.gm.player.inventory.getItemStack() == null && this.cheatStack == null) { - int i = (ITEM_LIST.size() + 12 - 1) / 12 - 9; + if(this.gm.itemCheat && this.isPointInRegion(this.xSize + 2, 0, 18 * this.cheatWidth, 18 * this.cheatHeight, mouseX, mouseY) && this.gm.player != null && this.gm.player.inventory.getItemStack() == null && this.cheatStack == null) { + int i = (ITEM_LIST.size() + this.cheatWidth - 1) / this.cheatWidth - this.cheatHeight; int j = (int)((double)(this.currentScroll * (float)i) + 0.5D); if (j < 0) @@ -1128,7 +1132,7 @@ public abstract class GuiContainer extends Gui int sx = (mouseX - (this.xSize + 2)) / 18; int sy = mouseY / 18; - int i1 = sx + (sy + j) * 12; + int i1 = sx + (sy + j) * this.cheatWidth; if(i1 >= 0 && i1 < ITEM_LIST.size()) { if(slot >= 0 || instant) { diff --git a/common/src/main/java/common/item/CheatTab.java b/common/src/main/java/common/item/CheatTab.java index 3817234d..d824e096 100755 --- a/common/src/main/java/common/item/CheatTab.java +++ b/common/src/main/java/common/item/CheatTab.java @@ -100,12 +100,8 @@ public enum CheatTab { this.name = name; } - public int getHorizontal() { - return this.ordinal() % 12; - } - - public int getVertical() { - return this.ordinal() / 12; + public int getIndex() { + return this.ordinal(); } public String getName() {