diff --git a/gradle.properties b/gradle.properties index 2ee4c5b..b6fa136 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,7 +1,7 @@ org.gradle.jvmargs = -Xmx1G -minecraft = 1.17 -yarn = 1.17+build.13 +minecraft = 1.17.1 +yarn = 1.17.1+build.1 loader = 0.11.3 # Mod Properties @@ -9,7 +9,7 @@ group = com.github.badasintended archivesBaseName = megane # Dependencies -wthit = 3.6.0 +wthit = 3.7.0 modmenu = 2.0.2 fabricKotlin = 1.6.1+kotlin.1.5.10 diff --git a/src/runtime/java/badasintended/megane/runtime/config/screen/BlacklistConfigScreen.java b/src/runtime/java/badasintended/megane/runtime/config/screen/BlacklistConfigScreen.java index c55bcbc..b1f9f59 100644 --- a/src/runtime/java/badasintended/megane/runtime/config/screen/BlacklistConfigScreen.java +++ b/src/runtime/java/badasintended/megane/runtime/config/screen/BlacklistConfigScreen.java @@ -2,9 +2,9 @@ import java.util.Set; -import mcp.mobius.waila.gui.GuiOptions; -import mcp.mobius.waila.gui.config.OptionsEntryButton; -import mcp.mobius.waila.gui.config.OptionsListWidget; +import mcp.mobius.waila.gui.screen.ConfigScreen; +import mcp.mobius.waila.gui.widget.ButtonEntry; +import mcp.mobius.waila.gui.widget.ConfigListWidget; import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.widget.ButtonWidget; import net.minecraft.client.gui.widget.TextFieldWidget; @@ -15,7 +15,7 @@ import static badasintended.megane.util.MeganeUtils.CONFIG; -public class BlacklistConfigScreen extends GuiOptions { +public class BlacklistConfigScreen extends ConfigScreen { private final Set set; @@ -25,22 +25,22 @@ public BlacklistConfigScreen(Screen parent, Text title, Set set) { } @Override - public OptionsListWidget getOptions() { - OptionsListWidget options = new OptionsListWidget(this, client, width + 45, height, 32, height - 32, 30, CONFIG::save); + public ConfigListWidget getOptions() { + ConfigListWidget options = new ConfigListWidget(this, client, width, height, 32, height - 32, 30, CONFIG::save); this.set.forEach(value -> options.add(new SetEntry(this, options, value, this.set))); - options.add(new OptionsEntryButton("config.megane.add", new ButtonWidget(0, 0, 100, 20, LiteralText.EMPTY, w -> + options.add(new ButtonEntry("config.megane.add", new ButtonWidget(0, 0, 100, 20, LiteralText.EMPTY, w -> options.children().add(options.children().size() - 1, new SetEntry(this, options, null, set)) ))); return options; } - static class SetEntry extends OptionsListWidget.Entry { + static class SetEntry extends ConfigListWidget.Entry { private final TextFieldWidget textField; private final ButtonWidget removeButton; private Identifier value; - SetEntry(GuiOptions screen, OptionsListWidget options, Identifier value, Set set) { + SetEntry(ConfigScreen screen, ConfigListWidget options, Identifier value, Set set) { this.value = value; this.textField = new TextFieldWidget(client.textRenderer, 0, 0, 200, 18, new LiteralText("")); this.textField.setTextPredicate(s -> s.matches("^[a-z0-9/_.-]*$") || s.matches("^[a-z0-9_.-]*:[a-z0-9/._-]*$")); diff --git a/src/runtime/java/badasintended/megane/runtime/config/screen/MapConfigScreen.java b/src/runtime/java/badasintended/megane/runtime/config/screen/MapConfigScreen.java index 8725dfb..c99078f 100644 --- a/src/runtime/java/badasintended/megane/runtime/config/screen/MapConfigScreen.java +++ b/src/runtime/java/badasintended/megane/runtime/config/screen/MapConfigScreen.java @@ -1,21 +1,23 @@ package badasintended.megane.runtime.config.screen; -import badasintended.megane.api.function.Functions.TriConsumer; import java.util.Map; import java.util.function.Function; import java.util.function.Predicate; -import mcp.mobius.waila.gui.GuiOptions; -import mcp.mobius.waila.gui.config.OptionsEntryButton; -import mcp.mobius.waila.gui.config.OptionsListWidget; + +import badasintended.megane.api.function.Functions.TriConsumer; +import mcp.mobius.waila.gui.screen.ConfigScreen; +import mcp.mobius.waila.gui.widget.ButtonEntry; +import mcp.mobius.waila.gui.widget.ConfigListWidget; import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.widget.ButtonWidget; import net.minecraft.client.gui.widget.TextFieldWidget; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.text.LiteralText; import net.minecraft.text.Text; + import static badasintended.megane.util.MeganeUtils.CONFIG; -public class MapConfigScreen extends GuiOptions { +public class MapConfigScreen extends ConfigScreen { private final Map map; private final Function keyStr; @@ -35,16 +37,16 @@ public MapConfigScreen(Screen parent, Text title, Map map, Function options.add(new PairEntry(this, options, keyStr.apply(key), valStr.apply(val), mapApplier, keyPredicate, valPredicate))); - options.add(new OptionsEntryButton("config.megane.add", new ButtonWidget(0, 0, 100, 20, LiteralText.EMPTY, w -> + options.add(new ButtonEntry("config.megane.add", new ButtonWidget(0, 0, 100, 20, LiteralText.EMPTY, w -> options.children().add(options.children().size() - 1, new PairEntry(this, options, "", "", mapApplier, keyPredicate, valPredicate)) ))); return options; } - static class PairEntry extends OptionsListWidget.Entry { + static class PairEntry extends ConfigListWidget.Entry { private final TextFieldWidget keyTextField; private final TextFieldWidget valTextField; @@ -52,7 +54,7 @@ static class PairEntry extends OptionsListWidget.Entry { private String key; private String val; - PairEntry(GuiOptions screen, OptionsListWidget options, String key, String val, TriConsumer consumer, Predicate keyPredicate, Predicate valPredicate) { + PairEntry(ConfigScreen screen, ConfigListWidget options, String key, String val, TriConsumer consumer, Predicate keyPredicate, Predicate valPredicate) { this.key = key; this.val = val; this.keyTextField = new TextFieldWidget(client.textRenderer, 0, 0, 100, 18, new LiteralText("")); diff --git a/src/runtime/java/badasintended/megane/runtime/config/screen/MeganeConfigScreen.java b/src/runtime/java/badasintended/megane/runtime/config/screen/MeganeConfigScreen.java index 1089a79..a5f526f 100644 --- a/src/runtime/java/badasintended/megane/runtime/config/screen/MeganeConfigScreen.java +++ b/src/runtime/java/badasintended/megane/runtime/config/screen/MeganeConfigScreen.java @@ -7,11 +7,11 @@ import badasintended.megane.runtime.config.widget.Side; import badasintended.megane.runtime.config.widget.SidedEntry; import badasintended.megane.util.MeganeUtils; -import mcp.mobius.waila.gui.GuiOptions; -import mcp.mobius.waila.gui.config.OptionsEntryButton; -import mcp.mobius.waila.gui.config.OptionsListWidget; -import mcp.mobius.waila.gui.config.value.OptionsEntryValueBoolean; -import mcp.mobius.waila.gui.config.value.OptionsEntryValueInput; +import mcp.mobius.waila.gui.screen.ConfigScreen; +import mcp.mobius.waila.gui.widget.ButtonEntry; +import mcp.mobius.waila.gui.widget.ConfigListWidget; +import mcp.mobius.waila.gui.widget.value.BooleanValue; +import mcp.mobius.waila.gui.widget.value.InputValue; import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.widget.ButtonWidget; import net.minecraft.text.LiteralText; @@ -26,7 +26,7 @@ import static badasintended.megane.util.MeganeUtils.CONFIG; import static badasintended.megane.util.MeganeUtils.config; -public class MeganeConfigScreen extends GuiOptions { +public class MeganeConfigScreen extends ConfigScreen { private static final Predicate ALL = s -> true; private static final Predicate HEX = s -> s.matches("^[a-fA-F0-9]*$"); @@ -58,30 +58,30 @@ private static String tlKey(String type) { return "config.megane." + type; } - private static OptionsEntryButton button(String type, ButtonWidget.PressAction pressAction) { - return new OptionsEntryButton(tlKey(type), new ButtonWidget(0, 0, 100, 20, LiteralText.EMPTY, pressAction)); + private static ButtonEntry button(String type, ButtonWidget.PressAction pressAction) { + return new ButtonEntry(tlKey(type), new ButtonWidget(0, 0, 100, 20, LiteralText.EMPTY, pressAction)); } - private static OptionsEntryValueBoolean bool(String type, boolean value, Consumer consumer) { - return new OptionsEntryValueBoolean(tlKey(type), value, consumer); + private static BooleanValue bool(String type, boolean value, Consumer consumer) { + return new BooleanValue(tlKey(type), value, consumer); } - private static OptionsEntryValueInput input(String type, T t, Consumer consumer, Predicate validator) { - return new OptionsEntryValueInput<>(tlKey(type), t, consumer, validator); + private static InputValue input(String type, T t, Consumer consumer, Predicate validator) { + return new InputValue<>(tlKey(type), t, consumer, validator); } - private static SidedEntry sided(Side side, OptionsListWidget.Entry entry) { + private static SidedEntry sided(Side side, ConfigListWidget.Entry entry) { return new SidedEntry(side, entry); } @Override @SuppressWarnings("ConstantConditions") - public OptionsListWidget getOptions() { - OptionsListWidget options = new OptionsListWidget(this, client, width + 45, height, 32, height - 32, 30, CONFIG::save); + public ConfigListWidget getOptions() { + ConfigListWidget options = new ConfigListWidget(this, client, width, height, 32, height - 32, 30, CONFIG::save); options.add(button("inventory", w -> client.openScreen(new MeganeConfigScreen(this, tl(tlKey("inventory"))) { @Override - public OptionsListWidget getOptions() { - OptionsListWidget options = new OptionsListWidget(this, client, width + 45, height, 32, height - 32, 30); + public ConfigListWidget getOptions() { + ConfigListWidget options = new ConfigListWidget(this, client, width, height, 32, height - 32, 30); options.add(sided(AND, bool("enabled", config().inventory.isEnabled(), config().inventory::setEnabled))); options.add(sided(SERVER, bool("inventory.itemCount", config().inventory.isItemCount(), config().inventory::setItemCount))); options.add(sided(SERVER, bool("inventory.nbt", config().inventory.isNbt(), config().inventory::setNbt))); @@ -93,8 +93,8 @@ public OptionsListWidget getOptions() { }))); options.add(button("entityInventory", w -> client.openScreen(new MeganeConfigScreen(this, tl(tlKey("entityInventory"))) { @Override - public OptionsListWidget getOptions() { - OptionsListWidget options = new OptionsListWidget(this, client, width + 45, height, 32, height - 32, 30); + public ConfigListWidget getOptions() { + ConfigListWidget options = new ConfigListWidget(this, client, width, height, 32, height - 32, 30); options.add(sided(AND, bool("enabled", config().entityInventory.isEnabled(), config().entityInventory::setEnabled))); options.add(sided(SERVER, bool("inventory.itemCount", config().entityInventory.isItemCount(), config().entityInventory::setItemCount))); options.add(sided(SERVER, bool("inventory.nbt", config().entityInventory.isNbt(), config().entityInventory::setNbt))); @@ -106,8 +106,8 @@ public OptionsListWidget getOptions() { }))); options.add(button("energy", w -> client.openScreen(new MeganeConfigScreen(this, tl(tlKey("energy"))) { @Override - public OptionsListWidget getOptions() { - OptionsListWidget options = new OptionsListWidget(this, client, width + 45, height, 32, height - 32, 30); + public ConfigListWidget getOptions() { + ConfigListWidget options = new ConfigListWidget(this, client, width, height, 32, height - 32, 30); options.add(sided(AND, bool("enabled", config().energy.isEnabled(), config().energy::setEnabled))); options.add(sided(CLIENT, bool("expand", config().energy.isExpandWhenSneak(), config().energy::setExpandWhenSneak))); options.add(sided(CLIENT, button("energy.unit", w -> client.openScreen(new MapConfigScreen<>( @@ -130,8 +130,8 @@ this, tl(tlKey("energy.color")), config().energy.getColors(), s -> s, INT2RGB, N }))); options.add(button("fluid", w -> client.openScreen(new MeganeConfigScreen(this, tl(tlKey("fluid"))) { @Override - public OptionsListWidget getOptions() { - OptionsListWidget options = new OptionsListWidget(this, client, width + 45, height, 32, height - 32, 30); + public ConfigListWidget getOptions() { + ConfigListWidget options = new ConfigListWidget(this, client, width, height, 32, height - 32, 30); options.add(sided(AND, bool("enabled", config().fluid.isEnabled(), config().fluid::setEnabled))); options.add(sided(CLIENT, bool("expand", config().fluid.isExpandWhenSneak(), config().fluid::setExpandWhenSneak))); options.add(sided(CLIENT, button("fluid.color", w -> client.openScreen(new MapConfigScreen<>( @@ -147,8 +147,8 @@ this, tl(tlKey("fluid.color")), config().fluid.getColors(), Identifier::toString }))); options.add(button("progress", w -> client.openScreen(new MeganeConfigScreen(this, tl(tlKey("progress"))) { @Override - public OptionsListWidget getOptions() { - OptionsListWidget options = new OptionsListWidget(this, client, width + 45, height, 32, height - 32, 30); + public ConfigListWidget getOptions() { + ConfigListWidget options = new ConfigListWidget(this, client, width, height, 32, height - 32, 30); options.add(sided(AND, bool("enabled", config().progress.isEnabled(), config().progress::setEnabled))); options.add(sided(CLIENT, bool("progress.showWhenZero", config().progress.isShowWhenZero(), config().progress::setShowWhenZero))); options.add(sided(PLUS, button("blacklist", w -> client.openScreen(new BlacklistConfigScreen(this, tl(tlKey("progress.blacklist")), config().progress.getBlacklist()))))); @@ -157,8 +157,8 @@ public OptionsListWidget getOptions() { }))); options.add(button("owner", w -> client.openScreen(new MeganeConfigScreen(this, tl(tlKey("owner"))) { @Override - public OptionsListWidget getOptions() { - OptionsListWidget options = new OptionsListWidget(this, client, width + 45, height, 32, height - 32, 30); + public ConfigListWidget getOptions() { + ConfigListWidget options = new ConfigListWidget(this, client, width, height, 32, height - 32, 30); options.add(sided(AND, bool("enabled", config().petOwner.isEnabled(), config().petOwner::setEnabled))); options.add(sided(SERVER, bool("owner.offline", config().petOwner.isOffline(), config().petOwner::setOffline))); options.add(sided(PLUS, button("blacklist", w -> client.openScreen(new BlacklistConfigScreen(this, tl(tlKey("owner.blacklist")), config().petOwner.getBlacklist()))))); @@ -167,8 +167,8 @@ public OptionsListWidget getOptions() { }))); options.add(button("effect", w -> client.openScreen(new MeganeConfigScreen(this, tl(tlKey("effect"))) { @Override - public OptionsListWidget getOptions() { - OptionsListWidget options = new OptionsListWidget(this, client, width + 45, height, 32, height - 32, 30); + public ConfigListWidget getOptions() { + ConfigListWidget options = new ConfigListWidget(this, client, width, height, 32, height - 32, 30); options.add(sided(AND, bool("enabled", config().effect.isEnabled(), config().effect::setEnabled))); options.add(sided(AND, bool("effect.level", config().effect.getLevel(), config().effect::setLevel))); options.add(sided(AND, bool("effect.hidden", config().effect.getHidden(), config().effect::setHidden))); diff --git a/src/runtime/java/badasintended/megane/runtime/config/widget/SidedEntry.java b/src/runtime/java/badasintended/megane/runtime/config/widget/SidedEntry.java index d5b54b6..d946103 100644 --- a/src/runtime/java/badasintended/megane/runtime/config/widget/SidedEntry.java +++ b/src/runtime/java/badasintended/megane/runtime/config/widget/SidedEntry.java @@ -1,15 +1,15 @@ package badasintended.megane.runtime.config.widget; -import mcp.mobius.waila.gui.config.OptionsListWidget; -import mcp.mobius.waila.gui.config.value.OptionsEntryValue; +import mcp.mobius.waila.gui.widget.ConfigListWidget; +import mcp.mobius.waila.gui.widget.value.ConfigValue; import net.minecraft.client.gui.Element; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.text.LiteralText; import net.minecraft.text.Text; -public class SidedEntry extends OptionsEntryValue { +public class SidedEntry extends ConfigValue { - private final OptionsListWidget.Entry entry; + private final ConfigListWidget.Entry entry; private final Side side; private Element listener = null; @@ -18,12 +18,12 @@ public class SidedEntry extends OptionsEntryValue { private Runnable save = () -> { }; - public SidedEntry(Side side, OptionsListWidget.Entry entry) { + public SidedEntry(Side side, ConfigListWidget.Entry entry) { super("", null); this.entry = entry; this.side = side; - if (entry instanceof OptionsEntryValue value) { + if (entry instanceof ConfigValue value) { this.listener = value.getListener(); this.title = value.getTitle(); this.description = value.getDescription(); @@ -35,8 +35,8 @@ public SidedEntry(Side side, OptionsListWidget.Entry entry) { protected void drawValue(MatrixStack matrices, int entryWidth, int entryHeight, int x, int y, int mouseX, int mouseY, boolean selected, float partialTicks) { this.entry.render(matrices, 0, y, x, entryWidth, entryHeight, mouseX, mouseY, selected, partialTicks); - int sideX = x + 8 - client.textRenderer.getWidth(side.text); - int sideY = y + (entryHeight / 4) + (client.textRenderer.fontHeight / 2); + float sideX = x - 5 - client.textRenderer.getWidth(side.text); + float sideY = y + (entryHeight - client.textRenderer.fontHeight) / 2f; client.textRenderer.drawWithShadow(matrices, side.text, sideX, sideY, 0xFFFFFFFF); diff --git a/src/runtime/java/badasintended/megane/runtime/mixin/MixinGuiConfigPlugins.java b/src/runtime/java/badasintended/megane/runtime/mixin/MixinPluginConfigScreen.java similarity index 56% rename from src/runtime/java/badasintended/megane/runtime/mixin/MixinGuiConfigPlugins.java rename to src/runtime/java/badasintended/megane/runtime/mixin/MixinPluginConfigScreen.java index 13923ba..5a3bc55 100644 --- a/src/runtime/java/badasintended/megane/runtime/mixin/MixinGuiConfigPlugins.java +++ b/src/runtime/java/badasintended/megane/runtime/mixin/MixinPluginConfigScreen.java @@ -1,9 +1,9 @@ package badasintended.megane.runtime.mixin; import badasintended.megane.runtime.config.screen.MeganeConfigScreen; -import mcp.mobius.waila.gui.GuiConfigPlugins; -import mcp.mobius.waila.gui.config.OptionsEntryButton; -import mcp.mobius.waila.gui.config.OptionsListWidget; +import mcp.mobius.waila.gui.screen.PluginConfigScreen; +import mcp.mobius.waila.gui.widget.ButtonEntry; +import mcp.mobius.waila.gui.widget.ConfigListWidget; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.widget.ButtonWidget; import net.minecraft.text.LiteralText; @@ -12,13 +12,13 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -@Mixin(GuiConfigPlugins.class) -public class MixinGuiConfigPlugins { +@Mixin(PluginConfigScreen.class) +public class MixinPluginConfigScreen { @Inject(method = "getOptions", at = @At("TAIL"), remap = false) - private void add(CallbackInfoReturnable cir) { - cir.getReturnValue().children().add(1, new OptionsEntryButton("config.waila.megane", new ButtonWidget(0, 0, 100, 20, LiteralText.EMPTY, w -> - MinecraftClient.getInstance().openScreen(new MeganeConfigScreen((GuiConfigPlugins) (Object) this)) + private void add(CallbackInfoReturnable cir) { + cir.getReturnValue().children().add(1, new ButtonEntry("config.waila.megane", new ButtonWidget(0, 0, 100, 20, LiteralText.EMPTY, w -> + MinecraftClient.getInstance().openScreen(new MeganeConfigScreen((PluginConfigScreen) (Object) this)) ))); } diff --git a/src/runtime/java/badasintended/megane/runtime/mixin/MixinTooltipRegistrar.java b/src/runtime/java/badasintended/megane/runtime/mixin/MixinTooltipRegistrar.java index 6137206..7decef4 100644 --- a/src/runtime/java/badasintended/megane/runtime/mixin/MixinTooltipRegistrar.java +++ b/src/runtime/java/badasintended/megane/runtime/mixin/MixinTooltipRegistrar.java @@ -3,8 +3,8 @@ import mcp.mobius.waila.api.IBlockComponentProvider; import mcp.mobius.waila.api.IServerDataProvider; import mcp.mobius.waila.api.TooltipPosition; -import mcp.mobius.waila.overlay.TooltipRegistrar; import mcp.mobius.waila.plugin.vanilla.FurnaceComponent; +import mcp.mobius.waila.registry.TooltipRegistrar; import net.minecraft.block.entity.BlockEntity; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; diff --git a/src/runtime/resources/megane-runtime.mixins.json b/src/runtime/resources/megane-runtime.mixins.json index 5d50a6a..962359a 100644 --- a/src/runtime/resources/megane-runtime.mixins.json +++ b/src/runtime/resources/megane-runtime.mixins.json @@ -9,7 +9,7 @@ "MixinTooltipRegistrar" ], "client" : [ - "MixinGuiConfigPlugins", + "MixinPluginConfigScreen", "MixinTitleScreen" ], "injectors" : {