1
0
Fork 0

add basic inventory mode switch (tab)

This commit is contained in:
Sen 2025-09-05 18:50:20 +02:00
parent 9f452b410e
commit 83dca68f11
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
46 changed files with 198 additions and 22 deletions

View file

@ -468,6 +468,7 @@ public class Client implements IThreadListener {
private boolean saving;
private boolean drawFps;
private boolean drawDebug;
private boolean placeMode;
public boolean jump;
public boolean sneak;
public boolean debugCamEnable;
@ -961,6 +962,11 @@ public class Client implements IThreadListener {
this.renderer.setDisplayListEntitiesDirty();
}
if (Bind.ITEMMODE.isPressed() && this.viewEntity == this.player)
{
this.placeMode ^= true;
}
boolean hadZoom = this.zooming;
this.zooming = Bind.ZOOM.isDown() || this.viewEntity != this.player;
@ -1096,7 +1102,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)
if(this.player != null && (this.player.getHeldItem() == null || !this.player.getHeldItem().getItem().canBeHeld() || (this.player.getHeldItem().getItem().getBlock() != null) != this.placeMode))
this.select(1);
}
else if (this.connection != null)
@ -1166,7 +1172,7 @@ public class Client implements IThreadListener {
if(this.world != null && this.player != null && this.viewEntity == this.player) {
total = 0;
for(int z = 0; z < this.player.getHotbarSize(); z++) {
if(this.player.getStackInSlot(z) != null)
if(this.player.getStackInSlot(z) != null && this.player.getStackInSlot(z).getItem().canBeHeld() && (this.player.getStackInSlot(z).getItem().getBlock() != null) == this.placeMode)
++total;
}
if(total == 0)
@ -1198,7 +1204,7 @@ public class Client implements IThreadListener {
int x = xoff * scale;
for(int n = 0; n < size; n++) {
if(this.player.getStackInSlot(n) == null)
if(this.player.getStackInSlot(n) == null || !this.player.getStackInSlot(n).getItem().canBeHeld() || (this.player.getStackInSlot(n).getItem().getBlock() != null) != this.placeMode)
continue;
if(selected == n)
Drawing.drawRect(x - scale * 2, by - scale * 2, 20 * scale, 20 * scale, 0xffffffff);
@ -1364,7 +1370,7 @@ public class Client implements IThreadListener {
int cnt = 0;
for(int index = 0; index < size; ++index) {
ItemStack itemstack = this.player.getStackInSlot(index);
if(itemstack != null) {
if(itemstack != null && itemstack.getItem().canBeHeld() && (itemstack.getItem().getBlock() != null) == this.placeMode) {
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);
GL15.glEnable(GL15.GL_SCISSOR_TEST);
@ -1408,12 +1414,13 @@ public class Client implements IThreadListener {
int xPos = xoff * scale;
for(int index = 0; index < size; ++index) {
ItemStack itemstack = this.player.getStackInSlot(index);
if(itemstack != null && (width >= 17 || index == selected)) {
GuiContainer.renderItemOverlay(itemstack,
xPos, by, null, index == this.player.getSelectedIndex() ? this.controller.getUseCooldown() : 0, this.controller.getUseCooldownMax(), scale);
}
if(itemstack != null)
if(itemstack != null && itemstack.getItem().canBeHeld() && (itemstack.getItem().getBlock() != null) == this.placeMode) {
if(width >= 17 || index == selected) {
GuiContainer.renderItemOverlay(itemstack,
xPos, by, null, index == this.player.getSelectedIndex() ? this.controller.getUseCooldown() : 0, this.controller.getUseCooldownMax(), scale);
}
xPos += (width >= 20 || selected == index || selected == index + 1 ? 20 : width) * scale;
}
}
}
if(this.open != null)
@ -1543,7 +1550,7 @@ public class Client implements IThreadListener {
this.player.setSelectedIndex(0);
++n;
}
while(this.player.getHeldItem() == null && n < this.player.getHotbarSize());
while((this.player.getHeldItem() == null || !this.player.getHeldItem().getItem().canBeHeld() || (this.player.getHeldItem().getItem().getBlock() != null) != this.placeMode) && n < this.player.getHotbarSize());
this.controller.resetUseCooldown();
}

View file

@ -179,10 +179,12 @@ public abstract class GuiContainer extends Gui
if(stack.getRepairCost() > 0)
list.add("Reparaturkosten: " + stack.getRepairCost() + " Mana");
if(stack.getItem().getMaxAmount() == 1)
list.add("Nicht stapelbar");
else
list.add("Stapelbar bis " + stack.getItem().getMaxAmount());
list.add(stack.getItem().getMaxAmount() == 1 ? "Nicht stapelbar" : "Stapelbar");
list.add("Gewicht: " + (stack.getSize() != 1 ? stack.getSize() * stack.getItem().getWeight() + "(" + stack.getSize() + "x " + stack.getItem().getWeight() + ")" : stack.getItem().getWeight()));
if(stack.getItem().canBeHeld())
list.add("Kann gehalten werden");
list.add(Color.GRAY + ItemRegistry.getName(stack.getItem()));

View file

@ -17,6 +17,7 @@ public enum Bind implements Identifyable, CVar {
DOWN(BindCategory.MOVEMENT, "down", "Abwärts, Langsam", Keysym.LEFT_CONTROL),
FAST(BindCategory.MOVEMENT, "fast", "Schneller", Keysym.LEFT_SHIFT),
INVENTORY(BindCategory.INTERACTION, "inventory", "Inventar", Keysym.E),
ITEMMODE(BindCategory.INTERACTION, "itemmode", "Platziermodus", Keysym.TAB),
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),
@ -42,7 +43,7 @@ public enum Bind implements Identifyable, CVar {
RENAME(BindCategory.INTERACTION, "rename", "Umbenennen", Keysym.N),
CONSOLE(BindCategory.GENERAL, "console", "Konsole", Keysym.F1),
COMMAND(BindCategory.GENERAL, "command", "Befehl / Chat", Keysym.C),
INFO(BindCategory.GENERAL, "info", "Infos einblenden", Keysym.TAB),
INFO(BindCategory.GENERAL, "info", "Infos einblenden", Keysym.CIRCUMFLEX),
PERSPECTIVE(BindCategory.GENERAL, "perspective", "Perspektive", Keysym.F4),
ZOOM(BindCategory.GENERAL, "zoom", "Kamera zoomen", Keysym.Y),
MENU(BindCategory.GENERAL, "menu", "Menü", Keysym.ESCAPE),