aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--GuiTest/build.gradle2
-rw-r--r--GuiTest/gradle.properties10
-rw-r--r--GuiTest/src/main/java/io/github/cottonmc/test/GuiBlockEntity.java4
-rw-r--r--GuiTest/src/main/java/io/github/cottonmc/test/ImplementedInventory.java32
-rw-r--r--GuiTest/src/main/java/io/github/cottonmc/test/LibGuiTest.java6
-rw-r--r--GuiTest/src/main/java/io/github/cottonmc/test/TestController.java (renamed from GuiTest/src/main/java/io/github/cottonmc/test/TestContainer.java)10
-rw-r--r--GuiTest/src/main/java/io/github/cottonmc/test/client/LibGuiTestClient.java6
-rw-r--r--GuiTest/src/main/java/io/github/cottonmc/test/client/TestClientGui.java10
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/CottonInventoryController.java (renamed from src/main/java/io/github/cottonmc/cotton/gui/CottonCraftingController.java)64
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/client/CottonClientScreen.java19
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/client/CottonHud.java3
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/client/CottonInventoryScreen.java25
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/client/ScreenDrawing.java128
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/client/TextHoverRendererScreen.java3
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/client/modmenu/ModMenuSupport.java5
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/client/modmenu/WKirbSprite.java3
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WAbstractSlider.java88
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WBar.java3
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WButton.java5
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WClippedPanel.java18
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WDynamicLabel.java5
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WItem.java9
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WItemSlot.java3
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WLabel.java8
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WLabeledSlider.java24
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WListPanel.java19
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WPanel.java14
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WScrollBar.java152
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WSlider.java16
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WSprite.java3
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WText.java8
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WTextField.java15
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WToggleButton.java40
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WWidget.java88
34 files changed, 356 insertions, 492 deletions
diff --git a/GuiTest/build.gradle b/GuiTest/build.gradle
index 849cf3e..9609abd 100644
--- a/GuiTest/build.gradle
+++ b/GuiTest/build.gradle
@@ -5,7 +5,7 @@ buildscript {
}
plugins {
- id 'fabric-loom' version '0.2.5-SNAPSHOT'
+ id 'fabric-loom' version '0.2.7-SNAPSHOT'
}
sourceCompatibility = JavaVersion.VERSION_1_8
diff --git a/GuiTest/gradle.properties b/GuiTest/gradle.properties
index 1ef1e05..b1db372 100644
--- a/GuiTest/gradle.properties
+++ b/GuiTest/gradle.properties
@@ -3,15 +3,15 @@ org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# check these on https://fabricmc.net/use
- minecraft_version=1.15.2
- yarn_mappings=1.15.2+build.2
- loader_version=0.7.5+build.178
+ minecraft_version=20w17a
+ yarn_mappings=20w17a+build.4
+ loader_version=0.8.2+build.194
# Mod Properties
- mod_version = 1.5.1
+ mod_version = 1.9.0
maven_group = io.github.cottonmc
archives_base_name = LibGui
# Dependencies
- fabric_version=0.4.29+build.290-1.15
+ fabric_version=0.6.2+build.327-1.16
jankson_version=2.0.1+j1.2.0
diff --git a/GuiTest/src/main/java/io/github/cottonmc/test/GuiBlockEntity.java b/GuiTest/src/main/java/io/github/cottonmc/test/GuiBlockEntity.java
index f07ccb7..3e76fdd 100644
--- a/GuiTest/src/main/java/io/github/cottonmc/test/GuiBlockEntity.java
+++ b/GuiTest/src/main/java/io/github/cottonmc/test/GuiBlockEntity.java
@@ -3,7 +3,7 @@ package io.github.cottonmc.test;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
-import net.minecraft.util.DefaultedList;
+import net.minecraft.util.collection.DefaultedList;
public class GuiBlockEntity extends BlockEntity implements ImplementedInventory {
@@ -19,7 +19,7 @@ public class GuiBlockEntity extends BlockEntity implements ImplementedInventory
}
@Override
- public boolean canPlayerUseInv(PlayerEntity player) {
+ public boolean canPlayerUse(PlayerEntity player) {
return pos.isWithinDistance(player.getBlockPos(), 4.5);
}
diff --git a/GuiTest/src/main/java/io/github/cottonmc/test/ImplementedInventory.java b/GuiTest/src/main/java/io/github/cottonmc/test/ImplementedInventory.java
index 177affd..1335b64 100644
--- a/GuiTest/src/main/java/io/github/cottonmc/test/ImplementedInventory.java
+++ b/GuiTest/src/main/java/io/github/cottonmc/test/ImplementedInventory.java
@@ -6,7 +6,7 @@ import net.minecraft.inventory.Inventory;
import net.minecraft.inventory.SidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
-import net.minecraft.util.DefaultedList;
+import net.minecraft.util.collection.DefaultedList;
import net.minecraft.util.math.Direction;
import java.util.List;
@@ -64,7 +64,7 @@ public interface ImplementedInventory extends SidedInventory {
* @return the available slots
*/
@Override
- default int[] getInvAvailableSlots(Direction side) {
+ default int[] getAvailableSlots(Direction side) {
int[] result = new int[getItems().size()];
for (int i = 0; i < result.length; i++) {
result[i] = i;
@@ -84,7 +84,7 @@ public interface ImplementedInventory extends SidedInventory {
* @return true if the stack can be inserted
*/
@Override
- default boolean canInsertInvStack(int slot, ItemStack stack, Direction side) {
+ default boolean canInsert(int slot, ItemStack stack, Direction side) {
return true;
}
@@ -99,7 +99,7 @@ public interface ImplementedInventory extends SidedInventory {
* @return true if the stack can be extracted
*/
@Override
- default boolean canExtractInvStack(int slot, ItemStack stack, Direction side) {
+ default boolean canExtract(int slot, ItemStack stack, Direction side) {
return true;
}
@@ -113,7 +113,7 @@ public interface ImplementedInventory extends SidedInventory {
* @return the inventory size
*/
@Override
- default int getInvSize() {
+ default int size() {
return getItems().size();
}
@@ -121,9 +121,9 @@ public interface ImplementedInventory extends SidedInventory {
* @return true if this inventory has only empty stacks, false otherwise
*/
@Override
- default boolean isInvEmpty() {
- for (int i = 0; i < getInvSize(); i++) {
- ItemStack stack = getInvStack(i);
+ default boolean isEmpty() {
+ for (int i = 0; i < size(); i++) {
+ ItemStack stack = getStack(i);
if (!stack.isEmpty()) {
return false;
}
@@ -139,7 +139,7 @@ public interface ImplementedInventory extends SidedInventory {
* @return the item in the slot
*/
@Override
- default ItemStack getInvStack(int slot) {
+ default ItemStack getStack(int slot) {
return getItems().get(slot);
}
@@ -154,7 +154,7 @@ public interface ImplementedInventory extends SidedInventory {
* @return a stack
*/
@Override
- default ItemStack takeInvStack(int slot, int count) {
+ default ItemStack removeStack(int slot, int count) {
ItemStack result = Inventories.splitStack(getItems(), slot, count);
if (!result.isEmpty()) {
markDirty();
@@ -172,24 +172,24 @@ public interface ImplementedInventory extends SidedInventory {
* @return the removed stack
*/
@Override
- default ItemStack removeInvStack(int slot) {
+ default ItemStack removeStack(int slot) {
return Inventories.removeStack(getItems(), slot);
}
/**
* Replaces the current stack in the {@code slot} with the provided stack.
*
- * <p>If the stack is too big for this inventory ({@link Inventory#getInvMaxStackAmount()}),
+ * <p>If the stack is too big for this inventory ({@link Inventory#getMaxCountPerStack()} ()}),
* it gets resized to this inventory's maximum amount.
*
* @param slot the slot
* @param stack the stack
*/
@Override
- default void setInvStack(int slot, ItemStack stack) {
+ default void setStack(int slot, ItemStack stack) {
getItems().set(slot, stack);
- if (stack.getCount() > getInvMaxStackAmount()) {
- stack.setCount(getInvMaxStackAmount());
+ if (stack.getCount() > getMaxCountPerStack()) {
+ stack.setCount(getMaxCountPerStack());
}
}
@@ -207,7 +207,7 @@ public interface ImplementedInventory extends SidedInventory {
}
@Override
- default boolean canPlayerUseInv(PlayerEntity player) {
+ default boolean canPlayerUse(PlayerEntity player) {
return true;
}
} \ No newline at end of file
diff --git a/GuiTest/src/main/java/io/github/cottonmc/test/LibGuiTest.java b/GuiTest/src/main/java/io/github/cottonmc/test/LibGuiTest.java
index 32d359d..6d63688 100644
--- a/GuiTest/src/main/java/io/github/cottonmc/test/LibGuiTest.java
+++ b/GuiTest/src/main/java/io/github/cottonmc/test/LibGuiTest.java
@@ -10,13 +10,13 @@ import net.fabricmc.fabric.api.container.ContainerProviderRegistry;
import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.loader.api.ModContainer;
import net.minecraft.block.entity.BlockEntityType;
-import net.minecraft.container.BlockContext;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
+import net.minecraft.network.PacketByteBuf;
+import net.minecraft.screen.ScreenHandlerContext;
import net.minecraft.util.Identifier;
-import net.minecraft.util.PacketByteBuf;
import net.minecraft.util.registry.Registry;
public class LibGuiTest implements ModInitializer {
@@ -38,7 +38,7 @@ public class LibGuiTest implements ModInitializer {
ContainerProviderRegistry.INSTANCE.registerFactory(new Identifier(MODID, "gui"), (int syncId, Identifier identifier, PlayerEntity player, PacketByteBuf buf)->{
- return new TestContainer(syncId, player.inventory, BlockContext.create(player.getEntityWorld(), buf.readBlockPos()));
+ return new TestController(syncId, player.inventory, ScreenHandlerContext.create(player.getEntityWorld(), buf.readBlockPos()));
});
Optional<ModContainer> containerOpt = FabricLoader.getInstance().getModContainer("jankson");
diff --git a/GuiTest/src/main/java/io/github/cottonmc/test/TestContainer.java b/GuiTest/src/main/java/io/github/cottonmc/test/TestController.java
index b4bb11b..43a0a6f 100644
--- a/GuiTest/src/main/java/io/github/cottonmc/test/TestContainer.java
+++ b/GuiTest/src/main/java/io/github/cottonmc/test/TestController.java
@@ -1,18 +1,18 @@
package io.github.cottonmc.test;
-import io.github.cottonmc.cotton.gui.CottonCraftingController;
+import io.github.cottonmc.cotton.gui.CottonInventoryController;
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.WPlayerInvPanel;
-import net.minecraft.container.BlockContext;
import net.minecraft.entity.player.PlayerInventory;
+import net.minecraft.screen.ScreenHandlerContext;
import net.minecraft.text.LiteralText;
-public class TestContainer extends CottonCraftingController {
+public class TestController extends CottonInventoryController {
- public TestContainer(int syncId, PlayerInventory playerInventory, BlockContext context) {
- super(null, syncId, playerInventory, getBlockInventory(context), null);
+ public TestController(int syncId, PlayerInventory playerInventory, ScreenHandlerContext context) {
+ super(syncId, playerInventory, getBlockInventory(context), null);
WGridPanel root = (WGridPanel)this.getRootPanel();
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 6db6902..a2a23fb 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
@@ -2,17 +2,17 @@ package io.github.cottonmc.test.client;
import io.github.cottonmc.cotton.gui.client.CottonInventoryScreen;
import io.github.cottonmc.test.LibGuiTest;
-import io.github.cottonmc.test.TestContainer;
+import io.github.cottonmc.test.TestController;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.screen.ScreenProviderRegistry;
-import net.minecraft.container.BlockContext;
+import net.minecraft.screen.ScreenHandlerContext;
import net.minecraft.util.Identifier;
public class LibGuiTestClient implements ClientModInitializer {
@Override
public void onInitializeClient() {
- ScreenProviderRegistry.INSTANCE.registerFactory(new Identifier(LibGuiTest.MODID, "gui"), (syncId, identifier, player, buf)->new CottonInventoryScreen<TestContainer>(new TestContainer(syncId, player.inventory, BlockContext.create(player.getEntityWorld(), buf.readBlockPos())), player));
+ ScreenProviderRegistry.INSTANCE.registerFactory(new Identifier(LibGuiTest.MODID, "gui"), (syncId, identifier, player, buf)->new CottonInventoryScreen<TestController>(new TestController(syncId, player.inventory, ScreenHandlerContext.create(player.getEntityWorld(), buf.readBlockPos())), player));
}
}
diff --git a/GuiTest/src/main/java/io/github/cottonmc/test/client/TestClientGui.java b/GuiTest/src/main/java/io/github/cottonmc/test/client/TestClientGui.java
index e1e23d5..b96a359 100644
--- a/GuiTest/src/main/java/io/github/cottonmc/test/client/TestClientGui.java
+++ b/GuiTest/src/main/java/io/github/cottonmc/test/client/TestClientGui.java
@@ -20,7 +20,9 @@ import io.github.cottonmc.cotton.gui.widget.data.Axis;
import io.github.cottonmc.cotton.gui.widget.data.Color;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
+import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.LiteralText;
+import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
public class TestClientGui extends LightweightGuiDescription {
@@ -43,8 +45,8 @@ public class TestClientGui extends LightweightGuiDescription {
WLabel title = new WLabel(new LiteralText("Client Test Gui"), WLabel.DEFAULT_TEXT_COLOR) {
@Override
- public void addInformation(List<String> information) {
- information.add("Radical!");
+ public void addTooltip(List<Text> tooltip) {
+ tooltip.add(new LiteralText("Radical!"));
}
};
root.add(title, 0, 0);
@@ -142,9 +144,7 @@ public class TestClientGui extends LightweightGuiDescription {
}
@Override
- public void paintBackground(int x, int y, int mouseX, int mouseY) {
- super.paintBackground(x, y, mouseX, mouseY);
-
+ public void paint(MatrixStack matrices, int x, int y, int mouseX, int mouseY) {
ScreenDrawing.coloredRect(x, y, this.getWidth(), this.getHeight(), color);
}
}
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/CottonCraftingController.java b/src/main/java/io/github/cottonmc/cotton/gui/CottonInventoryController.java
index 6bc7dcd..2721ff3 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/CottonCraftingController.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/CottonInventoryController.java
@@ -17,20 +17,15 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.Inventory;
import net.minecraft.item.ItemStack;
-import net.minecraft.recipe.Recipe;
-import net.minecraft.recipe.RecipeFinder;
-import net.minecraft.recipe.RecipeInputProvider;
-import net.minecraft.recipe.RecipeType;
import net.minecraft.screen.*;
import net.minecraft.screen.slot.Slot;
import net.minecraft.screen.slot.SlotActionType;
import net.minecraft.world.World;
-public class CottonCraftingController extends AbstractRecipeScreenHandler<Inventory> implements GuiDescription {
+public class CottonInventoryController extends ScreenHandler implements GuiDescription {
protected Inventory blockInventory;
protected PlayerInventory playerInventory;
- protected RecipeType<?> recipeType;
protected World world;
protected PropertyDelegate propertyDelegate;
@@ -40,20 +35,18 @@ public class CottonCraftingController extends AbstractRecipeScreenHandler<Invent
protected WWidget focus;
- public CottonCraftingController(RecipeType<?> recipeType, int syncId, PlayerInventory playerInventory) {
+ public CottonInventoryController(int syncId, PlayerInventory playerInventory) {
super(null, syncId);
this.blockInventory = null;
this.playerInventory = playerInventory;
- this.recipeType = recipeType;
this.world = playerInventory.player.world;
this.propertyDelegate = null;//new ArrayPropertyDelegate(1);
}
- public CottonCraftingController(RecipeType<?> recipeType, int syncId, PlayerInventory playerInventory, Inventory blockInventory, PropertyDelegate propertyDelegate) {
+ public CottonInventoryController(int syncId, PlayerInventory playerInventory, Inventory blockInventory, PropertyDelegate propertyDelegate) {
super(null, syncId);
this.blockInventory = blockInventory;
this.playerInventory = playerInventory;
- this.recipeType = recipeType;
this.world = playerInventory.player.world;
this.propertyDelegate = propertyDelegate;
if (propertyDelegate!=null && propertyDelegate.size()>0) this.addProperties(propertyDelegate);
@@ -67,12 +60,12 @@ public class CottonCraftingController extends AbstractRecipeScreenHandler<Invent
return LibGuiClient.config.darkMode ? darkTitleColor : titleColor;
}
- public CottonCraftingController setRootPanel(WPanel panel) {
+ public CottonInventoryController setRootPanel(WPanel panel) {
this.rootPanel = panel;
return this;
}
- public CottonCraftingController setTitleColor(int color) {
+ public CottonInventoryController setTitleColor(int color) {
this.titleColor = color;
return this;
}
@@ -378,52 +371,11 @@ public class CottonCraftingController extends AbstractRecipeScreenHandler<Invent
}).orElse(new ArrayPropertyDelegate(0));
}
- //extends CraftingContainer<Inventory> {
+ //extends ScreenHandler {
@Override
- public void populateRecipeFinder(RecipeFinder recipeFinder) {
- if (this.blockInventory instanceof RecipeInputProvider) {
- ((RecipeInputProvider)this.blockInventory).provideRecipeInputs(recipeFinder);
- }
- }
-
- @Override
- public void clearCraftingSlots() {
- if (this.blockInventory!=null) this.blockInventory.clear();
+ public boolean canUse(PlayerEntity entity) {
+ return (blockInventory!=null) ? blockInventory.canPlayerUse(entity) : true;
}
-
- @Override
- public boolean matches(Recipe<? super Inventory> recipe) {
- if (blockInventory==null || world==null) return false;
- return false; //TODO recipe support
- }
-
- @Override
- public int getCraftingResultSlotIndex() {
- return -1;
- }
-
- @Override
- public int getCraftingWidth() {
- return 1;
- }
-
- @Override
- public int getCraftingHeight() {
- return 1;
- }
-
- @Override
- @Environment(EnvType.CLIENT)
- public int getCraftingSlotCount() {
- return 1;
- }
-
- //(implied) extends Container {
- @Override
- public boolean canUse(PlayerEntity entity) {
- return (blockInventory!=null) ? blockInventory.canPlayerUse(entity) : true;
- }
- //}
//}
@Override
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/client/CottonClientScreen.java b/src/main/java/io/github/cottonmc/cotton/gui/client/CottonClientScreen.java
index 05f3b68..968cbba 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/client/CottonClientScreen.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/client/CottonClientScreen.java
@@ -55,36 +55,33 @@ public class CottonClientScreen extends Screen implements TextHoverRendererScree
}
}
- public void paint(int mouseX, int mouseY) {
- super.renderBackground(ScreenDrawing.matrices);
+ public void paint(MatrixStack matrices, int mouseX, int mouseY) {
+ super.renderBackground(matrices);
if (description!=null) {
WPanel root = description.getRootPanel();
if (root!=null) {
- root.paintBackground(left, top, mouseX-left, mouseY-top);
+ root.paint(matrices, left, top, mouseX-left, mouseY-top);
}
}
if (getTitle() != null) {
- textRenderer.method_27528(ScreenDrawing.matrices, getTitle(), left, top, description.getTitleColor());
+ textRenderer.method_27528(matrices, getTitle(), left, top, description.getTitleColor());
}
}
@SuppressWarnings("deprecation")
@Override
public void render(MatrixStack matrices, int mouseX, int mouseY, float partialTicks) {
- ScreenDrawing.matrices = matrices;
- paint(mouseX, mouseY);
+ paint(matrices, mouseX, mouseY);
super.render(matrices, mouseX, mouseY, partialTicks);
if (description!=null) {
WPanel root = description.getRootPanel();
if (root!=null) {
- root.paintForeground(left, top, mouseX, mouseY);
-
WWidget hitChild = root.hit(mouseX-left, mouseY-top);
- if (hitChild!=null) hitChild.renderTooltip(left, top, mouseX-left, mouseY-top);
+ if (hitChild!=null) hitChild.renderTooltip(matrices, left, top, mouseX-left, mouseY-top);
}
}
}
@@ -223,7 +220,7 @@ public class CottonClientScreen extends Screen implements TextHoverRendererScree
//}
@Override
- public void renderTextHover(Text text, int x, int y) {
- renderTextHoverEffect(ScreenDrawing.matrices, text, x, y);
+ public void renderTextHover(MatrixStack matrices, Text text, int x, int y) {
+ renderTextHoverEffect(matrices, text, x, y);
}
}
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/client/CottonHud.java b/src/main/java/io/github/cottonmc/cotton/gui/client/CottonHud.java
index 0e6fa4f..ae0f232 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/client/CottonHud.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/client/CottonHud.java
@@ -106,7 +106,6 @@ public enum CottonHud implements HudRenderCallback {
@Override
public void onHudRender(MatrixStack matrices, float tickDelta) {
- ScreenDrawing.matrices = matrices;
Window window = MinecraftClient.getInstance().getWindow();
int hudWidth = window.getScaledWidth();
int hudHeight = window.getScaledHeight();
@@ -116,7 +115,7 @@ public enum CottonHud implements HudRenderCallback {
positioner.reposition(widget, hudWidth, hudHeight);
}
- widget.paintBackground(widget.getX(), widget.getY(), -1, -1);
+ widget.paint(matrices, widget.getX(), widget.getY(), -1, -1);
}
}
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 5dca5f1..a018173 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
@@ -1,11 +1,11 @@
package io.github.cottonmc.cotton.gui.client;
+import io.github.cottonmc.cotton.gui.CottonInventoryController;
import net.minecraft.client.gui.screen.ingame.HandledScreen;
import net.minecraft.client.render.DiffuseLighting;
import net.minecraft.client.util.math.MatrixStack;
import org.lwjgl.glfw.GLFW;
-import io.github.cottonmc.cotton.gui.CottonCraftingController;
import io.github.cottonmc.cotton.gui.widget.WPanel;
import io.github.cottonmc.cotton.gui.widget.WWidget;
import net.minecraft.client.MinecraftClient;
@@ -13,8 +13,8 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
-public class CottonInventoryScreen<T extends CottonCraftingController> extends HandledScreen<T> implements TextHoverRendererScreen {
- protected CottonCraftingController description;
+public class CottonInventoryScreen<T extends CottonInventoryController> extends HandledScreen<T> implements TextHoverRendererScreen {
+ protected CottonInventoryController description;
public static final int PADDING = 8;
protected WWidget lastResponder = null;
protected WWidget focus = null;
@@ -187,26 +187,25 @@ public class CottonInventoryScreen<T extends CottonCraftingController> extends H
@Override
protected void drawBackground(MatrixStack matrices, float partialTicks, int mouseX, int mouseY) {} //This is just an AbstractContainerScreen thing; most Screens don't work this way.
- public void paint(int mouseX, int mouseY) {
- super.renderBackground(ScreenDrawing.matrices);
+ public void paint(MatrixStack matrices, int mouseX, int mouseY) {
+ super.renderBackground(matrices);
if (description!=null) {
WPanel root = description.getRootPanel();
if (root!=null) {
- root.paintBackground(x, y, mouseX-x, mouseY-y);
+ root.paint(matrices, x, y, mouseX-x, mouseY-y);
}
}
if (getTitle() != null) {
- textRenderer.method_27528(ScreenDrawing.matrices, getTitle(), x, y, description.getTitleColor());
+ textRenderer.method_27528(matrices, getTitle(), x, y, description.getTitleColor());
}
}
@SuppressWarnings("deprecation")
@Override
public void render(MatrixStack matrices, int mouseX, int mouseY, float partialTicks) {
- ScreenDrawing.matrices = matrices;
- paint(mouseX, mouseY);
+ paint(matrices, mouseX, mouseY);
super.render(matrices, mouseX, mouseY, partialTicks);
DiffuseLighting.disable(); //Needed because super.render leaves dirty state
@@ -214,10 +213,8 @@ public class CottonInventoryScreen<T extends CottonCraftingController> extends H
if (description!=null) {
WPanel root = description.getRootPanel();
if (root!=null) {
- root.paintForeground(x, y, mouseX, mouseY);
-
WWidget hitChild = root.hit(mouseX-x, mouseY-y);
- if (hitChild!=null) hitChild.renderTooltip(x, y, mouseX-x, mouseY-y);
+ if (hitChild!=null) hitChild.renderTooltip(matrices, x, y, mouseX-x, mouseY-y);
}
}
@@ -236,7 +233,7 @@ public class CottonInventoryScreen<T extends CottonCraftingController> extends H
}
@Override
- public void renderTextHover(Text text, int x, int y) {
- renderTextHoverEffect(ScreenDrawing.matrices, text, x, y);
+ public void renderTextHover(MatrixStack matrices, Text text, int x, int y) {
+ renderTextHoverEffect(matrices, text, x, y);
}
}
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/client/ScreenDrawing.java b/src/main/java/io/github/cottonmc/cotton/gui/client/ScreenDrawing.java
index 199909f..786f2ee 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/client/ScreenDrawing.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/client/ScreenDrawing.java
@@ -9,7 +9,6 @@ import com.mojang.blaze3d.systems.RenderSystem;
import io.github.cottonmc.cotton.gui.widget.data.Alignment;
import net.minecraft.client.MinecraftClient;
-import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.render.BufferBuilder;
import net.minecraft.client.render.Tessellator;
import net.minecraft.client.render.VertexFormats;
@@ -19,23 +18,9 @@ import net.minecraft.util.Identifier;
* {@code ScreenDrawing} contains utility methods for drawing contents on a screen.
*/
public class ScreenDrawing {
- // Internal MatrixStack for rendering strings.
- // TODO (2.0): Remove
- static MatrixStack matrices;
-
private ScreenDrawing() {}
/**
- * Gets the currently bound matrix stack.
- *
- * @return the matrix stack
- * @since 1.9.0
- */
- public static MatrixStack getMatrices() {
- return matrices;
- }
-
- /**
* Draws a textured rectangle.
*
* @param x the x coordinate of the box on-screen
@@ -79,12 +64,11 @@ public class ScreenDrawing {
RenderSystem.enableBlend();
//GlStateManager.disableTexture2D();
RenderSystem.blendFuncSeparate(GlStateManager.SrcFactor.SRC_ALPHA, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SrcFactor.ONE, GlStateManager.DstFactor.ZERO);
- RenderSystem.color4f(r, g, b, 1.0f);
- buffer.begin(GL11.GL_QUADS, VertexFormats.POSITION_TEXTURE); //I thought GL_QUADS was deprecated but okay, sure.
- buffer.vertex(x, y + height, 0).texture(u1, v2).next();
- buffer.vertex(x + width, y + height, 0).texture(u2, v2).next();
- buffer.vertex(x + width, y, 0).texture(u2, v1).next();
- buffer.vertex(x, y, 0).texture(u1, v1).next();
+ buffer.begin(GL11.GL_QUADS, VertexFormats.POSITION_COLOR_TEXTURE); //I thought GL_QUADS was deprecated but okay, sure.
+ buffer.vertex(x, y + height, 0).color(r, g, b, 1.0f).texture(u1, v2).next();
+ buffer.vertex(x + width, y + height, 0).color(r, g, b, 1.0f).texture(u2, v2).next();