1
0
Fork 0

increase hotbar size

This commit is contained in:
Sen 2025-08-18 13:27:26 +02:00
parent 69bb1e6ffb
commit 5641c5c834
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
7 changed files with 27 additions and 17 deletions

View file

@ -386,7 +386,7 @@ public class Client implements IThreadListener {
private final List<Message> hotbar = Lists.newArrayList();
private final File config = new File(System.getProperty("config.file", "client.cfg"));
private final Bind[] keyBindsHotbar = new Bind[] {
Bind.SELECT1, Bind.SELECT2, Bind.SELECT3, Bind.SELECT4, Bind.SELECT5, Bind.SELECT6, Bind.SELECT7, Bind.SELECT8, Bind.SELECT9
Bind.SELECT1, Bind.SELECT2, Bind.SELECT3, Bind.SELECT4, Bind.SELECT5, Bind.SELECT6, Bind.SELECT7, Bind.SELECT8, Bind.SELECT9, Bind.SELECT10, Bind.SELECT11, Bind.SELECT12
};
private final int[] tickTimes = new int[240];
private final long[] frames = new long[240];
@ -874,7 +874,7 @@ public class Client implements IThreadListener {
}
if(this.viewEntity == this.player) {
for (int l = 0; l < 9; ++l)
for (int l = 0; l < this.keyBindsHotbar.length && l < this.player.getHotbarSize(); ++l)
{
if (this.keyBindsHotbar[l].isPressed())
{
@ -1076,8 +1076,9 @@ public class Client implements IThreadListener {
int selected = this.player.getSelectedIndex();
int scale = this.scaleHotbar ? 2 : 1;
for(int n = 0; n < 9; n++) {
int x = this.fbX / 2 - 90 * scale + n * 20 * scale + 2 * scale;
int size = this.player.getHotbarSize();
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);
@ -1231,11 +1232,12 @@ public class Client implements IThreadListener {
ItemRenderer.enableGUIStandardItemLighting();
GL11.glPushMatrix();
int scale = this.scaleHotbar ? 2 : 1;
GL11.glTranslatef((float)(this.fbX / 2 - 90 * scale + 2 * scale), (float)(this.fbY - 20 * scale), 0.0f);
int size = this.player.getHotbarSize();
GL11.glTranslatef((float)(this.fbX / 2 - size * 10 * scale + 2 * scale), (float)(this.fbY - 20 * scale), 0.0f);
if(this.scaleHotbar)
GL11.glScalef(2.0f, 2.0f, 2.0f);
for(int index = 0; index < 9; ++index) {
for(int index = 0; index < size; ++index) {
int xPos = index * 20;
ItemStack itemstack = this.player.getStackInSlot(index);
if(itemstack != null) {
@ -1272,11 +1274,12 @@ public class Client implements IThreadListener {
GlState.disableDepth();
if(this.world != null && this.open == null && this.player != null && this.viewEntity == this.player) {
int scale = this.scaleHotbar ? 2 : 1;
for(int index = 0; index < 9; ++index) {
int size = this.player.getHotbarSize();
for(int index = 0; index < size; ++index) {
ItemStack itemstack = this.player.getStackInSlot(index);
if(itemstack != null) {
GuiContainer.renderItemOverlay(itemstack,
this.fbX / 2 - 90 * 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 * 10 * scale + 2 * scale + index * 20 * scale, this.fbY - 20 * scale, null, index == this.player.getSelectedIndex() ? this.controller.getUseCooldown() : 0, this.controller.getUseCooldownMax(), scale);
}
}
}
@ -1396,8 +1399,8 @@ public class Client implements IThreadListener {
else if(this.player != null) {
this.player.setSelectedIndex(this.player.getSelectedIndex() - dir);
if(this.player.getSelectedIndex() < 0)
this.player.setSelectedIndex(9 - 1);
else if(this.player.getSelectedIndex() >= 9)
this.player.setSelectedIndex(this.player.getHotbarSize() - 1);
else if(this.player.getSelectedIndex() >= this.player.getHotbarSize())
this.player.setSelectedIndex(0);
this.controller.resetUseCooldown();
}
@ -1618,7 +1621,7 @@ public class Client implements IThreadListener {
return;
int idx = this.player.getInventorySlotContainItem(item);
if(idx >= 0 && idx < 9) {
if(idx >= 0 && idx < this.player.getHotbarSize()) {
this.player.setSelectedIndex(idx);
this.controller.resetUseCooldown();
}

View file

@ -858,7 +858,7 @@ public abstract class GuiContainer extends Gui
public void useHotbar(int slot)
{
if (!this.clickSide(this.gm.mouseX, this.gm.mouseY, slot, this.gm.shift(), this.gm.ctrl()) && this.gm != null && this.gm.player != null && this.gm.player.getMouseItem() == null && this.cheatStack == null && this.theSlot != null)
if (this.gm != null && this.gm.player != null && slot < this.gm.player.getHotbarSize() && !this.clickSide(this.gm.mouseX, this.gm.mouseY, slot, this.gm.shift(), this.gm.ctrl()) && this.gm.player.getMouseItem() == null && this.cheatStack == null && this.theSlot != null)
{
this.handleMouseClick(this.theSlot, this.theSlot.slotNumber, slot, 2);
}

View file

@ -570,7 +570,7 @@ public class ClientPlayer implements IClientPlayer
{
NetHandler.checkThread(packetIn, this, this.gm, this.world);
if (packetIn.getHeldItemHotbarIndex() >= 0 && packetIn.getHeldItemHotbarIndex() < 9)
if (packetIn.getHeldItemHotbarIndex() >= 0 && packetIn.getHeldItemHotbarIndex() < this.gm.player.getHotbarSize())
{
if(this.gm.player.getSelectedIndex() != packetIn.getHeldItemHotbarIndex())
this.gm.controller.resetUseCooldown();

View file

@ -31,6 +31,9 @@ public enum Bind implements Identifyable, CVar {
SELECT7("select7", "Auswahl #7", Keysym.N7),
SELECT8("select8", "Auswahl #8", Keysym.N8),
SELECT9("select9", "Auswahl #9", Keysym.N9),
SELECT10("select10", "Auswahl #10", Keysym.N0),
SELECT11("select11", "Auswahl #11", Keysym.SHARP_S),
SELECT12("select12", "Auswahl #12", Keysym.ACUTE),
CRAFT("craft", "Herstellen", Keysym.M),
RENAME("rename", "Umbenennen", Keysym.N),
CONSOLE("console", "Konsole", Keysym.F1),

View file

@ -2483,6 +2483,10 @@ public abstract class EntityNPC extends EntityLiving implements IInventory
}
}
public int getHotbarSize() {
return 12;
}
public int getSelectedIndex() {
return this.currentItem;
}
@ -2493,7 +2497,7 @@ public abstract class EntityNPC extends EntityLiving implements IInventory
public ItemStack getHeldItem()
{
return this.isPlayer() || this.dummy ? (this.getSelectedIndex() < 9 && this.getSelectedIndex() >= 0 ? this.getStackInSlot(this.getSelectedIndex()) : null) : this.heldItem;
return this.isPlayer() || this.dummy ? (this.getSelectedIndex() < this.getHotbarSize() && this.getSelectedIndex() >= 0 ? this.getStackInSlot(this.getSelectedIndex()) : null) : this.heldItem;
}
public ItemStack[] getArmor()

View file

@ -391,7 +391,7 @@ public abstract class Container
}
}
}
else if (mode == 2 && clickedButton >= 0 && clickedButton < 9)
else if (mode == 2 && clickedButton >= 0 && clickedButton < 12)
{
Slot slot5 = (Slot)this.inventorySlots.get(slotId);

View file

@ -2638,7 +2638,7 @@ public class Player extends User implements Executor, IPlayer
break;
case SET_ITEMSLOT:
if(packetIn.getAuxData() >= 0 && packetIn.getAuxData() < 9) {
if(packetIn.getAuxData() >= 0 && packetIn.getAuxData() < this.entity.getHotbarSize()) {
if(packetIn.getAuxData() != this.entity.getSelectedIndex())
this.itemUseCooldown = 0;
this.entity.setSelectedIndex(packetIn.getAuxData());
@ -2932,7 +2932,7 @@ public class Player extends User implements Executor, IPlayer
if(amount <= 0)
return;
}
else if(packet.getSlot() <= -2 - 9) {
else if(packet.getSlot() <= -2 - this.entity.getHotbarSize()) {
this.entity.dropItem(stack, false, true);
}
else {