improve container gui
This commit is contained in:
parent
5421552dde
commit
448d54c441
1 changed files with 16 additions and 25 deletions
|
@ -1176,7 +1176,6 @@ public class Client implements IThreadListener {
|
|||
|
||||
public void renderHud() {
|
||||
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;
|
||||
int total = 1;
|
||||
if(this.world != null && this.player != null && this.viewEntity == this.player) {
|
||||
|
@ -1188,10 +1187,10 @@ public class Client implements IThreadListener {
|
|||
if(total == 0)
|
||||
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 by = this.fbY - 20 * scale;
|
||||
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 by = this.fbY - 40;
|
||||
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();
|
||||
if(this.world != null && !(this.open instanceof GuiConsole) && this.player != null && this.viewEntity == this.player) {
|
||||
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++) {
|
||||
if(this.player.getStackInSlot(n) == null || this.player.getStackInSlot(n).getItem().getCategory() != this.itemSelection)
|
||||
continue;
|
||||
if(selected == n)
|
||||
Drawing.drawRect(x - scale * 2, by - scale * 2, 20 * scale, 20 * scale, 0xffffffff);
|
||||
InventoryButton.drawButton(this, x - scale, by - scale, 18 * scale, 18 * scale);
|
||||
x += (width >= 20 || selected == n || selected == n + 1 ? 20 : width) * scale;
|
||||
Drawing.drawRect(x - 4, by - 4, 40, 40, 0xffffffff);
|
||||
InventoryButton.drawButton(this, x - 2, by - 2, 36, 36);
|
||||
x += width >= 40 || selected == n || selected == n + 1 ? 40 : width;
|
||||
}
|
||||
|
||||
ItemStack itemstack = this.player.getHeldItem();
|
||||
|
@ -1371,24 +1370,21 @@ public class Client implements IThreadListener {
|
|||
GlState.enableBlend();
|
||||
GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
ItemRenderer.enableGUIStandardItemLighting();
|
||||
GL15.glPushMatrix();
|
||||
GL15.glTranslatef(0.0f, (float)by, 0.0f);
|
||||
GL15.glScalef(2.0f, 2.0f, 2.0f);
|
||||
|
||||
int xPos = xoff;
|
||||
int cnt = 0;
|
||||
for(int index = 0; index < size; ++index) {
|
||||
ItemStack itemstack = this.player.getStackInSlot(index);
|
||||
if(itemstack != null && itemstack.getItem().getCategory() == this.itemSelection) {
|
||||
if(width < 20 && selected != index && selected != index + 1 && cnt != total - 1) {
|
||||
this.scissor(xPos * scale, this.fbY - (by + 16 * scale), (width - 1) * scale, 16 * scale);
|
||||
if(width < 40 && selected != index && selected != index + 1 && cnt != total - 1) {
|
||||
this.scissor(xPos, this.fbY - (by + 32), width - 2, 32);
|
||||
GL15.glEnable(GL15.GL_SCISSOR_TEST);
|
||||
}
|
||||
GlState.enableDepth();
|
||||
this.renderItem.renderItemAndEffectIntoGUI(itemstack, xPos, 0);
|
||||
if(width < 20 && selected != index && selected != index + 1 && cnt != total - 1)
|
||||
this.renderItem.renderItemAndEffectIntoGUI(itemstack, xPos, by);
|
||||
if(width < 40 && selected != index && selected != index + 1 && cnt != total - 1)
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -1400,16 +1396,11 @@ public class Client implements IThreadListener {
|
|||
else if(this.pointed != null && this.pointed.type == ObjectType.ENTITY && this.pointed.entity != null)
|
||||
item = this.pointed.entity.getItem();
|
||||
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();
|
||||
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();
|
||||
GlState.disableRescaleNormal();
|
||||
GlState.disableBlend();
|
||||
|
@ -1420,15 +1411,15 @@ public class Client implements IThreadListener {
|
|||
GlState.enableBlend();
|
||||
GlState.disableDepth();
|
||||
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) {
|
||||
ItemStack itemstack = this.player.getStackInSlot(index);
|
||||
if(itemstack != null && itemstack.getItem().getCategory() == this.itemSelection) {
|
||||
if(width >= 17 || index == selected) {
|
||||
if(width >= 34 || index == selected) {
|
||||
GuiContainer.renderItemOverlay(itemstack,
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue