diff options
author | Juuz <6596629+Juuxel@users.noreply.github.com> | 2022-01-16 18:37:55 +0200 |
---|---|---|
committer | Juuz <6596629+Juuxel@users.noreply.github.com> | 2022-01-16 18:37:55 +0200 |
commit | 1964ce97ba0121d4346d8134fb7395285193137c (patch) | |
tree | 84b2af0d13507e27ed6573251189fa8205108eeb /GuiTest | |
parent | 53b4519a51aabc9c324dc5c285b875c60bcf2e08 (diff) | |
download | LibGui-1964ce97ba0121d4346d8134fb7395285193137c.tar.gz LibGui-1964ce97ba0121d4346d8134fb7395285193137c.tar.bz2 LibGui-1964ce97ba0121d4346d8134fb7395285193137c.zip |
Add test for WItemSlot filters
Diffstat (limited to 'GuiTest')
-rw-r--r-- | GuiTest/src/main/java/io/github/cottonmc/test/TestDescription.java | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/GuiTest/src/main/java/io/github/cottonmc/test/TestDescription.java b/GuiTest/src/main/java/io/github/cottonmc/test/TestDescription.java index 70c50d4..69be1f4 100644 --- a/GuiTest/src/main/java/io/github/cottonmc/test/TestDescription.java +++ b/GuiTest/src/main/java/io/github/cottonmc/test/TestDescription.java @@ -1,17 +1,22 @@ package io.github.cottonmc.test; -import io.github.cottonmc.cotton.gui.SyncedGuiDescription; -import io.github.cottonmc.cotton.gui.networking.NetworkSide; -import io.github.cottonmc.cotton.gui.networking.ScreenNetworking; -import io.github.cottonmc.cotton.gui.widget.*; -import io.github.cottonmc.cotton.gui.widget.icon.TextureIcon; - import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.item.Items; import net.minecraft.screen.ScreenHandlerContext; import net.minecraft.screen.ScreenHandlerType; import net.minecraft.text.LiteralText; import net.minecraft.util.Identifier; +import io.github.cottonmc.cotton.gui.SyncedGuiDescription; +import io.github.cottonmc.cotton.gui.networking.NetworkSide; +import io.github.cottonmc.cotton.gui.networking.ScreenNetworking; +import io.github.cottonmc.cotton.gui.widget.WButton; +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.icon.TextureIcon; + public class TestDescription extends SyncedGuiDescription { private static final Identifier TEST_MESSAGE = new Identifier("libgui", "test"); private static final Identifier UNREGISTERED_ON_SERVER = new Identifier("libgui", "unregistered_on_server"); @@ -51,6 +56,14 @@ public class TestDescription extends SyncedGuiDescription { 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!"); }); |