aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--GuiTest/src/main/java/io/github/cottonmc/test/client/LibGuiTestClient.java7
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/client/CottonInventoryScreen.java36
2 files changed, 33 insertions, 10 deletions
diff --git a/GuiTest/src/main/java/io/github/cottonmc/test/client/LibGuiTestClient.java b/GuiTest/src/main/java/io/github/cottonmc/test/client/LibGuiTestClient.java
index 45b1cbf..efdcd3f 100644
--- a/GuiTest/src/main/java/io/github/cottonmc/test/client/LibGuiTestClient.java
+++ b/GuiTest/src/main/java/io/github/cottonmc/test/client/LibGuiTestClient.java
@@ -1,7 +1,5 @@
package io.github.cottonmc.test.client;
-import io.github.cottonmc.test.ReallySimpleDescription;
-
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.command.v1.ClientCommandManager;
import net.fabricmc.fabric.api.client.screenhandler.v1.ScreenRegistry;
@@ -13,6 +11,7 @@ import io.github.cottonmc.cotton.gui.client.CottonInventoryScreen;
import io.github.cottonmc.cotton.gui.impl.modmenu.ConfigGui;
import io.github.cottonmc.cotton.gui.widget.WLabel;
import io.github.cottonmc.test.LibGuiTest;
+import io.github.cottonmc.test.ReallySimpleDescription;
import io.github.cottonmc.test.TestDescription;
import static net.fabricmc.fabric.api.client.command.v1.ClientCommandManager.literal;
@@ -23,12 +22,12 @@ public class LibGuiTestClient implements ClientModInitializer {
public void onInitializeClient() {
ScreenRegistry.<TestDescription, CottonInventoryScreen<TestDescription>>register(
LibGuiTest.GUI_SCREEN_HANDLER_TYPE,
- (desc, inventory, title) -> new CottonInventoryScreen<>(desc, inventory.player, title)
+ CottonInventoryScreen::new
);
ScreenRegistry.<ReallySimpleDescription, CottonInventoryScreen<ReallySimpleDescription>>register(
LibGuiTest.REALLY_SIMPLE_SCREEN_HANDLER_TYPE,
- (desc, inventory, title) -> new CottonInventoryScreen<>(desc, inventory.player, title)
+ CottonInventoryScreen::new
);
CottonHud.add(new WHudTest(), 10, -20, 10, 10);
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/client/CottonInventoryScreen.java b/src/main/java/io/github/cottonmc/cotton/gui/client/CottonInventoryScreen.java
index 96da107..53fbcba 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/client/CottonInventoryScreen.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/client/CottonInventoryScreen.java
@@ -5,6 +5,7 @@ import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder;
import net.minecraft.client.render.DiffuseLighting;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.player.PlayerEntity;
+import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Style;
import net.minecraft.text.Text;
@@ -36,21 +37,23 @@ public class CottonInventoryScreen<T extends SyncedGuiDescription> extends Handl
* Constructs a new screen without a title.
*
* @param description the GUI description
- * @param player the player
+ * @param inventory the player inventory
+ * @since 5.2.0
*/
- public CottonInventoryScreen(T description, PlayerEntity player) {
- this(description, player, new LiteralText(""));
+ public CottonInventoryScreen(T description, PlayerInventory inventory) {
+ this(description, inventory, new LiteralText(""));
}
/**
* Constructs a new screen.
*
* @param description the GUI description
- * @param player the player
+ * @param inventory the player inventory
* @param title the screen title
+ * @since 5.2.0
*/
- public CottonInventoryScreen(T description, PlayerEntity player, Text title) {
- super(description, player.getInventory(), title);
+ public CottonInventoryScreen(T description, PlayerInventory inventory, Text title) {
+ super(description, inventory, title);
this.description = description;
width = 18*9;
height = 18*9;
@@ -58,6 +61,27 @@ public class CottonInventoryScreen<T extends SyncedGuiDescription> extends Handl
this.backgroundHeight = 18*9;
description.getRootPanel().validate(description);
}
+
+ /**
+ * Constructs a new screen without a title.
+ *
+ * @param description the GUI description
+ * @param player the player
+ */
+ public CottonInventoryScreen(T description, PlayerEntity player) {
+ this(description, player.getInventory());
+ }
+
+ /**
+ * Constructs a new screen.
+ *
+ * @param description the GUI description
+ * @param player the player
+ * @param title the screen title
+ */
+ public CottonInventoryScreen(T description, PlayerEntity player, Text title) {
+ this(description, player.getInventory(), title);
+ }
/*
* RENDERING NOTES: