Skip to content

Commit

Permalink
update to mc 1.17.1 and wthit 3.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
deirn committed Jul 8, 2021
1 parent 50c1f3a commit 63ade90
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 69 deletions.
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
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
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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -15,7 +15,7 @@

import static badasintended.megane.util.MeganeUtils.CONFIG;

public class BlacklistConfigScreen extends GuiOptions {
public class BlacklistConfigScreen extends ConfigScreen {

private final Set<Identifier> set;

Expand All @@ -25,22 +25,22 @@ public BlacklistConfigScreen(Screen parent, Text title, Set<Identifier> 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<Identifier> set) {
SetEntry(ConfigScreen screen, ConfigListWidget options, Identifier value, Set<Identifier> 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/._-]*$"));
Expand Down
Original file line number Diff line number Diff line change
@@ -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<K, V> extends GuiOptions {
public class MapConfigScreen<K, V> extends ConfigScreen {

private final Map<K, V> map;
private final Function<K, String> keyStr;
Expand All @@ -35,24 +37,24 @@ public MapConfigScreen(Screen parent, Text title, Map<K, V> map, Function<K, Str
}

@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.map.forEach((key, val) -> 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;
private final ButtonWidget removeButton;
private String key;
private String val;

PairEntry(GuiOptions screen, OptionsListWidget options, String key, String val, TriConsumer<String, String, String> consumer, Predicate<String> keyPredicate, Predicate<String> valPredicate) {
PairEntry(ConfigScreen screen, ConfigListWidget options, String key, String val, TriConsumer<String, String, String> consumer, Predicate<String> keyPredicate, Predicate<String> valPredicate) {
this.key = key;
this.val = val;
this.keyTextField = new TextFieldWidget(client.textRenderer, 0, 0, 100, 18, new LiteralText(""));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<String> ALL = s -> true;
private static final Predicate<String> HEX = s -> s.matches("^[a-fA-F0-9]*$");
Expand Down Expand Up @@ -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<Boolean> consumer) {
return new OptionsEntryValueBoolean(tlKey(type), value, consumer);
private static BooleanValue bool(String type, boolean value, Consumer<Boolean> consumer) {
return new BooleanValue(tlKey(type), value, consumer);
}

private static <T> OptionsEntryValueInput<T> input(String type, T t, Consumer<T> consumer, Predicate<String> validator) {
return new OptionsEntryValueInput<>(tlKey(type), t, consumer, validator);
private static <T> InputValue<T> input(String type, T t, Consumer<T> consumer, Predicate<String> 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)));
Expand All @@ -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)));
Expand All @@ -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<>(
Expand All @@ -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<>(
Expand All @@ -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())))));
Expand All @@ -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())))));
Expand All @@ -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)));
Expand Down
Original file line number Diff line number Diff line change
@@ -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<Object> {
public class SidedEntry extends ConfigValue<Object> {

private final OptionsListWidget.Entry entry;
private final ConfigListWidget.Entry entry;
private final Side side;

private Element listener = null;
Expand All @@ -18,12 +18,12 @@ public class SidedEntry extends OptionsEntryValue<Object> {
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();
Expand All @@ -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);

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<OptionsListWidget> 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<ConfigListWidget> 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))
)));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/resources/megane-runtime.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"MixinTooltipRegistrar"
],
"client" : [
"MixinGuiConfigPlugins",
"MixinPluginConfigScreen",
"MixinTitleScreen"
],
"injectors" : {
Expand Down

0 comments on commit 63ade90

Please sign in to comment.