improve hotbar gui
This commit is contained in:
parent
e1759b853e
commit
030268bfc3
2 changed files with 21 additions and 7 deletions
|
@ -1077,12 +1077,13 @@ public class Client implements IThreadListener {
|
|||
int selected = this.player.getSelectedIndex();
|
||||
int scale = this.scaleHotbar ? 2 : 1;
|
||||
int size = this.player.getHotbarSize();
|
||||
int x = this.fbX / 2 - size * (size <= 12 ? 10 : 6) * scale + 2 * scale - (size > 12 && selected != 0 ? 20 - 12 : 0) * scale;
|
||||
int y = this.fbY - 20 * scale;
|
||||
for(int n = 0; n < size; n++) {
|
||||
int x = this.fbX / 2 - size * 10 * scale + n * 20 * scale + 2 * scale;
|
||||
int y = this.fbY - 20 * scale;
|
||||
if(selected == n)
|
||||
Drawing.drawRect(x - scale * 2, y - scale * 2, 20 * scale, 20 * scale, 0xffffffff);
|
||||
InventoryButton.drawButton(this, x - scale, y - scale, 18 * scale, 18 * scale, this.scaleHotbar);
|
||||
x += (size <= 12 || selected == n || selected == n + 1 ? 20 : 12) * scale;
|
||||
}
|
||||
|
||||
ItemStack itemstack = this.player.getHeldItem();
|
||||
|
@ -1231,19 +1232,29 @@ public class Client implements IThreadListener {
|
|||
GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
ItemRenderer.enableGUIStandardItemLighting();
|
||||
GL11.glPushMatrix();
|
||||
int selected = this.player.getSelectedIndex();
|
||||
int scale = this.scaleHotbar ? 2 : 1;
|
||||
int size = this.player.getHotbarSize();
|
||||
GL11.glTranslatef((float)(this.fbX / 2 - size * 10 * scale + 2 * scale), (float)(this.fbY - 20 * scale), 0.0f);
|
||||
int bx = this.fbX / 2 - size * (size <= 12 ? 10 : 6) * scale + 2 * scale;
|
||||
int by = this.fbY - 20 * scale;
|
||||
GL11.glTranslatef((float)bx, (float)by, 0.0f);
|
||||
if(this.scaleHotbar)
|
||||
GL11.glScalef(2.0f, 2.0f, 2.0f);
|
||||
|
||||
int xPos = - (size > 12 && selected != 0 ? 20 - 12 : 0);
|
||||
for(int index = 0; index < size; ++index) {
|
||||
int xPos = index * 20;
|
||||
ItemStack itemstack = this.player.getStackInSlot(index);
|
||||
if(itemstack != null) {
|
||||
if(size > 12 && selected != index && selected != index + 1 && index != size - 1) {
|
||||
this.scissor(bx + xPos * scale, this.fbY - (by + 16 * scale), 11 * scale, 16 * scale);
|
||||
GL11.glEnable(GL11.GL_SCISSOR_TEST);
|
||||
}
|
||||
GlState.enableDepth();
|
||||
this.renderItem.renderItemAndEffectIntoGUI(itemstack, xPos, 0);
|
||||
if(size > 12 && selected != index && selected != index + 1 && index != size - 1)
|
||||
GL11.glDisable(GL11.GL_SCISSOR_TEST);
|
||||
}
|
||||
xPos += size <= 12 || selected == index || selected == index + 1 ? 20 : 12;
|
||||
}
|
||||
|
||||
if(this.infoOverlay) {
|
||||
|
@ -1273,14 +1284,17 @@ public class Client implements IThreadListener {
|
|||
GlState.enableBlend();
|
||||
GlState.disableDepth();
|
||||
if(this.world != null && this.open == null && this.player != null && this.viewEntity == this.player) {
|
||||
int selected = this.player.getSelectedIndex();
|
||||
int scale = this.scaleHotbar ? 2 : 1;
|
||||
int size = this.player.getHotbarSize();
|
||||
int xPos = - (size > 12 && selected != 0 ? 20 - 12 : 0) * scale;
|
||||
for(int index = 0; index < size; ++index) {
|
||||
ItemStack itemstack = this.player.getStackInSlot(index);
|
||||
if(itemstack != null) {
|
||||
if(itemstack != null && (size <= 12 || index == selected)) {
|
||||
GuiContainer.renderItemOverlay(itemstack,
|
||||
this.fbX / 2 - size * 10 * scale + 2 * scale + index * 20 * scale, this.fbY - 20 * scale, null, index == this.player.getSelectedIndex() ? this.controller.getUseCooldown() : 0, this.controller.getUseCooldownMax(), scale);
|
||||
this.fbX / 2 - size * (size <= 12 ? 10 : 6) * scale + 2 * scale + xPos, this.fbY - 20 * scale, null, index == this.player.getSelectedIndex() ? this.controller.getUseCooldown() : 0, this.controller.getUseCooldownMax(), scale);
|
||||
}
|
||||
xPos += (size <= 12 || selected == index || selected == index + 1 ? 20 : 12) * scale;
|
||||
}
|
||||
}
|
||||
if(this.open != null)
|
||||
|
|
|
@ -2484,7 +2484,7 @@ public abstract class EntityNPC extends EntityLiving implements IInventory
|
|||
}
|
||||
|
||||
public int getHotbarSize() {
|
||||
return 12;
|
||||
return this.getInventoryCapacity();
|
||||
}
|
||||
|
||||
public int getSelectedIndex() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue