aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--GuiTest/src/main/java/io/github/cottonmc/test/GuiBlock.java10
-rw-r--r--GuiTest/src/main/java/io/github/cottonmc/test/GuiBlockEntity.java6
-rw-r--r--GuiTest/src/main/java/io/github/cottonmc/test/ImplementedInventory.java5
-rw-r--r--GuiTest/src/main/java/io/github/cottonmc/test/LibGuiTest.java3
-rw-r--r--GuiTest/src/main/java/io/github/cottonmc/test/client/ScrollingTestGui.java8
-rw-r--r--build.gradle5
-rw-r--r--gradle.properties10
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/SyncedGuiDescription.java26
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/client/CottonClientScreen.java1
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/client/CottonInventoryScreen.java5
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/client/ScreenDrawing.java50
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WLabeledSlider.java4
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WTextField.java8
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/icon/ItemIcon.java10
14 files changed, 70 insertions, 81 deletions
diff --git a/GuiTest/src/main/java/io/github/cottonmc/test/GuiBlock.java b/GuiTest/src/main/java/io/github/cottonmc/test/GuiBlock.java
index 69a0640..1b1666f 100644
--- a/GuiTest/src/main/java/io/github/cottonmc/test/GuiBlock.java
+++ b/GuiTest/src/main/java/io/github/cottonmc/test/GuiBlock.java
@@ -1,14 +1,16 @@
package io.github.cottonmc.test;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
-import net.minecraft.block.*;
+import net.minecraft.block.BlockRenderType;
+import net.minecraft.block.BlockState;
+import net.minecraft.block.BlockWithEntity;
+import net.minecraft.block.Blocks;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
-import net.minecraft.world.BlockView;
import net.minecraft.world.World;
public class GuiBlock extends BlockWithEntity {
@@ -24,8 +26,8 @@ public class GuiBlock extends BlockWithEntity {
}
@Override
- public BlockEntity createBlockEntity(BlockView var1) {
- return new GuiBlockEntity();
+ public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
+ return new GuiBlockEntity(pos, state);
}
@Override
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 6a9f741..82188d2 100644
--- a/GuiTest/src/main/java/io/github/cottonmc/test/GuiBlockEntity.java
+++ b/GuiTest/src/main/java/io/github/cottonmc/test/GuiBlockEntity.java
@@ -1,5 +1,6 @@
package io.github.cottonmc.test;
+import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
@@ -10,6 +11,7 @@ import net.minecraft.screen.ScreenHandlerContext;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import net.minecraft.util.collection.DefaultedList;
+import net.minecraft.util.math.BlockPos;
import javax.annotation.Nullable;
@@ -18,8 +20,8 @@ public class GuiBlockEntity extends BlockEntity implements ImplementedInventory,
DefaultedList<ItemStack> items = DefaultedList.ofSize(INVENTORY_SIZE, ItemStack.EMPTY);
- public GuiBlockEntity() {
- super(LibGuiTest.GUI_BLOCKENTITY_TYPE);
+ public GuiBlockEntity(BlockPos pos, BlockState state) {
+ super(LibGuiTest.GUI_BLOCKENTITY_TYPE, pos, state);
}
@Override
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 1335b64..d8ba3f3 100644
--- a/GuiTest/src/main/java/io/github/cottonmc/test/ImplementedInventory.java
+++ b/GuiTest/src/main/java/io/github/cottonmc/test/ImplementedInventory.java
@@ -5,7 +5,6 @@ import net.minecraft.inventory.Inventories;
import net.minecraft.inventory.Inventory;
import net.minecraft.inventory.SidedInventory;
import net.minecraft.item.ItemStack;
-import net.minecraft.nbt.CompoundTag;
import net.minecraft.util.collection.DefaultedList;
import net.minecraft.util.math.Direction;
@@ -15,7 +14,7 @@ import java.util.List;
* A simple {@code SidedInventory} implementation with only default methods + an item list getter.
*
* <h2>Reading and writing to tags</h2>
- * Use {@link Inventories#fromTag(CompoundTag, DefaultedList)} and {@link Inventories#toTag(CompoundTag, DefaultedList)}
+ * Use {@link Inventories#readNbt(net.minecraft.nbt.NbtCompound, DefaultedList)} and {@link Inventories#writeNbt(net.minecraft.nbt.NbtCompound, DefaultedList)}
* on {@linkplain #getItems() the item list}.
*
* License: <a href="https://creativecommons.org/publicdomain/zero/1.0/">CC0</a>
@@ -210,4 +209,4 @@ public interface ImplementedInventory extends SidedInventory {
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 8b567b7..17bfdaa 100644
--- a/GuiTest/src/main/java/io/github/cottonmc/test/LibGuiTest.java
+++ b/GuiTest/src/main/java/io/github/cottonmc/test/LibGuiTest.java
@@ -6,6 +6,7 @@ import java.nio.file.Path;
import java.util.Optional;
import net.fabricmc.api.ModInitializer;
+import net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityTypeBuilder;
import net.fabricmc.fabric.api.screenhandler.v1.ScreenHandlerRegistry;
import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.loader.api.ModContainer;
@@ -35,7 +36,7 @@ public class LibGuiTest implements ModInitializer {
Registry.register(Registry.BLOCK, new Identifier(MODID, "gui"), GUI_BLOCK);
GUI_BLOCK_ITEM = new BlockItem(GUI_BLOCK, new Item.Settings().group(ItemGroup.MISC));
Registry.register(Registry.ITEM, new Identifier(MODID, "gui"), GUI_BLOCK_ITEM);
- GUI_BLOCKENTITY_TYPE = BlockEntityType.Builder.create(GuiBlockEntity::new, GUI_BLOCK).build(null);
+ GUI_BLOCKENTITY_TYPE = FabricBlockEntityTypeBuilder.create(GuiBlockEntity::new, GUI_BLOCK).build(null);
Registry.register(Registry.BLOCK_ENTITY_TYPE, new Identifier(MODID, "gui"), GUI_BLOCKENTITY_TYPE);
GUI_SCREEN_HANDLER_TYPE = ScreenHandlerRegistry.registerSimple(new Identifier(MODID, "gui"), (int syncId, PlayerInventory inventory) -> {
diff --git a/GuiTest/src/main/java/io/github/cottonmc/test/client/ScrollingTestGui.java b/GuiTest/src/main/java/io/github/cottonmc/test/client/ScrollingTestGui.java
index 1ae78b6..30bda75 100644
--- a/GuiTest/src/main/java/io/github/cottonmc/test/client/ScrollingTestGui.java
+++ b/GuiTest/src/main/java/io/github/cottonmc/test/client/ScrollingTestGui.java
@@ -1,14 +1,16 @@
package io.github.cottonmc.test.client;
-import io.github.cottonmc.cotton.gui.widget.WLabeledSlider;
-
+import net.minecraft.item.Items;
import net.minecraft.text.LiteralText;
import io.github.cottonmc.cotton.gui.client.LightweightGuiDescription;
import io.github.cottonmc.cotton.gui.widget.WBox;
+import io.github.cottonmc.cotton.gui.widget.WButton;
import io.github.cottonmc.cotton.gui.widget.WGridPanel;
+import io.github.cottonmc.cotton.gui.widget.WLabeledSlider;
import io.github.cottonmc.cotton.gui.widget.WScrollPanel;
import io.github.cottonmc.cotton.gui.widget.data.Axis;
+import io.github.cottonmc.cotton.gui.widget.icon.ItemIcon;
public class ScrollingTestGui extends LightweightGuiDescription {
public ScrollingTestGui() {
@@ -19,6 +21,8 @@ public class ScrollingTestGui extends LightweightGuiDescription {
box.add(new WLabeledSlider(0, 10, new LiteralText("Slider #" + i)));
}
+ box.add(new WButton(new ItemIcon(Items.APPLE)));
+
root.add(new WScrollPanel(box), 0, 0, 5, 3);
root.validate(this);
}
diff --git a/build.gradle b/build.gradle
index dc33eb1..ab1f887 100644
--- a/build.gradle
+++ b/build.gradle
@@ -33,9 +33,10 @@ dependencies {
modImplementation "io.github.cottonmc:Jankson-Fabric:${project.jankson_version}"
include "io.github.cottonmc:Jankson-Fabric:${project.jankson_version}"
- modRuntime(modCompileOnly("com.terraformersmc:modmenu:$project.modmenu_version") {
+ // TODO: Add runtime when ModMenu updates to 1.17
+ modCompileOnly("com.terraformersmc:modmenu:$project.modmenu_version") {
exclude group: 'net.fabricmc.fabric-api'
- })
+ }
}
processResources {
diff --git a/gradle.properties b/gradle.properties
index f325d1b..dc1fff1 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -3,16 +3,16 @@ org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# check these on https://fabricmc.net/use
- minecraft_version=1.16.5
- yarn_mappings=1.16.5+build.3
- loader_version=0.11.1
+ minecraft_version=21w11a
+ yarn_mappings=21w11a+build.5
+ loader_version=0.11.3
# Mod Properties
- mod_version = 4.0.0-beta.1
+ mod_version = 4.0.0-alpha.1
maven_group = io.github.cottonmc
archives_base_name = LibGui
# Dependencies
- fabric_version=0.30.0+1.16
+ fabric_version=0.32.4+1.17
jankson_version=3.0.1+j1.2.0
modmenu_version=1.14.15
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/SyncedGuiDescription.java b/src/main/java/io/github/cottonmc/cotton/gui/SyncedGuiDescription.java
index 2cb1de6..3c4d8ad 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/SyncedGuiDescription.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/SyncedGuiDescription.java
@@ -115,17 +115,17 @@ public class SyncedGuiDescription extends ScreenHandler implements GuiDescriptio
}
@Override
- public ItemStack onSlotClick(int slotNumber, int button, SlotActionType action, PlayerEntity player) {
+ public void onSlotClick(int slotNumber, int button, SlotActionType action, PlayerEntity player) {
if (action==SlotActionType.QUICK_MOVE) {
if (slotNumber < 0) {
- return ItemStack.EMPTY;
+ return;
}
- if (slotNumber>=this.slots.size()) return ItemStack.EMPTY;
+ if (slotNumber>=this.slots.size()) return;
Slot slot = this.slots.get(slotNumber);
if (slot == null || !slot.canTakeItems(player)) {
- return ItemStack.EMPTY;
+ return;
}
ItemStack remaining = ItemStack.EMPTY;
@@ -137,15 +137,15 @@ public class SyncedGuiDescription extends ScreenHandler implements GuiDescriptio
if (slot.inventory==blockInventory) {
//Try to transfer the item from the block into the player's inventory
if (!this.insertItem(toTransfer, this.playerInventory, true, player)) {
- return ItemStack.EMPTY;
+ return;
}
} else if (!this.insertItem(toTransfer, this.blockInventory, false, player)) { //Try to transfer the item from the player to the block
- return ItemStack.EMPTY;
+ return;
}
} else {
//There's no block, just swap between the player's storage and their hotbar
if (!swapHotbar(toTransfer, slotNumber, this.playerInventory, player)) {
- return ItemStack.EMPTY;
+ return;
}
}
@@ -156,16 +156,14 @@ public class SyncedGuiDescription extends ScreenHandler implements GuiDescriptio
}
}
- return remaining;
- } else {
- return super.onSlotClick(slotNumber, button, action, player);
+ super.onSlotClick(slotNumber, button, action, player);
}
}
/** WILL MODIFY toInsert! Returns true if anything was inserted. */
private boolean insertIntoExisting(ItemStack toInsert, Slot slot, PlayerEntity player) {
ItemStack curSlotStack = slot.getStack();
- if (!curSlotStack.isEmpty() && canStacksCombine(toInsert, curSlotStack) && slot.canInsert(toInsert)) {
+ if (!curSlotStack.isEmpty() && ItemStack.canCombine(toInsert, curSlotStack) && slot.canInsert(toInsert)) {
int combinedAmount = curSlotStack.getCount() + toInsert.getCount();
int maxAmount = Math.min(toInsert.getMaxCount(), slot.getMaxItemCount(toInsert));
if (combinedAmount <= maxAmount) {
@@ -384,7 +382,7 @@ public class SyncedGuiDescription extends ScreenHandler implements GuiDescriptio
}
private static Inventory getBlockInventory(ScreenHandlerContext ctx, Supplier<Inventory> fallback) {
- return ctx.run((world, pos) -> {
+ return ctx.get((world, pos) -> {
BlockState state = world.getBlockState(pos);
Block b = state.getBlock();
@@ -422,7 +420,7 @@ public class SyncedGuiDescription extends ScreenHandler implements GuiDescriptio
* @return the found property delegate
*/
public static PropertyDelegate getBlockPropertyDelegate(ScreenHandlerContext ctx) {
- return ctx.run((world, pos) -> {
+ return ctx.get((world, pos) -> {
BlockEntity be = world.getBlockEntity(pos);
if (be!=null && be instanceof PropertyDelegateHolder) {
return ((PropertyDelegateHolder)be).getPropertyDelegate();
@@ -446,7 +444,7 @@ public class SyncedGuiDescription extends ScreenHandler implements GuiDescriptio
* @since 2.0.0
*/
public static PropertyDelegate getBlockPropertyDelegate(ScreenHandlerContext ctx, int size) {
- return ctx.run((world, pos) -> {
+ return ctx.get((world, pos) -> {
BlockEntity be = world.getBlockEntity(pos);
if (be!=null && be instanceof PropertyDelegateHolder) {
return ((PropertyDelegateHolder)be).getPropertyDelegate();
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 fa27766..2acc371 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
@@ -127,7 +127,6 @@ public class CottonClientScreen extends Screen implements CottonScreenImpl {
}
}
- @SuppressWarnings("deprecation")
@Override
public void render(MatrixStack matrices, int mouseX, int mouseY, float partialTicks) {
paint(matrices, mouseX, mouseY);
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 2ddf84a..68f28fe 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
@@ -44,7 +44,7 @@ public class CottonInventoryScreen<T extends SyncedGuiDescription> extends Handl
* @param title the screen title
*/
public CottonInventoryScreen(T description, PlayerEntity player, Text title) {
- super(description, player.inventory, title);
+ super(description, player.getInventory(), title);
this.description = description;
width = 18*9;
height = 18*9;
@@ -251,13 +251,12 @@ public class CottonInventoryScreen<T extends SyncedGuiDescription> extends Handl
}
}
- @SuppressWarnings("deprecation")
@Override
public void render(MatrixStack matrices, int mouseX, int mouseY, float partialTicks) {
paint(matrices, mouseX, mouseY);
super.render(matrices, mouseX, mouseY, partialTicks);
- DiffuseLighting.disable(); //Needed because super.render leaves dirty state
+ DiffuseLighting.disableGuiDepthLighting(); //Needed because super.render leaves dirty state
if (description!=null) {
WPanel root = description.getRootPanel();
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 d9d5da8..7fae1bf 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
@@ -1,10 +1,13 @@
package io.github.cottonmc.cotton.gui.client;
-import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.MinecraftClient;
+import net.minecraft.client.gui.DrawableHelper;
import net.minecraft.client.render.BufferBuilder;
+import net.minecraft.client.render.BufferRenderer;
+import net.minecraft.client.render.GameRenderer;
import net.minecraft.client.render.Tessellator;
+import net.minecraft.client.render.VertexFormat;
import net.minecraft.client.render.VertexFormats;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.OrderedText;
@@ -18,7 +21,6 @@ import io.github.cottonmc.cotton.gui.widget.data.Texture;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.Nullable;
-import org.lwjgl.opengl.GL11;
/**
* {@code ScreenDrawing} contains utility methods for drawing contents on a screen.
@@ -130,10 +132,6 @@ public class ScreenDrawing {
* @since 2.0.0
*/
public static void texturedRect(MatrixStack matrices, int x, int y, int width, int height, Identifier texture, float u1, float v1, float u2, float v2, int color, float opacity) {
- MinecraftClient.getInstance().getTextureManager().bindTexture(texture);
-
- //float scale = 0.00390625F;
-
if (width <= 0) width = 1;
if (height <= 0) height = 1;
@@ -143,17 +141,16 @@ public class ScreenDrawing {
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder buffer = tessellator.getBuffer();
Matrix4f model = matrices.peek().getModel();
- RenderSystem.enableBlend();
- //GlStateManager.disableTexture2D();
- RenderSystem.blendFuncSeparate(GlStateManager.SrcFactor.SRC_ALPHA, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SrcFactor.ONE, GlStateManager.DstFactor.ZERO);
- buffer.begin(GL11.GL_QUADS, VertexFormats.POSITION_COLOR_TEXTURE); //I thought GL_QUADS was deprecated but okay, sure.
- buffer.vertex(model, x, y + height, 0).color(r, g, b, opacity).texture(u1, v2).next();
- buffer.vertex(model, x + width, y + height, 0).color(r, g, b, opacity).texture(u2, v2).next();
- buffer.vertex(model, x + width, y, 0).color(r, g, b, opacity).texture(u2, v1).next();
- buffer.vertex(model, x, y, 0).color(r, g, b, opacity).texture(u1, v1).next();
- tessellator.draw();
- //GlStateManager.enableTexture2D();
- RenderSystem.disableBlend();
+ RenderSystem.setShaderTexture(0, texture);
+ RenderSystem.setShaderColor(r, g, b, opacity);
+ RenderSystem.setShader(GameRenderer::method_34542);
+ buffer.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE);
+ buffer.vertex(model, x, y + height, 0).texture(u1, v2).next();
+ buffer.vertex(model, x + width, y + height, 0).texture(u2, v2).next();
+ buffer.vertex(model, x + width, y, 0).texture(u2, v1).next();
+ buffer.vertex(model, x, y, 0).texture(u1, v1).next();
+ buffer.end();
+ BufferRenderer.draw(buffer);
}
/**
@@ -200,24 +197,7 @@ public class ScreenDrawing {
if (width <= 0) width = 1;
if (height <= 0) height = 1;
- float a = (color >> 24 & 255) / 255.0F;
- float r = (color >> 16 & 255) / 255.0F;
- float g = (color >> 8 & 255) / 255.0F;
- float b = (color & 255) / 255.0F;
- Tessellator tessellator = Tessellator.getInstance();
- BufferBuilder buffer = tessellator.getBuffer();
- Matrix4f model = matrices.peek().getModel();
- RenderSystem.enableBlend();
- RenderSystem.disableTexture();
- RenderSystem.blendFuncSeparate(GlStateManager.SrcFactor.SRC_ALPHA, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SrcFactor.ONE, GlStateManager.DstFactor.ZERO);
- buffer.begin(GL11.GL_QUADS, VertexFormats.POSITION_COLOR); //I thought GL_QUADS was deprecated but okay, sure.
- buffer.vertex(model, left, top + height, 0).color(r, g, b, a).next();
- buffer.vertex(model, left + width, top + height, 0).color(r, g, b, a).next();
- buffer.vertex(model, left + width, top, 0).color(r, g, b, a).next();
- buffer.vertex(model, left, top, 0).color(r, g, b, a).next();
- tessellator.draw();
- RenderSystem.enableTexture();
- RenderSystem.disableBlend();
+ DrawableHelper.fill(matrices, left, top, left + width, top + height, color);
}
/**
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WLabeledSlider.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WLabeledSlider.java
index 5403bff..911d547 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WLabeledSlider.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WLabeledSlider.java
@@ -3,9 +3,9 @@ package io.github.cottonmc.cotton.gui.widget;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.util.math.MatrixStack;
-import net.minecraft.client.util.math.Vector3f;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
+import net.minecraft.util.math.Vec3f;
import io.github.cottonmc.cotton.gui.client.ScreenDrawing;
import io.github.cottonmc.cotton.gui.widget.data.Axis;
@@ -169,7 +169,7 @@ public class WLabeledSlider extends WAbstractSlider {
matrices.translate(x, y, 0);
if (axis == Axis.VERTICAL) {
matrices.translate(0, height, 0);
- matrices.multiply(Vector3f.POSITIVE_Z.getDegreesQuaternion(270));
+ matrices.multiply(Vec3f.POSITIVE_Z.getDegreesQuaternion(270));
}
drawButton(matrices, 0, 0, 0, aWidth);
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WTextField.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WTextField.java
index c9fd92e..ac3c8bf 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WTextField.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WTextField.java
@@ -8,7 +8,9 @@ import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.render.BufferBuilder;
+import net.minecraft.client.render.GameRenderer;
import net.minecraft.client.render.Tessellator;
+import net.minecraft.client.render.VertexFormat;
import net.minecraft.client.render.VertexFormats;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.LiteralText;
@@ -20,7 +22,6 @@ import io.github.cottonmc.cotton.gui.client.ScreenDrawing;
import io.github.cottonmc.cotton.gui.widget.data.InputResult;
import org.jetbrains.annotations.Nullable;
import org.lwjgl.glfw.GLFW;
-import org.lwjgl.opengl.GL11;
import java.util.function.Consumer;
import java.util.function.Predicate;
@@ -404,11 +405,12 @@ public class WTextField extends WWidget {
private void invertedRect(int x, int y, int width, int height) {
Tessellator tessellator_1 = Tessellator.getInstance();
BufferBuilder bufferBuilder_1 = tessellator_1.getBuffer();
- RenderSystem.color4f(0.0F, 0.0F, 255.0F, 255.0F);
+ RenderSystem.setShaderColor(0.0F, 0.0F, 1.0F, 1.0F);
+ RenderSystem.setShader(GameRenderer::method_34542);
RenderSystem.disableTexture();
RenderSystem.enableColorLogicOp();
RenderSystem.logicOp(GlStateManager.LogicOp.OR_REVERSE);
- bufferBuilder_1.begin(GL11.GL_QUADS, VertexFormats.POSITION);
+ bufferBuilder_1.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION);
bufferBuilder_1.vertex(x, y+height, 0.0D).next();
bufferBuilder_1.vertex(x+width, y+height, 0.0D).next();
bufferBuilder_1.vertex(x+width, y, 0.0D).next();
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/icon/ItemIcon.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/icon/ItemIcon.java
index b5fb85e..2575d36 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/widget/icon/ItemIcon.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/icon/ItemIcon.java
@@ -43,15 +43,17 @@ public class ItemIcon implements Icon {
@Environment(EnvType.CLIENT)
@Override
public void paint(MatrixStack matrices, int x, int y, int size) {
+ // TODO: Make this not ignore the actual matrices
MinecraftClient client = MinecraftClient.getInstance();
ItemRenderer renderer = client.getItemRenderer();
+ MatrixStack modelViewMatrices = RenderSystem.getModelViewStack();
float scale = size != 16 ? ((float) size / 16f) : 1f;
- RenderSystem.pushMatrix();
- RenderSystem.translatef(x, y, 0);
- RenderSystem.scalef(scale, scale, 1);
+ modelViewMatrices.push();
+ modelViewMatrices.translate(x, y, 0);
+ modelViewMatrices.scale(scale, scale, 1);
renderer.renderInGui(stack, 0, 0);
- RenderSystem.popMatrix();
+ modelViewMatrices.pop();
}
}