aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--GuiTest/src/main/java/io/github/cottonmc/test/GuiBlock.java23
-rw-r--r--GuiTest/src/main/java/io/github/cottonmc/test/GuiBlockEntity.java20
-rw-r--r--GuiTest/src/main/java/io/github/cottonmc/test/LibGuiTest.java15
-rw-r--r--GuiTest/src/main/java/io/github/cottonmc/test/TestDescription.java5
-rw-r--r--GuiTest/src/main/java/io/github/cottonmc/test/client/LibGuiTestClient.java9
-rw-r--r--gradle.properties6
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/client/CottonInventoryScreen.java2
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/client/ScreenDrawing.java8
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WButton.java10
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WItem.java2
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WLabel.java12
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WLabeledSlider.java14
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WText.java18
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WToggleButton.java12
14 files changed, 87 insertions, 69 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 ded6fcb..69a0640 100644
--- a/GuiTest/src/main/java/io/github/cottonmc/test/GuiBlock.java
+++ b/GuiTest/src/main/java/io/github/cottonmc/test/GuiBlock.java
@@ -1,38 +1,35 @@
package io.github.cottonmc.test;
-import net.fabricmc.fabric.api.block.FabricBlockSettings;
-import net.fabricmc.fabric.api.container.ContainerProviderRegistry;
-import net.minecraft.block.Block;
-import net.minecraft.block.BlockEntityProvider;
-import net.minecraft.block.BlockState;
-import net.minecraft.block.Blocks;
+import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
+import net.minecraft.block.*;
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.Identifier;
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 Block implements BlockEntityProvider {
+public class GuiBlock extends BlockWithEntity {
public GuiBlock() {
- super(FabricBlockSettings.copy(Blocks.IRON_BLOCK).build());
+ super(FabricBlockSettings.copy(Blocks.IRON_BLOCK));
}
@Override
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hitResult) {
- if (!world.isClient) {
- ContainerProviderRegistry.INSTANCE.openContainer(new Identifier(LibGuiTest.MODID, "gui"), player, (buf)->buf.writeBlockPos(pos));
- }
+ player.openHandledScreen(state.createScreenHandlerFactory(world, pos));
return ActionResult.SUCCESS;
}
-
@Override
public BlockEntity createBlockEntity(BlockView var1) {
return new GuiBlockEntity();
}
+
+ @Override
+ public BlockRenderType getRenderType(BlockState state) {
+ return BlockRenderType.MODEL;
+ }
}
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 3e76fdd..c699b47 100644
--- a/GuiTest/src/main/java/io/github/cottonmc/test/GuiBlockEntity.java
+++ b/GuiTest/src/main/java/io/github/cottonmc/test/GuiBlockEntity.java
@@ -2,10 +2,18 @@ package io.github.cottonmc.test;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.entity.player.PlayerEntity;
+import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.item.ItemStack;
+import net.minecraft.screen.NamedScreenHandlerFactory;
+import net.minecraft.screen.ScreenHandler;
+import net.minecraft.screen.ScreenHandlerContext;
+import net.minecraft.text.LiteralText;
+import net.minecraft.text.Text;
import net.minecraft.util.collection.DefaultedList;
-public class GuiBlockEntity extends BlockEntity implements ImplementedInventory {
+import javax.annotation.Nullable;
+
+public class GuiBlockEntity extends BlockEntity implements ImplementedInventory, NamedScreenHandlerFactory {
DefaultedList<ItemStack> items = DefaultedList.ofSize(8, ItemStack.EMPTY);
@@ -23,4 +31,14 @@ public class GuiBlockEntity extends BlockEntity implements ImplementedInventory
return pos.isWithinDistance(player.getBlockPos(), 4.5);
}
+ @Override
+ public Text getDisplayName() {
+ return new LiteralText(""); // no title
+ }
+
+ @Nullable
+ @Override
+ public ScreenHandler createMenu(int syncId, PlayerInventory inv, PlayerEntity player) {
+ return new TestDescription(LibGuiTest.GUI_SCREEN_HANDLER_TYPE, syncId, inv, ScreenHandlerContext.create(world, pos));
+ }
}
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 90f3c92..8b567b7 100644
--- a/GuiTest/src/main/java/io/github/cottonmc/test/LibGuiTest.java
+++ b/GuiTest/src/main/java/io/github/cottonmc/test/LibGuiTest.java
@@ -6,16 +6,16 @@ import java.nio.file.Path;
import java.util.Optional;
import net.fabricmc.api.ModInitializer;
-import net.fabricmc.fabric.api.container.ContainerProviderRegistry;
+import net.fabricmc.fabric.api.screenhandler.v1.ScreenHandlerRegistry;
import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.loader.api.ModContainer;
import net.minecraft.block.entity.BlockEntityType;
-import net.minecraft.entity.player.PlayerEntity;
+import net.minecraft.entity.player.PlayerInventory;
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.screen.ScreenHandlerType;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
@@ -25,6 +25,8 @@ public class LibGuiTest implements ModInitializer {
public static GuiBlock GUI_BLOCK;
public static BlockItem GUI_BLOCK_ITEM;
public static BlockEntityType<GuiBlockEntity> GUI_BLOCKENTITY_TYPE;
+ public static ScreenHandlerType<TestDescription> GUI_SCREEN_HANDLER_TYPE;
+
@Override
public void onInitialize() {
Registry.register(Registry.ITEM, new Identifier(MODID, "client_gui"), new GuiItem());
@@ -36,11 +38,10 @@ public class LibGuiTest implements ModInitializer {
GUI_BLOCKENTITY_TYPE = BlockEntityType.Builder.create(GuiBlockEntity::new, GUI_BLOCK).build(null);
Registry.register(Registry.BLOCK_ENTITY_TYPE, new Identifier(MODID, "gui"), GUI_BLOCKENTITY_TYPE);
-
- ContainerProviderRegistry.INSTANCE.registerFactory(new Identifier(MODID, "gui"), (int syncId, Identifier identifier, PlayerEntity player, PacketByteBuf buf)->{
- return new TestDescription(syncId, player.inventory, ScreenHandlerContext.create(player.getEntityWorld(), buf.readBlockPos()));
+ GUI_SCREEN_HANDLER_TYPE = ScreenHandlerRegistry.registerSimple(new Identifier(MODID, "gui"), (int syncId, PlayerInventory inventory) -> {
+ return new TestDescription(GUI_SCREEN_HANDLER_TYPE, syncId, inventory, ScreenHandlerContext.EMPTY);
});
-
+
Optional<ModContainer> containerOpt = FabricLoader.getInstance().getModContainer("jankson");
if (containerOpt.isPresent()) {
ModContainer jankson = containerOpt.get();
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 3d5e48c..732494e 100644
--- a/GuiTest/src/main/java/io/github/cottonmc/test/TestDescription.java
+++ b/GuiTest/src/main/java/io/github/cottonmc/test/TestDescription.java
@@ -4,12 +4,13 @@ import io.github.cottonmc.cotton.gui.SyncedGuiDescription;
import io.github.cottonmc.cotton.gui.widget.*;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.screen.ScreenHandlerContext;
+import net.minecraft.screen.ScreenHandlerType;
import net.minecraft.text.LiteralText;
public class TestDescription extends SyncedGuiDescription {
- public TestDescription(int syncId, PlayerInventory playerInventory, ScreenHandlerContext context) {
- super(syncId, playerInventory, getBlockInventory(context), null);
+ public TestDescription(ScreenHandlerType<?> type, int syncId, PlayerInventory playerInventory, ScreenHandlerContext context) {
+ super(type, 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 f0d3f27..5ef61c2 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
@@ -4,15 +4,16 @@ import io.github.cottonmc.cotton.gui.client.CottonInventoryScreen;
import io.github.cottonmc.test.LibGuiTest;
import io.github.cottonmc.test.TestDescription;
import net.fabricmc.api.ClientModInitializer;
-import net.fabricmc.fabric.api.client.screen.ScreenProviderRegistry;
-import net.minecraft.screen.ScreenHandlerContext;
-import net.minecraft.util.Identifier;
+import net.fabricmc.fabric.api.client.screenhandler.v1.ScreenRegistry;
public class LibGuiTestClient implements ClientModInitializer {
@Override
public void onInitializeClient() {
- ScreenProviderRegistry.INSTANCE.registerFactory(new Identifier(LibGuiTest.MODID, "gui"), (syncId, identifier, player, buf)->new CottonInventoryScreen<TestDescription>(new TestDescription(syncId, player.inventory, ScreenHandlerContext.create(player.getEntityWorld(), buf.readBlockPos())), player));
+ ScreenRegistry.<TestDescription, CottonInventoryScreen<TestDescription>>register(
+ LibGuiTest.GUI_SCREEN_HANDLER_TYPE,
+ (desc, inventory, title) -> new CottonInventoryScreen<>(desc, inventory.player, title)
+ );
}
}
diff --git a/gradle.properties b/gradle.properties
index fc09dbd..bb69335 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -3,8 +3,8 @@ org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# check these on https://fabricmc.net/use
- minecraft_version=1.16-pre2
- yarn_mappings=1.16-pre2+build.1
+ minecraft_version=1.16-pre8
+ yarn_mappings=1.16-pre8+build.1
loader_version=0.8.7+build.201
# Mod Properties
@@ -13,6 +13,6 @@ org.gradle.jvmargs=-Xmx1G
archives_base_name = LibGui
# Dependencies
- fabric_version=0.11.6+build.355-1.16
+ fabric_version=0.12.4+build.365-1.16
jankson_version=3.0.0+j1.2.0
modmenu_version=1.11.8+build.13
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 4891765..0b2daa1 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
@@ -249,7 +249,7 @@ public class CottonInventoryScreen<T extends SyncedGuiDescription> extends Handl
@Override
protected void drawForeground(MatrixStack matrices, int mouseX, int mouseY) {
if (description != null) {
- this.textRenderer.draw(matrices, this.title, (float) this.field_25267, (float) this.field_25268, description.getTitleColor());
+ this.textRenderer.draw(matrices, this.title, (float) this.titleX, (float) this.titleY, description.getTitleColor());
}
// Don't draw the player inventory label as it's drawn by the widget itself
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 b4ae9d3..cde778a 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
@@ -2,12 +2,12 @@ package io.github.cottonmc.cotton.gui.client;
import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem;
-import net.minecraft.class_5348;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.BufferBuilder;
import net.minecraft.client.render.Tessellator;
import net.minecraft.client.render.VertexFormats;
import net.minecraft.client.util.math.MatrixStack;
+import net.minecraft.text.StringRenderable;
import net.minecraft.util.Identifier;
import org.lwjgl.opengl.GL11;
@@ -364,7 +364,7 @@ public class ScreenDrawing {
* @param color the text color
* @since 1.9.0
*/
- public static void drawString(MatrixStack matrices, class_5348 text, Alignment align, int x, int y, int width, int color) {
+ public static void drawString(MatrixStack matrices, StringRenderable text, Alignment align, int x, int y, int width, int color) {
switch(align) {
case LEFT: {
MinecraftClient.getInstance().textRenderer.draw(matrices, text, x, y, color);
@@ -428,7 +428,7 @@ public class ScreenDrawing {
* @param width the width of the string, used for aligning
* @param color the text color
*/
- public static void drawStringWithShadow(MatrixStack matrices, class_5348 text, Alignment align, int x, int y, int width, int color) {
+ public static void drawStringWithShadow(MatrixStack matrices, StringRenderable text, Alignment align, int x, int y, int width, int color) {
switch(align) {
case LEFT: {
MinecraftClient.getInstance().textRenderer.drawWithShadow(matrices, text, x, y, color);
@@ -471,7 +471,7 @@ public class ScreenDrawing {
* @param y the Y position
* @param color the text color
*/
- public static void drawString(MatrixStack matrices, class_5348 text, int x, int y, int color) {
+ public static void drawString(MatrixStack matrices, StringRenderable text, int x, int y, int color) {
MinecraftClient.getInstance().textRenderer.draw(matrices, text, x, y, color);
}
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WButton.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WButton.java
index 7087e00..b308483 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WButton.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WButton.java
@@ -2,18 +2,18 @@ package io.github.cottonmc.cotton.gui.widget;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
-import net.minecraft.class_5348;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.widget.AbstractButtonWidget;
import net.minecraft.client.sound.PositionedSoundInstance;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.sound.SoundEvents;
+import net.minecraft.text.StringRenderable;
import io.github.cottonmc.cotton.gui.client.ScreenDrawing;
import io.github.cottonmc.cotton.gui.widget.data.Alignment;
public class WButton extends WWidget {
- private class_5348 label;
+ private StringRenderable label;
protected int color = WLabel.DEFAULT_TEXT_COLOR;
protected int darkmodeColor = WLabel.DEFAULT_TEXT_COLOR;
private boolean enabled = true;
@@ -25,7 +25,7 @@ public class WButton extends WWidget {
}
- public WButton(class_5348 text) {
+ public WButton(StringRenderable text) {
this.label = text;
}
@@ -110,11 +110,11 @@ public class WButton extends WWidget {
return this;
}
- public class_5348 getLabel() {
+ public StringRenderable getLabel() {
return label;
}
- public WButton setLabel(class_5348 label) {
+ public WButton setLabel(StringRenderable label) {
this.label = label;
return this;
}
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WItem.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WItem.java
index ffba2c3..1269afe 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WItem.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WItem.java
@@ -62,7 +62,7 @@ public class WItem extends WWidget {
MinecraftClient mc = MinecraftClient.getInstance();
ItemRenderer renderer = mc.getItemRenderer();
renderer.zOffset = 100f;
- renderer.method_27951(mc.player, items.get(current), x + getWidth() / 2 - 9, y + getHeight() / 2 - 9);
+ renderer.renderInGui(items.get(current), x + getWidth() / 2 - 9, y + getHeight() / 2 - 9);
renderer.zOffset = 0f;
}
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WLabel.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WLabel.java
index 518a4a6..ab1764f 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WLabel.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WLabel.java
@@ -2,11 +2,11 @@ package io.github.cottonmc.cotton.gui.widget;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
-import net.minecraft.class_5348;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.LiteralText;
+import net.minecraft.text.StringRenderable;
import net.minecraft.text.Style;
import io.github.cottonmc.cotton.gui.client.LibGuiClient;
@@ -20,7 +20,7 @@ import javax.annotation.Nullable;
* A single-line label widget.
*/
public class WLabel extends WWidget {
- protected class_5348 text;
+ protected StringRenderable text;
protected Alignment alignment = Alignment.LEFT;
protected int color;
protected int darkmodeColor;
@@ -51,7 +51,7 @@ public class WLabel extends WWidget {
* @param text the text of the label
* @param color the color of the label
*/
- public WLabel(class_5348 text, int color) {
+ public WLabel(StringRenderable text, int color) {
this.text = text;
this.color = color;
this.darkmodeColor = (color==DEFAULT_TEXT_COLOR) ? DEFAULT_DARKMODE_TEXT_COLOR : color;
@@ -72,7 +72,7 @@ public class WLabel extends WWidget {
* @param text the text of the label
* @since 1.8.0
*/
- public WLabel(class_5348 text) {
+ public WLabel(StringRenderable text) {
this(text, DEFAULT_TEXT_COLOR);
}
@@ -196,7 +196,7 @@ public class WLabel extends WWidget {
*
* @return the text
*/
- public class_5348 getText() {
+ public StringRenderable getText() {
return text;
}
@@ -206,7 +206,7 @@ public class WLabel extends WWidget {
* @param text the new text
* @return this label
*/
- public WLabel setText(class_5348 text) {
+ public WLabel setText(StringRenderable text) {
this.text = text;
return this;
}
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 7f122da..4cce813 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
@@ -2,10 +2,10 @@ package io.github.cottonmc.cotton.gui.widget;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
-import net.minecraft.class_5348;
import net.minecraft.client.gui.widget.AbstractButtonWidget;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.client.util.math.Vector3f;
+import net.minecraft.text.StringRenderable;
import net.minecraft.util.math.Quaternion;
import io.github.cottonmc.cotton.gui.client.ScreenDrawing;
@@ -26,7 +26,7 @@ import javax.annotation.Nullable;
public class WLabeledSlider extends WAbstractSlider {
private static final Quaternion ROTATION_Z_270 = Vector3f.POSITIVE_X.getDegreesQuaternion(270);
- @Nullable private class_5348 label = null;
+ @Nullable private StringRenderable label = null;
@Nullable private LabelUpdater labelUpdater = null;
private Alignment labelAlignment = Alignment.CENTER;
@@ -59,7 +59,7 @@ public class WLabeledSlider extends WAbstractSlider {
* @param axis the slider axis
* @param label the slider label (can be null)
*/
- public WLabeledSlider(int min, int max, Axis axis, @Nullable class_5348 label) {
+ public WLabeledSlider(int min, int max, Axis axis, @Nullable StringRenderable label) {
this(min, max, axis);
this.label = label;
}
@@ -71,7 +71,7 @@ public class WLabeledSlider extends WAbstractSlider {
* @param max the maximum value
* @param label the slider label (can be null)
*/
- public WLabeledSlider(int min, int max, @Nullable class_5348 label) {
+ public WLabeledSlider(int min, int max, @Nullable StringRenderable label) {
this(min, max);
this.label = label;
}
@@ -91,7 +91,7 @@ public class WLabeledSlider extends WAbstractSlider {
* @return the label
*/
@Nullable
- public class_5348 getLabel() {
+ public StringRenderable getLabel() {
return label;
}
@@ -100,7 +100,7 @@ public class WLabeledSlider extends WAbstractSlider {
*
* @param label the new label
*/
- public void setLabel(@Nullable class_5348 label) {
+ public void setLabel(@Nullable StringRenderable label) {
this.label = label;
}
@@ -228,6 +228,6 @@ public class WLabeledSlider extends WAbstractSlider {
* @param value the slider value
* @return the label
*/
- class_5348 updateLabel(int value);
+ StringRenderable updateLabel(int value);
}
}
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WText.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WText.java
index 4cf268e..8e4d826 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WText.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WText.java
@@ -2,11 +2,11 @@ package io.github.cottonmc.cotton.gui.widget;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
-import net.minecraft.class_5348;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.util.math.MatrixStack;
+import net.minecraft.text.StringRenderable;
import net.minecraft.text.Style;
import io.github.cottonmc.cotton.gui.client.LibGuiClient;
@@ -24,18 +24,18 @@ import java.util.Objects;
* @since 1.8.0
*/
public class WText extends WWidget {
- protected class_5348 text;
+ protected StringRenderable text;
protected int color;
protected int darkmodeColor;
protected Alignment alignment = Alignment.LEFT;
- private List<class_5348> wrappedLines;
+ private List<StringRenderable> wrappedLines;
private boolean wrappingScheduled = false;
- public WText(class_5348 text) {
+ public WText(StringRenderable text) {
this(text, WLabel.DEFAULT_TEXT_COLOR);
}
- public WText(class_5348 text, int color) {
+ public WText(StringRenderable text, int color) {
this.text = Objects.requireNonNull(text, "text must not be null");
this.color = color;
this.darkmodeColor = (color == WLabel.DEFAULT_TEXT_COLOR) ? WLabel.DEFAULT_DARKMODE_TEXT_COLOR : color;
@@ -72,7 +72,7 @@ public class WText extends WWidget {
int lineIndex = y / font.fontHeight;
if (lineIndex >= 0 && lineIndex < wrappedLines.size()) {
- class_5348 line = wrappedLines.get(lineIndex);
+ StringRenderable line = wrappedLines.get(lineIndex);
return font.getTextHandler().trimToWidth(line, x);
}
@@ -89,7 +89,7 @@ public class WText extends WWidget {
TextRenderer font = MinecraftClient.getInstance().textRenderer;
for (int i = 0; i < wrappedLines.size(); i++) {
- class_5348 line = wrappedLines.get(i);
+ StringRenderable line = wrappedLines.get(i);
int c = LibGuiClient.config.darkMode ? darkmodeColor : color;
ScreenDrawing.drawString(matrices, line, alignment, x, y + i * font.fontHeight, width, c);
@@ -120,7 +120,7 @@ public class WText extends WWidget {
*
* @return the text
*/
- public class_5348 getText() {
+ public StringRenderable getText() {
return text;
}
@@ -130,7 +130,7 @@ public class WText extends WWidget {
* @param text the new text
* @return this label
*/
- public WText setText(class_5348 text) {
+ public WText setText(StringRenderable text) {
Objects.requireNonNull(text, "text is null");
this.text = text;
wrappingScheduled = true;
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WToggleButton.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WToggleButton.java
index 9d1306f..b917d97 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WToggleButton.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WToggleButton.java
@@ -2,11 +2,11 @@ package io.github.cottonmc.cotton.gui.widget;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
-import net.minecraft.class_5348;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.sound.PositionedSoundInstance;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.sound.SoundEvents;
+import net.minecraft.text.StringRenderable;
import net.minecraft.util.Identifier;
import io.github.cottonmc.cotton.gui.client.LibGuiClient;
@@ -25,7 +25,7 @@ public class WToggleButton extends WWidget {
protected Identifier offImage;
protected Identifier focusImage = DEFAULT_FOCUS_IMAGE;
- @Nullable protected class_5348 label = null;
+ @Nullable protected StringRenderable label = null;
protected boolean isOn = false;
@Nullable protected Consumer<Boolean> onToggle = null;
@@ -39,7 +39,7 @@ public class WToggleButton extends WWidget {
}
/** Defaults with text */
- public WToggleButton(class_5348 text) {
+ public WToggleButton(StringRenderable text) {
this(DEFAULT_ON_IMAGE, DEFAULT_OFF_IMAGE);
this.label = text;
}
@@ -51,7 +51,7 @@ public class WToggleButton extends WWidget {
}
/** Custom images, with default sizes and a label */
- public WToggleButton(Identifier onImage, Identifier offImage, class_5348 label) {
+ public WToggleButton(Identifier onImage, Identifier offImage, StringRenderable label) {
this.onImage = onImage;
this.offImage = offImage;
this.label = label;
@@ -118,11 +118,11 @@ public class WToggleButton extends WWidget {
}
@Nullable
- public class_5348 getLabel() {
+ public StringRenderable getLabel() {
return label;
}
- public WToggleButton setLabel(@Nullable class_5348 label) {
+ public WToggleButton setLabel(@Nullable StringRenderable label) {
this.label = label;
return this;
}