aboutsummaryrefslogtreecommitdiff
path: root/GuiTest/src
diff options
context:
space:
mode:
Diffstat (limited to 'GuiTest/src')
-rw-r--r--GuiTest/src/main/java/io/github/cottonmc/test/TestDescription.java25
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!");
});