improve container gui
This commit is contained in:
parent
581a6215ff
commit
fe4a8fa6a5
4 changed files with 54 additions and 36 deletions
|
@ -566,7 +566,7 @@ public class Client implements IThreadListener {
|
|||
public LocalPos pointedLiquid;
|
||||
public DisplayMode vidMode;
|
||||
public String dimensionName;
|
||||
public ItemCategory itemSelection = ItemCategory.USEABLE;
|
||||
public ItemCategory itemSelection = null;
|
||||
private ChunkClient emptyChunk;
|
||||
private ChunkClient outsideChunk;
|
||||
|
||||
|
@ -828,7 +828,7 @@ public class Client implements IThreadListener {
|
|||
this.player = null;
|
||||
this.serverInfo = null;
|
||||
Arrays.fill(this.lastSelection, 0);
|
||||
this.itemSelection = ItemCategory.USEABLE;
|
||||
this.itemSelection = null;
|
||||
this.lastTickTime = -1;
|
||||
this.selectedCharacter = -1;
|
||||
this.playerList.clear();
|
||||
|
@ -960,6 +960,10 @@ public class Client implements IThreadListener {
|
|||
{
|
||||
this.category(this.shift() ? -1 : 1);
|
||||
}
|
||||
if (Bind.DESELECT.isPressed() && this.viewEntity == this.player)
|
||||
{
|
||||
this.deselect();
|
||||
}
|
||||
|
||||
boolean hadZoom = this.zooming;
|
||||
this.zooming = Bind.ZOOM.isDown() || this.viewEntity != this.player;
|
||||
|
@ -970,7 +974,7 @@ public class Client implements IThreadListener {
|
|||
if(this.viewEntity == this.player) {
|
||||
for (int l = 0; l < this.keyBindsHotbar.length && l < this.player.getHotbarSize(); ++l)
|
||||
{
|
||||
if (this.keyBindsHotbar[l].isPressed())
|
||||
if (this.keyBindsHotbar[l].isPressed() && this.itemSelection != null)
|
||||
{
|
||||
int n = 0;
|
||||
for(int z = 0; z < this.player.getHotbarSize(); z++) {
|
||||
|
@ -1112,7 +1116,7 @@ public class Client implements IThreadListener {
|
|||
|
||||
this.displayTick(ExtMath.floord(this.player.posX), ExtMath.floord(this.player.posY), ExtMath.floord(this.player.posZ));
|
||||
this.effectRenderer.update();
|
||||
if(this.player != null && (this.player.getHeldItem() == null || this.player.getHeldItem().getItem().getCategory() != this.itemSelection))
|
||||
if(this.player != null && this.itemSelection != null && (this.player.getHeldItem() == null || this.player.getHeldItem().getItem().getCategory() != this.itemSelection))
|
||||
this.select(1);
|
||||
}
|
||||
else if (this.connection != null)
|
||||
|
@ -1178,7 +1182,7 @@ public class Client implements IThreadListener {
|
|||
final int selected = this.world != null && this.player != null && this.viewEntity == this.player ? this.player.getSelectedIndex() : -1;
|
||||
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) {
|
||||
if(this.world != null && this.player != null && this.viewEntity == this.player && this.itemSelection != null) {
|
||||
total = 0;
|
||||
for(int z = 0; z < this.player.getHotbarSize(); z++) {
|
||||
if(this.player.getStackInSlot(z) != null && this.player.getStackInSlot(z).getItem().getCategory() == this.itemSelection)
|
||||
|
@ -1211,14 +1215,16 @@ public class Client implements IThreadListener {
|
|||
}
|
||||
}
|
||||
|
||||
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 - 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;
|
||||
if(this.itemSelection != null) {
|
||||
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 - 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,21 +1377,23 @@ public class Client implements IThreadListener {
|
|||
GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
ItemRenderer.enableGUIStandardItemLighting();
|
||||
|
||||
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 < 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);
|
||||
if(this.itemSelection != null) {
|
||||
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 < 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, by);
|
||||
if(width < 40 && selected != index && selected != index + 1 && cnt != total - 1)
|
||||
GL15.glDisable(GL15.GL_SCISSOR_TEST);
|
||||
xPos += width >= 40 || selected == index || selected == index + 1 ? 40 : width;
|
||||
++cnt;
|
||||
}
|
||||
GlState.enableDepth();
|
||||
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 >= 40 || selected == index || selected == index + 1 ? 40 : width;
|
||||
++cnt;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1410,7 +1418,7 @@ public class Client implements IThreadListener {
|
|||
GlState.disableCull();
|
||||
GlState.enableBlend();
|
||||
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 && this.itemSelection != null) {
|
||||
int xPos = xoff;
|
||||
for(int index = 0; index < size; ++index) {
|
||||
ItemStack itemstack = this.player.getStackInSlot(index);
|
||||
|
@ -1536,17 +1544,15 @@ public class Client implements IThreadListener {
|
|||
public void scroll(int dir) {
|
||||
if(this.zooming)
|
||||
this.zoomLevel = ExtMath.clampf(this.zoomLevel + (dir < 0 ? -0.25f : 0.25f), this.viewEntity != this.player ? 1.0f : 2.0f, 16.0f);
|
||||
else if(this.player != null)
|
||||
else if(this.player != null && this.itemSelection != null)
|
||||
this.select(-dir);
|
||||
}
|
||||
|
||||
private void select(int dir) {
|
||||
int last = this.player.getSelectedIndex();
|
||||
if(last < 0)
|
||||
this.player.setSelectedIndex(last = 0);
|
||||
int n = 0;
|
||||
if(last < 0) {
|
||||
last = 0;
|
||||
this.player.setSelectedIndex(0);
|
||||
}
|
||||
boolean any = false;
|
||||
do {
|
||||
this.player.setSelectedIndex(this.player.getSelectedIndex() + dir);
|
||||
|
@ -1566,6 +1572,8 @@ public class Client implements IThreadListener {
|
|||
|
||||
private void category(int dir) {
|
||||
ItemCategory last = this.itemSelection;
|
||||
if(last == null)
|
||||
this.itemSelection = last = ItemCategory.USEABLE;
|
||||
this.lastSelection[last.ordinal()] = this.player.getSelectedIndex() >= 0 ? this.player.getSelectedIndex() : 0;
|
||||
int total;
|
||||
int n = 0;
|
||||
|
@ -1591,6 +1599,13 @@ public class Client implements IThreadListener {
|
|||
}
|
||||
}
|
||||
|
||||
private void deselect() {
|
||||
if(this.itemSelection != null)
|
||||
this.lastSelection[this.itemSelection.ordinal()] = this.player.getSelectedIndex() >= 0 ? this.player.getSelectedIndex() : 0;
|
||||
this.itemSelection = null;
|
||||
this.player.setSelectedIndex(-1);
|
||||
}
|
||||
|
||||
public void moveCamera(float x, float y) {
|
||||
this.deltaX += x;
|
||||
this.deltaY += y;
|
||||
|
|
|
@ -577,6 +577,10 @@ public class ClientPlayer implements IClientPlayer
|
|||
this.gm.itemSelection = this.gm.player.getHeldItem().getItem().getCategory();
|
||||
this.gm.lastSelection[this.gm.itemSelection.ordinal()] = this.gm.player.getSelectedIndex();
|
||||
}
|
||||
else {
|
||||
this.gm.itemSelection = null;
|
||||
this.gm.player.setSelectedIndex(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ public enum Bind implements Identifyable, CVar {
|
|||
FAST(BindCategory.MOVEMENT, "fast", "Schneller", Keysym.LEFT_SHIFT),
|
||||
INVENTORY(BindCategory.INTERACTION, "inventory", "Inventar", Keysym.E),
|
||||
ITEMMODE(BindCategory.INTERACTION, "itemmode", "Kategorie", Keysym.TAB),
|
||||
DESELECT(BindCategory.INTERACTION, "deselect", "Abwählen", Keysym.F),
|
||||
PRIMARY(BindCategory.INTERACTION, "primary", "Primäre Aktion", Button.MOUSE_LEFT),
|
||||
SECONDARY(BindCategory.INTERACTION, "secondary", "Sekundäre Aktion", Button.MOUSE_RIGHT),
|
||||
TERTIARY(BindCategory.INTERACTION, "tertiary", "Tertiäre Aktion", Button.MOUSE_MIDDLE),
|
||||
|
|
|
@ -3319,7 +3319,7 @@ public abstract class EntityNPC extends EntityLiving implements IInventory
|
|||
if(stack != null)
|
||||
this.setInventorySlotContents(z, stack);
|
||||
}
|
||||
this.setSelectedIndex(this.isPlayer() || this.dummy ? tag.getInt("selected") : 0);
|
||||
this.setSelectedIndex(this.isPlayer() || this.dummy ? -1 : 0);
|
||||
for(Equipment slot : Equipment.ARMOR) {
|
||||
this.setArmor(slot, ItemStack.readFromTag(tag.getObject(slot.getName())));
|
||||
}
|
||||
|
@ -3446,8 +3446,6 @@ public abstract class EntityNPC extends EntityLiving implements IInventory
|
|||
}
|
||||
}
|
||||
tag.setList("items", list);
|
||||
if(this.isPlayer() || this.dummy)
|
||||
tag.setInt("selected", this.getSelectedIndex());
|
||||
for(Equipment slot : Equipment.ARMOR) {
|
||||
TagObject item = new TagObject();
|
||||
if(this.getArmor(slot) != null)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue