add armor slot textures

This commit is contained in:
Sen 2025-08-07 16:43:48 +02:00
parent 3960bff398
commit 2eda9771ad
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
14 changed files with 27 additions and 11 deletions

View file

@ -210,8 +210,12 @@ public abstract class GuiContainer extends Gui
Drawing.drawGradient(this.container_x + x * this.container_scale, this.container_y + y * this.container_scale, width * this.container_scale, height * this.container_scale, 0xff000000 | top, 0xff000000 | bottom, 0xff000000 | topleft, 0xff000000 | btmright);
}
public InventoryButton slot(int x, int y, int w, int h, Slot slot) {
return this.add(new InventoryButton(this.container_x + x * this.container_scale, this.container_y + y * this.container_scale, w * this.container_scale, h * this.container_scale, this.container_scale > 1, slot));
}
public InventoryButton slot(int x, int y, int w, int h) {
return this.add(new InventoryButton(this.container_x + x * this.container_scale, this.container_y + y * this.container_scale, w * this.container_scale, h * this.container_scale, this.container_scale > 1));
return this.slot(x, y, w, h, null);
}
public ActButton button(int x, int y, int w, int h, ButtonCallback callback, String text) {
@ -276,8 +280,8 @@ public abstract class GuiContainer extends Gui
public void addButtons() {
if(this.inventorySlots != null) {
for (int i1 = 0; i1 < this.inventorySlots.inventorySlots.size(); ++i1) {
Slot slot = (Slot)this.inventorySlots.inventorySlots.get(i1);
this.slot(slot.xDisplayPosition - 1, slot.yDisplayPosition - 1, 18, 18);
Slot slot = this.inventorySlots.inventorySlots.get(i1);
this.slot(slot.xDisplayPosition - 1, slot.yDisplayPosition - 1, 18, 18, slot);
}
}
if(this.gm.itemCheat) {
@ -286,7 +290,7 @@ public abstract class GuiContainer extends Gui
this.cheatSearch = this.add(new Field(this.cheatX, this.cheatY + this.cheatHeight * 18 + 20 * ((CheatTab.values().length + (this.cheatWidth - 1)) / this.cheatWidth) + 4, this.cheatWidth * 18, 0, 128, null, ""));
this.cheatLast = "";
for(CheatTab tab : CheatTab.values()) {
this.add(new InventoryButton(this.cheatX + 18 * (tab.getIndex() % this.cheatWidth), this.cheatY + this.cheatHeight * 18 + 4 + 20 * (tab.getIndex() / this.cheatWidth), 18, 18, false));
this.add(new InventoryButton(this.cheatX + 18 * (tab.getIndex() % this.cheatWidth), this.cheatY + this.cheatHeight * 18 + 4 + 20 * (tab.getIndex() / this.cheatWidth), 18, 18, false, null));
}
this.setCurrentTab(selectedTab);
}

View file

@ -1,17 +1,26 @@
package client.gui.element;
import client.renderer.Drawing;
import common.inventory.Slot;
public class InventoryButton extends Element {
private final boolean bordered;
private final Slot slot;
private final String texture;
public InventoryButton(int x, int y, int w, int h, boolean bordered) {
public InventoryButton(int x, int y, int w, int h, boolean bordered, Slot slot) {
super(x, y, w, h, null);
this.bordered = bordered;
this.texture = slot == null || slot.getTexture() == null ? null : "textures/items/icon_" + slot.getTexture() + ".png";
this.slot = this.texture == null ? null : slot;
}
protected void drawBackground() {
drawButton(this.pos_x, this.pos_y, this.size_x, this.size_y, this.bordered);
if(this.texture != null && !this.slot.getHasStack()) {
int scale = this.bordered ? 2 : 1;
Drawing.drawTexturedRect(this.gm, this.texture, 16 * scale, 16 * scale, this.pos_x + scale, this.pos_y + scale, 0, 0, this.size_x - scale * 2, this.size_y - scale * 2);
}
}
protected void drawForeground(int x1, int y1, int x2, int y2) {

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

View file

@ -46,6 +46,9 @@ public class ContainerPlayer extends Container {
{
return stack != null && stack.getItem() instanceof ItemArmor armor && armor.getArmorType().canUseInSlot(type);
}
public String getTexture() {
return type.isRing() ? "ring" : type.getName();
}
});
}

View file

@ -122,10 +122,10 @@ public class Slot
return this.getSlotStackLimit();
}
// public String getSlotTexture()
// {
// return null;
// }
public String getTexture()
{
return null;
}
/**
* Decrease the size of the stack in slot (first int arg) by the amount of the second int arg. Returns the new

View file

@ -19,12 +19,12 @@ public enum Equipment implements Identifyable, Displayable {
BOOTS("boots", "Stiefel", "Stiefel", 13, 3, EnchantmentType.ARMOR_FEET, 1.4f, 1.0f, "X X", "X X"),
CROWN("crown", "Krone", 0, 4, null, 0.3f, 1.0f),
RING_LEFT_A("ring_left_A", "Linker Ring 1", 0, 5, EnchantmentType.RING, 1.0f),
RING_LEFT_A("ring_left_a", "Linker Ring 1", 0, 5, EnchantmentType.RING, 1.0f),
RING_LEFT_B("ring_left_b", "Linker Ring 2", 0, 6, EnchantmentType.RING, 1.0f),
SHIELD("shield", "Schild", 12, 7, EnchantmentType.SHIELD, 0.7f, 1.0f),
NECKLACE("necklace", "Halskette", 0, 8, EnchantmentType.NECKLACE, 1.0f),
RING_RIGHT_A("ring_right_a", "Rechter Ring 1", 0, 9, EnchantmentType.RING, 1.0f),
RING_RIGHT_B("ring_right_a", "Rechter Ring 2", 0, 10, EnchantmentType.RING, 1.0f),
RING_RIGHT_B("ring_right_b", "Rechter Ring 2", 0, 10, EnchantmentType.RING, 1.0f),
BELT("belt", "Gürtel", 0, 11, null, 1.0f),
HORSE_ARMOR("horse_armor", "Pferderüstung", EntityHorse.class, "X X", "XXX", "XXX");