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();
}