From 4a63d4ee6c118c006ec5b09c1565cbd75b318a38 Mon Sep 17 00:00:00 2001 From: Luiz Feikes <33578169+Luligabi1@users.noreply.github.com> Date: Sat, 9 Sep 2023 06:25:12 -0300 Subject: Add input/output filter + weaken WPlayerInvPanel's components' protection (#209) Co-authored-by: Juuz <6596629+Juuxel@users.noreply.github.com> --- .../java/io/github/cottonmc/test/TestDescription.java | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'src/testMod') diff --git a/src/testMod/java/io/github/cottonmc/test/TestDescription.java b/src/testMod/java/io/github/cottonmc/test/TestDescription.java index 39b09d6..fdea211 100644 --- a/src/testMod/java/io/github/cottonmc/test/TestDescription.java +++ b/src/testMod/java/io/github/cottonmc/test/TestDescription.java @@ -48,24 +48,16 @@ public class TestDescription extends SyncedGuiDescription { root.add(new WButton(Text.literal("Button D")), 5, 5, 4, 1); root.add(new WTextField(Text.literal("Type something...")).setMaxLength(64), 0, 7, 5, 1); - root.add(new WLabel(Text.literal("Large slot:")), 0, 9); - root.add(WItemSlot.outputOf(blockInventory, 0), 4, 9); + 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); - root.add(WItemSlot.of(blockInventory, 7).setIcon(new TextureIcon(new Identifier("libgui-test", "saddle.png"))), 7, 9); + root.add(WItemSlot.of(blockInventory, 7).setIcon(new TextureIcon(new Identifier("libgui-test", "saddle.png"))).setInputFilter(stack -> stack.isOf(Items.SADDLE)), 7, 10); root.add(createPlayerInventoryPanel(), 0, 11); System.out.println(root.toString()); this.getRootPanel().validate(this); - getRootPanel().streamChildren() - .forEach(child -> { - if (child instanceof WItemSlot wis) { - // Prevent apples from entering the item slots - wis.setFilter(stack -> !stack.isOf(Items.APPLE)); - } - }); - ScreenNetworking.of(this, NetworkSide.SERVER).receive(TEST_MESSAGE, buf -> { System.out.println("Received on the server!"); }); -- cgit