1
0
Fork 0

improve container gui

This commit is contained in:
Sen 2025-09-07 14:40:34 +02:00
parent 5421552dde
commit 448d54c441
Signed by: sen
GPG key ID: 3AC50A6F47D1B722

View file

@ -1176,7 +1176,6 @@ public class Client implements IThreadListener {
public void renderHud() { public void renderHud() {
final int selected = this.world != null && this.player != null && this.viewEntity == this.player ? this.player.getSelectedIndex() : -1; final int selected = this.world != null && this.player != null && this.viewEntity == this.player ? this.player.getSelectedIndex() : -1;
final int scale = 2;
final int size = this.world != null && this.player != null && this.viewEntity == this.player ? this.player.getHotbarSize() : 1; final int size = this.world != null && this.player != null && this.viewEntity == this.player ? this.player.getHotbarSize() : 1;
int total = 1; int total = 1;
if(this.world != null && this.player != null && this.viewEntity == this.player) { if(this.world != null && this.player != null && this.viewEntity == this.player) {
@ -1188,10 +1187,10 @@ public class Client implements IThreadListener {
if(total == 0) if(total == 0)
total = 1; total = 1;
} }
final int width = (this.fbX / scale - 20) / total; final int width = (this.fbX - 40) / total;
// final int bx = this.fbX / 2 - size * (width >= 20 ? 10 : width / 2) * scale + 2 * scale; // final int bx = this.fbX / 2 - size * (width >= 20 ? 10 : width / 2) * scale + 2 * scale;
final int by = this.fbY - 20 * scale; final int by = this.fbY - 40;
final int xoff = (this.fbX / scale - (width < 20 ? ((total - 2) * width + 40 + width / 2) : (total * 20 - 2))) / 2 + (width < 20 && selected == 0 ? 20 - width : 0) - 2; final int xoff = (this.fbX - (width < 40 ? ((total - 2) * width + 80 + width / 2) : (total * 40 - 4))) / 2 + (width < 40 && selected == 0 ? 40 - width : 0) - 4;
this.setupOverlay(); this.setupOverlay();
if(this.world != null && !(this.open instanceof GuiConsole) && this.player != null && this.viewEntity == this.player) { if(this.world != null && !(this.open instanceof GuiConsole) && this.player != null && this.viewEntity == this.player) {
if(this.open == null) { if(this.open == null) {
@ -1212,14 +1211,14 @@ public class Client implements IThreadListener {
} }
} }
int x = xoff * scale; int x = xoff;
for(int n = 0; n < size; n++) { for(int n = 0; n < size; n++) {
if(this.player.getStackInSlot(n) == null || this.player.getStackInSlot(n).getItem().getCategory() != this.itemSelection) if(this.player.getStackInSlot(n) == null || this.player.getStackInSlot(n).getItem().getCategory() != this.itemSelection)
continue; continue;
if(selected == n) if(selected == n)
Drawing.drawRect(x - scale * 2, by - scale * 2, 20 * scale, 20 * scale, 0xffffffff); Drawing.drawRect(x - 4, by - 4, 40, 40, 0xffffffff);
InventoryButton.drawButton(this, x - scale, by - scale, 18 * scale, 18 * scale); InventoryButton.drawButton(this, x - 2, by - 2, 36, 36);
x += (width >= 20 || selected == n || selected == n + 1 ? 20 : width) * scale; x += width >= 40 || selected == n || selected == n + 1 ? 40 : width;
} }
ItemStack itemstack = this.player.getHeldItem(); ItemStack itemstack = this.player.getHeldItem();
@ -1371,24 +1370,21 @@ public class Client implements IThreadListener {
GlState.enableBlend(); GlState.enableBlend();
GlState.color(1.0F, 1.0F, 1.0F, 1.0F); GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
ItemRenderer.enableGUIStandardItemLighting(); ItemRenderer.enableGUIStandardItemLighting();
GL15.glPushMatrix();
GL15.glTranslatef(0.0f, (float)by, 0.0f);
GL15.glScalef(2.0f, 2.0f, 2.0f);
int xPos = xoff; int xPos = xoff;
int cnt = 0; int cnt = 0;
for(int index = 0; index < size; ++index) { for(int index = 0; index < size; ++index) {
ItemStack itemstack = this.player.getStackInSlot(index); ItemStack itemstack = this.player.getStackInSlot(index);
if(itemstack != null && itemstack.getItem().getCategory() == this.itemSelection) { if(itemstack != null && itemstack.getItem().getCategory() == this.itemSelection) {
if(width < 20 && selected != index && selected != index + 1 && cnt != total - 1) { if(width < 40 && selected != index && selected != index + 1 && cnt != total - 1) {
this.scissor(xPos * scale, this.fbY - (by + 16 * scale), (width - 1) * scale, 16 * scale); this.scissor(xPos, this.fbY - (by + 32), width - 2, 32);
GL15.glEnable(GL15.GL_SCISSOR_TEST); GL15.glEnable(GL15.GL_SCISSOR_TEST);
} }
GlState.enableDepth(); GlState.enableDepth();
this.renderItem.renderItemAndEffectIntoGUI(itemstack, xPos, 0); this.renderItem.renderItemAndEffectIntoGUI(itemstack, xPos, by);
if(width < 20 && selected != index && selected != index + 1 && cnt != total - 1) if(width < 40 && selected != index && selected != index + 1 && cnt != total - 1)
GL15.glDisable(GL15.GL_SCISSOR_TEST); GL15.glDisable(GL15.GL_SCISSOR_TEST);
xPos += width >= 20 || selected == index || selected == index + 1 ? 20 : width; xPos += width >= 40 || selected == index || selected == index + 1 ? 40 : width;
++cnt; ++cnt;
} }
} }
@ -1400,16 +1396,11 @@ public class Client implements IThreadListener {
else if(this.pointed != null && this.pointed.type == ObjectType.ENTITY && this.pointed.entity != null) else if(this.pointed != null && this.pointed.type == ObjectType.ENTITY && this.pointed.entity != null)
item = this.pointed.entity.getItem(); item = this.pointed.entity.getItem();
if(item != null) { if(item != null) {
GL15.glPopMatrix();
GL15.glPushMatrix();
GL15.glTranslatef((float)(this.fbX / 2 - 180 + 4 + 1), (float)(this.hudMargin + 20 + 1), 0.0f);
GL15.glScalef(2.0f, 2.0f, 2.0f);
GlState.enableDepth(); GlState.enableDepth();
this.renderItem.renderItemAndEffectIntoGUI(new ItemStack(item), 0, 0); this.renderItem.renderItemAndEffectIntoGUI(new ItemStack(item), this.fbX / 2 - 180 + 4 + 1, this.hudMargin + 20 + 1);
} }
} }
GL15.glPopMatrix();
ItemRenderer.disableStandardItemLighting(); ItemRenderer.disableStandardItemLighting();
GlState.disableRescaleNormal(); GlState.disableRescaleNormal();
GlState.disableBlend(); GlState.disableBlend();
@ -1420,15 +1411,15 @@ public class Client implements IThreadListener {
GlState.enableBlend(); GlState.enableBlend();
GlState.disableDepth(); GlState.disableDepth();
if(this.world != null && this.open == null && this.player != null && this.viewEntity == this.player) { if(this.world != null && this.open == null && this.player != null && this.viewEntity == this.player) {
int xPos = xoff * scale; int xPos = xoff;
for(int index = 0; index < size; ++index) { for(int index = 0; index < size; ++index) {
ItemStack itemstack = this.player.getStackInSlot(index); ItemStack itemstack = this.player.getStackInSlot(index);
if(itemstack != null && itemstack.getItem().getCategory() == this.itemSelection) { if(itemstack != null && itemstack.getItem().getCategory() == this.itemSelection) {
if(width >= 17 || index == selected) { if(width >= 34 || index == selected) {
GuiContainer.renderItemOverlay(itemstack, GuiContainer.renderItemOverlay(itemstack,
xPos, by, null, index == this.player.getSelectedIndex() ? this.controller.getUseCooldown() : 0, this.controller.getUseCooldownMax()); xPos, by, null, index == this.player.getSelectedIndex() ? this.controller.getUseCooldown() : 0, this.controller.getUseCooldownMax());
} }
xPos += (width >= 20 || selected == index || selected == index + 1 ? 20 : width) * scale; xPos += width >= 40 || selected == index || selected == index + 1 ? 40 : width;
} }
} }
} }