Skip to content

Commit

Permalink
mc1.19.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Plastoid501 committed Jul 19, 2024
1 parent 559e4d4 commit 0312c32
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 34 deletions.
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ org.gradle.parallel=true

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.19.3
yarn_mappings=1.19.3+build.5
minecraft_version=1.19.2
yarn_mappings=1.19.2+build.28
loader_version=0.15.11

# Mod Properties
mod_version=1.0.1
maven_group=net.plastoid501.movement
archives_base_name=movement-in-gui-mc1.19.3
archives_base_name=movement-in-gui-mc1.19.2

# Dependencies
fabric_version=0.76.1+1.19.3
modmenu_version=5.1.0-beta.4
fabric_version=0.77.0+1.19.2
modmenu_version=4.2.0-beta.2
4 changes: 2 additions & 2 deletions src/main/java/net/plastoid501/movement/gui/ConfigScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ public ConfigScreen(Screen parent) {
protected void init() {
this.configList = new ConfigWidget(this, this.client);
this.addSelectableChild(this.configList);
this.addDrawableChild(ButtonWidget.builder(ScreenTexts.DONE, (button) -> {
this.addDrawableChild(new ButtonWidget(this.width / 2 - 100, this.height - 27, 200, 20, ScreenTexts.DONE, (button) -> {
this.close();
}).dimensions(this.width / 2 - 100, this.height - 27, 200, 20).build());
}));
}

@Override
Expand Down
49 changes: 27 additions & 22 deletions src/main/java/net/plastoid501/movement/gui/widget/ConfigWidget.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.Element;
import net.minecraft.client.gui.Selectable;
import net.minecraft.client.gui.tooltip.Tooltip;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.gui.widget.ElementListWidget;
import net.minecraft.client.gui.widget.TextWidget;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Style;
import net.minecraft.text.Text;
Expand All @@ -22,6 +20,7 @@
import net.plastoid501.movement.util.FileUtil;

import java.awt.*;
import java.util.Collections;
import java.util.List;


Expand Down Expand Up @@ -75,27 +74,30 @@ public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
}

public class CategoryEntry extends Entry {
private final TextWidget text;
private final TextRenderer textRenderer;
private final Text text;
private final int textWidth;
CategoryEntry(Text CategoryName, TextRenderer textRenderer) {
this.text = new TextWidget(CategoryName, textRenderer);
this.textWidth = this.text.getWidth();
this.textRenderer = textRenderer;
this.text = CategoryName;
this.textWidth = textRenderer.getWidth(this.text);
}

@Override
public List<? extends Element> children() {
return ImmutableList.of(this.text);
return Collections.emptyList();
}

@Override
public List<? extends Selectable> selectableChildren() {
return ImmutableList.of(this.text);
return Collections.emptyList();
}

@Override
public void render(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
this.text.setPos(ConfigWidget.this.client.currentScreen.width / 2 - this.textWidth / 2, y + 5);
this.text.render(matrices, mouseX, mouseY, tickDelta);
//this.text.setPos(ConfigWidget.this.client.currentScreen.width / 2 - this.textWidth / 2, y + 5);
//this.text.render(matrices, mouseX, mouseY, tickDelta);
this.textRenderer.draw(matrices, this.text, ConfigWidget.this.client.currentScreen.width / 2 - this.textWidth / 2, y + 5, Color.WHITE.getRGB());
}

@Override
Expand All @@ -105,48 +107,51 @@ void update() {
}

public class ToggleEntry extends Entry {
private final TextRenderer textRenderer;
private final ToggleConfig defaultConfig;
private boolean enable;
private final TextWidget text;
private final Text text;
private final ButtonWidget enableButton;
private final ButtonWidget resetButton;

ToggleEntry(String key, TextRenderer textRenderer, ModConfig config) {
this.textRenderer = textRenderer;
this.defaultConfig = Configs.getToggles().get(key);
this.enable = config.getToggles().get(key).isEnable();
this.text = new TextWidget(Text.literal(key), textRenderer);
this.text.setTooltip(Tooltip.of(Text.literal(this.defaultConfig.getNarrator())));
this.enableButton = ButtonWidget.builder(Text.literal(this.enable ? "ON" : "OFF").setStyle(Style.EMPTY.withColor(this.enable ? Color.GREEN.getRGB() : Color.red.getRGB())), button -> {
this.text = Text.literal(key);
//this.text.setTooltip(Tooltip.of(Text.literal(this.defaultConfig.getNarrator())));
this.enableButton = new ButtonWidget(0, 0, 60, 20, Text.literal(this.enable ? "ON" : "OFF").setStyle(Style.EMPTY.withColor(this.enable ? Color.GREEN.getRGB() : Color.red.getRGB())), button -> {
this.enable = !this.enable;
FileUtil.updateToggleConfig(key, new JToggleConfig(this.enable));
this.update();
}).size(60, 20).build();
this.resetButton = ButtonWidget.builder(Text.literal("RESET"), button -> {
});
this.resetButton = new ButtonWidget(0, 0, 40, 20, Text.literal("RESET"), button -> {
this.enable = this.defaultConfig.isEnable();
FileUtil.updateToggleConfig(key, new JToggleConfig(this.enable));
this.update();
}).size(40, 20).build();
});
this.resetButton.active = this.defaultConfig.isEnable() != this.enable;

}

@Override
public List<? extends Element> children() {
return ImmutableList.of(this.text, this.enableButton, this.resetButton);
return ImmutableList.of(this.enableButton, this.resetButton);
}

@Override
public List<? extends Selectable> selectableChildren() {
return ImmutableList.of(this.text, this.enableButton, this.resetButton);
return ImmutableList.of(this.enableButton, this.resetButton);
}

@Override
public void render(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
this.text.setPos(x - 60, y + 5);
this.text.render(matrices, mouseX, mouseY, tickDelta);
this.enableButton.setPos(x + 190, y);
this.textRenderer.draw(matrices, this.text, x - 60, y + 5, Color.WHITE.getRGB());
this.enableButton.x = x + 190;
this.enableButton.y = y;
this.enableButton.render(matrices, mouseX, mouseY, tickDelta);
this.resetButton.setPos(x + 253, y);
this.resetButton.x = x + 253;
this.resetButton.y = y;
this.resetButton.render(matrices, mouseX, mouseY, tickDelta);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import net.minecraft.client.gui.screen.*;
import net.minecraft.client.gui.screen.option.GameOptionsScreen;
import net.minecraft.client.gui.screen.option.OptionsScreen;
import net.minecraft.client.gui.screen.option.TelemetryInfoScreen;
import net.minecraft.client.gui.screen.pack.PackScreen;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.client.option.KeyBinding;
Expand All @@ -32,7 +31,7 @@ private boolean modifyTickMovement(KeyBinding instance) {
client.currentScreen instanceof GameOptionsScreen ||
client.currentScreen instanceof GameMenuScreen ||
client.currentScreen instanceof OptionsScreen ||
client.currentScreen instanceof TelemetryInfoScreen ||
//client.currentScreen instanceof TelemetryInfoScreen ||
client.currentScreen instanceof StatsScreen ||
client.currentScreen instanceof OpenToLanScreen ||
client.currentScreen instanceof ConfirmLinkScreen ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import net.minecraft.client.gui.screen.*;
import net.minecraft.client.gui.screen.option.GameOptionsScreen;
import net.minecraft.client.gui.screen.option.OptionsScreen;
import net.minecraft.client.gui.screen.option.TelemetryInfoScreen;
import net.minecraft.client.gui.screen.pack.PackScreen;
import net.minecraft.client.input.KeyboardInput;
import net.minecraft.client.option.KeyBinding;
Expand All @@ -31,7 +30,7 @@ private boolean modifyTick(KeyBinding instance) {
client.currentScreen instanceof GameOptionsScreen ||
client.currentScreen instanceof GameMenuScreen ||
client.currentScreen instanceof OptionsScreen ||
client.currentScreen instanceof TelemetryInfoScreen ||
//client.currentScreen instanceof TelemetryInfoScreen ||
client.currentScreen instanceof StatsScreen ||
client.currentScreen instanceof OpenToLanScreen ||
client.currentScreen instanceof ConfirmLinkScreen ||
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"movement-in-gui.mixins.json"
],
"depends": {
"minecraft": "1.19.3"
"minecraft": ">=1.19 <=1.19.2"
},
"suggests": {
"another-mod": "*"
Expand Down

0 comments on commit 0312c32

Please sign in to comment.