aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuuz <6596629+Juuxel@users.noreply.github.com>2023-11-26 16:27:26 +0200
committerJuuz <6596629+Juuxel@users.noreply.github.com>2023-11-26 16:27:26 +0200
commitc9af717918d1553df6d7d6338a1d4a270f274870 (patch)
tree845323c4bf9dfa02e69dd8eb7ab92bc5f743ba24
parent20e4bcf624d211ac0be0cfad54d795fff2e3fec0 (diff)
downloadLibGui-c9af717918d1553df6d7d6338a1d4a270f274870.tar.gz
LibGui-c9af717918d1553df6d7d6338a1d4a270f274870.tar.bz2
LibGui-c9af717918d1553df6d7d6338a1d4a270f274870.zip
Fix WItemSlot.iconOnlyPaintedForEmptySlots being flipped
Fixes #229.
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WItemSlot.java2
-rw-r--r--src/testMod/java/io/github/cottonmc/test/TestDescription.java8
2 files changed, 8 insertions, 2 deletions
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WItemSlot.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WItemSlot.java
index f5e90ef..bfe64a2 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WItemSlot.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WItemSlot.java
@@ -513,7 +513,7 @@ public class WItemSlot extends WWidget {
backgroundPainter.paintBackground(context, x, y, this);
}
- if (icon != null && (iconOnlyPaintedForEmptySlots || inventory.getStack(startIndex).isEmpty())) {
+ if (icon != null && (!iconOnlyPaintedForEmptySlots || inventory.getStack(startIndex).isEmpty())) {
icon.paint(context, x + 1, y + 1, 16);
}
}
diff --git a/src/testMod/java/io/github/cottonmc/test/TestDescription.java b/src/testMod/java/io/github/cottonmc/test/TestDescription.java
index fdea211..7c24610 100644
--- a/src/testMod/java/io/github/cottonmc/test/TestDescription.java
+++ b/src/testMod/java/io/github/cottonmc/test/TestDescription.java
@@ -15,6 +15,7 @@ import io.github.cottonmc.cotton.gui.widget.WGridPanel;
import io.github.cottonmc.cotton.gui.widget.WItemSlot;
import io.github.cottonmc.cotton.gui.widget.WLabel;
import io.github.cottonmc.cotton.gui.widget.WTextField;
+import io.github.cottonmc.cotton.gui.widget.WToggleButton;
import io.github.cottonmc.cotton.gui.widget.data.Texture;
import io.github.cottonmc.cotton.gui.widget.icon.TextureIcon;
@@ -49,7 +50,12 @@ public class TestDescription extends SyncedGuiDescription {
root.add(new WTextField(Text.literal("Type something...")).setMaxLength(64), 0, 7, 5, 1);
root.add(new WLabel(Text.literal("Large Glass-only output:")), 0, 9);
- root.add(WItemSlot.outputOf(blockInventory, 0).setOutputFilter(stack -> stack.isOf(Items.GLASS)), 4, 9);
+ WItemSlot glassOutputSlot = WItemSlot.outputOf(blockInventory, 0).setOutputFilter(stack -> stack.isOf(Items.GLASS));
+ glassOutputSlot.setIcon(new TextureIcon(new Identifier("minecraft:textures/block/glass.png")));
+ root.add(glassOutputSlot, 4, 9);
+ WToggleButton glassIconToggle = new WToggleButton(Text.literal("Show glass icon only when empty?"));
+ glassIconToggle.setOnToggle(glassOutputSlot::setIconOnlyPaintedForEmptySlots);
+ root.add(glassIconToggle, 0, 10);
root.add(WItemSlot.of(blockInventory, 7).setIcon(new TextureIcon(new Identifier("libgui-test", "saddle.png"))).setInputFilter(stack -> stack.isOf(Items.SADDLE)), 7, 10);