Compare commits
No commits in common. "main" and "v1.0.0" have entirely different histories.
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,6 +1,5 @@
|
||||
# User-specific stuff
|
||||
.idea/
|
||||
remappedSrc/
|
||||
|
||||
*.iml
|
||||
*.ipr
|
||||
|
129
build.gradle
129
build.gradle
@ -1,15 +1,11 @@
|
||||
plugins {
|
||||
id 'fabric-loom' version '1.7-SNAPSHOT'
|
||||
id 'fabric-loom' version '1.1-SNAPSHOT'
|
||||
id 'maven-publish'
|
||||
}
|
||||
|
||||
version = project.mod_version
|
||||
group = project.maven_group
|
||||
|
||||
base {
|
||||
archivesName = project.archives_base_name
|
||||
}
|
||||
|
||||
repositories {
|
||||
// Add repositories to retrieve artifacts from in here.
|
||||
// You should only use this when depending on other mods because
|
||||
@ -22,17 +18,6 @@ repositories {
|
||||
}
|
||||
}
|
||||
|
||||
loom {
|
||||
splitEnvironmentSourceSets()
|
||||
|
||||
mods {
|
||||
"cmods" {
|
||||
sourceSet sourceSets.client
|
||||
sourceSet sourceSets.main
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// To change the versions see the gradle.properties file
|
||||
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
||||
@ -46,37 +31,47 @@ dependencies {
|
||||
|
||||
processResources {
|
||||
inputs.property "version", project.version
|
||||
filteringCharset "UTF-8"
|
||||
|
||||
filesMatching("fabric.mod.json") {
|
||||
expand "version": project.version
|
||||
}
|
||||
}
|
||||
|
||||
def targetJavaVersion = 17
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
it.options.release = 21
|
||||
// ensure that the encoding is set to UTF-8, no matter what the system default is
|
||||
// this fixes some edge cases with special characters not displaying correctly
|
||||
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
|
||||
// If Javadoc is generated, this must be specified in that task too.
|
||||
it.options.encoding = "UTF-8"
|
||||
if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
|
||||
it.options.release = targetJavaVersion
|
||||
}
|
||||
}
|
||||
|
||||
java {
|
||||
def javaVersion = JavaVersion.toVersion(targetJavaVersion)
|
||||
if (JavaVersion.current() < javaVersion) {
|
||||
toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
|
||||
}
|
||||
archivesBaseName = project.archives_base_name
|
||||
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
|
||||
// if it is present.
|
||||
// If you remove this line, sources will not be generated.
|
||||
withSourcesJar()
|
||||
|
||||
sourceCompatibility = JavaVersion.VERSION_21
|
||||
targetCompatibility = JavaVersion.VERSION_21
|
||||
}
|
||||
|
||||
jar {
|
||||
from("LICENSE") {
|
||||
rename { "${it}_${project.base.archivesName.get()}"}
|
||||
rename { "${it}_${project.archivesBaseName}" }
|
||||
}
|
||||
}
|
||||
|
||||
// configure the maven publication
|
||||
publishing {
|
||||
publications {
|
||||
create("mavenJava", MavenPublication) {
|
||||
artifactId = project.archives_base_name
|
||||
mavenJava(MavenPublication) {
|
||||
from components.java
|
||||
}
|
||||
}
|
||||
@ -89,91 +84,3 @@ publishing {
|
||||
// retrieving dependencies.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//plugins {
|
||||
// id 'fabric-loom' version '1.7-SNAPSHOT'
|
||||
// id 'maven-publish'
|
||||
//}
|
||||
//
|
||||
//version = project.mod_version
|
||||
//group = project.maven_group
|
||||
//
|
||||
//repositories {
|
||||
// // Add repositories to retrieve artifacts from in here.
|
||||
// // You should only use this when depending on other mods because
|
||||
// // Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
|
||||
// // See https://docs.gradle.org/current/userguide/declaring_repositories.html
|
||||
// // for more information about repositories.
|
||||
// maven {
|
||||
// name = 'TerraformersMC'
|
||||
// url = 'https://maven.terraformersmc.com/releases'
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//dependencies {
|
||||
// // To change the versions see the gradle.properties file
|
||||
// minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
||||
// mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
|
||||
// modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
|
||||
//
|
||||
// // Fabric API. This is technically optional, but you probably want it anyway.
|
||||
// modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
||||
// modCompileOnly "com.terraformersmc:modmenu:4.1.1"
|
||||
//}
|
||||
//
|
||||
//processResources {
|
||||
// inputs.property "version", project.version
|
||||
// filteringCharset "UTF-8"
|
||||
//
|
||||
// filesMatching("fabric.mod.json") {
|
||||
// expand "version": project.version
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//def targetJavaVersion = 21
|
||||
//tasks.withType(JavaCompile).configureEach {
|
||||
// // ensure that the encoding is set to UTF-8, no matter what the system default is
|
||||
// // this fixes some edge cases with special characters not displaying correctly
|
||||
// // see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
|
||||
// // If Javadoc is generated, this must be specified in that task too.
|
||||
// it.options.encoding = "UTF-8"
|
||||
// if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
|
||||
// it.options.release = targetJavaVersion
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//java {
|
||||
// def javaVersion = JavaVersion.toVersion(targetJavaVersion)
|
||||
// if (JavaVersion.current() < javaVersion) {
|
||||
// toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
|
||||
// }
|
||||
// archivesBaseName = project.archives_base_name
|
||||
// // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
|
||||
// // if it is present.
|
||||
// // If you remove this line, sources will not be generated.
|
||||
// withSourcesJar()
|
||||
//}
|
||||
//
|
||||
//jar {
|
||||
// from("LICENSE") {
|
||||
// rename { "${it}_${project.archivesBaseName}" }
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//// configure the maven publication
|
||||
//publishing {
|
||||
// publications {
|
||||
// mavenJava(MavenPublication) {
|
||||
// from components.java
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
|
||||
// repositories {
|
||||
// // Add repositories to publish to here.
|
||||
// // Notice: This block does NOT have the same function as the block in the top level.
|
||||
// // The repositories here will be used for publishing your artifact, not for
|
||||
// // retrieving dependencies.
|
||||
// }
|
||||
//}
|
||||
|
@ -1,15 +1,14 @@
|
||||
# Done to increase the memory available to gradle.
|
||||
org.gradle.jvmargs=-Xmx4G
|
||||
org.gradle.parallel=true
|
||||
org.gradle.jvmargs=-Xmx1G
|
||||
# Fabric Properties
|
||||
# check these on https://modmuss50.me/fabric.html
|
||||
minecraft_version=1.21.3
|
||||
yarn_mappings=1.21.3+build.2
|
||||
loader_version=0.16.7
|
||||
minecraft_version=1.19.3
|
||||
yarn_mappings=1.19.3+build.5
|
||||
loader_version=0.14.13
|
||||
# Mod Properties
|
||||
mod_version=1.2.3
|
||||
mod_version=1.0.0
|
||||
maven_group=cmods
|
||||
archives_base_name=cmods
|
||||
# Dependencies
|
||||
# check this on https://modmuss50.me/fabric.html
|
||||
fabric_version=0.107.0+1.21.3
|
||||
fabric_version=0.73.0+1.19.3
|
||||
|
3
gradle/wrapper/gradle-wrapper.properties
vendored
3
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,6 +1,5 @@
|
||||
#Sun Jun 30 01:31:47 MDT 2024
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
@ -1,18 +0,0 @@
|
||||
package cmods.cmods.api;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class PropertyUtils {
|
||||
public static boolean getBooleanProperty(@Nullable java.util.Properties properties, String key, Boolean default_value) {
|
||||
if (properties == null)
|
||||
return default_value;
|
||||
return Boolean.parseBoolean(properties.getProperty(key, default_value.toString()));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public static int getIntegerProperty(@Nullable java.util.Properties properties, String key, Integer default_value) {
|
||||
if (properties == null)
|
||||
return default_value;
|
||||
return Integer.parseInt(properties.getProperty(key, default_value.toString()));
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
package cmods.cmods.api;
|
||||
|
||||
import cmods.cmods.ui.Line;
|
||||
import cmods.cmods.client.ui.Line;
|
||||
import net.minecraft.util.Pair;
|
||||
|
||||
import java.util.ArrayList;
|
@ -1,9 +1,9 @@
|
||||
package cmods.cmods.api;
|
||||
|
||||
import cmods.cmods.options.CmodsOptions;
|
||||
import cmods.cmods.ui.CmodsOptionsScreen;
|
||||
import cmods.cmods.ui.Line;
|
||||
import cmods.cmods.ui.UIOptionsScreen;
|
||||
import cmods.cmods.client.options.CmodsOptions;
|
||||
import cmods.cmods.client.ui.CmodsOptionsScreen;
|
||||
import cmods.cmods.client.ui.Line;
|
||||
import cmods.cmods.client.ui.UIOptionsScreen;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
@ -1,4 +1,4 @@
|
||||
package cmods.cmods;
|
||||
package cmods.cmods.client;
|
||||
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
import net.fabricmc.api.EnvType;
|
@ -1,11 +1,10 @@
|
||||
package cmods.cmods;
|
||||
package cmods.cmods.client;
|
||||
|
||||
import cmods.cmods.ui.CmodsOptionsScreen;
|
||||
import cmods.cmods.client.ui.CmodsOptionsScreen;
|
||||
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
|
||||
import com.terraformersmc.modmenu.api.ModMenuApi;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class ModMenuConfig implements ModMenuApi {
|
||||
@Override
|
||||
public ConfigScreenFactory<?> getModConfigScreenFactory() {
|
@ -1,11 +1,10 @@
|
||||
package cmods.cmods.options;
|
||||
package cmods.cmods.client.options;
|
||||
|
||||
public class BooleanOption extends Option<Boolean> {
|
||||
public BooleanOption(Boolean default_value) {
|
||||
super(default_value);
|
||||
}
|
||||
|
||||
@SuppressWarnings("UnusedReturnValue")
|
||||
public boolean toggle() {
|
||||
return value = !value;
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package cmods.cmods.options;
|
||||
package cmods.cmods.client.options;
|
||||
|
||||
import cmods.cmods.api.ModuleOptions;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
@ -11,8 +11,6 @@ import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Properties;
|
||||
|
||||
import static cmods.cmods.api.PropertyUtils.getBooleanProperty;
|
||||
|
||||
public final class CmodsOptions {
|
||||
private static CmodsOptions instance = null;
|
||||
|
||||
@ -84,34 +82,31 @@ public final class CmodsOptions {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean getBooleanProperty(@Nullable Properties properties, String key, Boolean default_value) {
|
||||
if (properties == null)
|
||||
return default_value;
|
||||
return Boolean.parseBoolean(properties.getProperty(key, default_value.toString()));
|
||||
}
|
||||
|
||||
|
||||
public static class UIOptions {
|
||||
private final String PREFIX = "ui.";
|
||||
|
||||
public BooleanOption enabled = new BooleanOption(true);
|
||||
public BooleanOption show_coordinates = new BooleanOption(true);
|
||||
public BooleanOption show_fps = new BooleanOption(true);
|
||||
public BooleanOption show_in_pause = new BooleanOption(true);
|
||||
public BooleanOption show_in_options = new BooleanOption(true);
|
||||
|
||||
|
||||
UIOptions() { }
|
||||
|
||||
|
||||
void load(@Nullable Properties properties) {
|
||||
enabled.value = getBooleanProperty(properties, PREFIX + "enabled", enabled.value);
|
||||
show_coordinates.value = getBooleanProperty(properties, PREFIX + "show_coordinates", show_coordinates.value);
|
||||
show_fps.value = getBooleanProperty(properties, PREFIX + "show_fps", show_coordinates.value);
|
||||
show_in_pause.value = getBooleanProperty(properties, PREFIX + "show_in_pause", show_in_pause.value);
|
||||
show_in_options.value = getBooleanProperty(properties, PREFIX + "show_in_options", show_in_options.value);
|
||||
enabled.value = getBooleanProperty(properties, PREFIX + "enabled", true);
|
||||
show_coordinates.value = getBooleanProperty(properties, PREFIX + "show_coordinates", true);
|
||||
}
|
||||
|
||||
void save(Properties properties) {
|
||||
properties.setProperty(PREFIX + "enabled", enabled.value.toString());
|
||||
properties.setProperty(PREFIX + "show_coordinates", show_coordinates.value.toString());
|
||||
properties.setProperty(PREFIX + "show_fps", show_fps.value.toString());
|
||||
properties.setProperty(PREFIX + "show_in_pause", show_in_pause.value.toString());
|
||||
properties.setProperty(PREFIX + "show_in_options", show_in_options.value.toString());
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
package cmods.cmods.options;
|
||||
package cmods.cmods.client.options;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class IntegerOption extends Option<Integer> {
|
||||
public IntegerOption(Integer default_value) {
|
||||
super(default_value);
|
@ -1,6 +1,5 @@
|
||||
package cmods.cmods.options;
|
||||
package cmods.cmods.client.options;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class Option<T> {
|
||||
public T value;
|
||||
|
@ -1,20 +1,20 @@
|
||||
package cmods.cmods.ui;
|
||||
package cmods.cmods.client.ui;
|
||||
|
||||
import cmods.cmods.api.ButtonBuilder;
|
||||
import cmods.cmods.CmodsClient;
|
||||
import cmods.cmods.options.CmodsOptions;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import cmods.cmods.client.CmodsClient;
|
||||
import cmods.cmods.client.options.CmodsOptions;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
import net.minecraft.client.gui.widget.GridWidget;
|
||||
import net.minecraft.client.gui.widget.SimplePositioningWidget;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.screen.ScreenTexts;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Pair;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static cmods.cmods.ui.Constants.*;
|
||||
import static cmods.cmods.client.ui.Constants.*;
|
||||
|
||||
public class CmodsOptionsScreen extends Screen {
|
||||
private final CmodsOptions options = CmodsOptions.getInstance();
|
||||
@ -49,9 +49,9 @@ public class CmodsOptionsScreen extends Screen {
|
||||
adder.add(ButtonWidget.builder(ScreenTexts.DONE, button -> client.setScreen(parent))
|
||||
.width(doneButtonWidth).build(), 2, adder.copyPositioner().marginTop(doneButtonRowIncrement));
|
||||
|
||||
grid.refreshPositions();
|
||||
grid.recalculateDimensions();
|
||||
SimplePositioningWidget.setPos(grid, 0, startHeight, this.width, this.height, 0.5f, 0.0f);
|
||||
grid.forEachChild(this::addDrawableChild);
|
||||
addDrawableChild(grid);
|
||||
}
|
||||
|
||||
public static void addExtraButtons(ArrayList<ButtonBuilder> buttons, int precedence) {
|
||||
@ -67,15 +67,15 @@ public class CmodsOptionsScreen extends Screen {
|
||||
extraWidgets.add(newPair);
|
||||
}
|
||||
|
||||
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
|
||||
// renderBackground(context, mouseX, mouseY, delta);
|
||||
super.render(context, mouseX, mouseY, delta);
|
||||
|
||||
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
|
||||
renderBackground(matrices);
|
||||
Text versionText = Text.literal("v" + CmodsClient.version);
|
||||
|
||||
context.drawCenteredTextWithShadow(textRenderer, title, this.width / 2, 15, 0xffffff);
|
||||
context.drawTextWithShadow(textRenderer, versionText, this.width - textRenderer.getWidth(versionText) - 2,
|
||||
|
||||
drawCenteredText(matrices, textRenderer, title, this.width / 2, 15, 0xffffff);
|
||||
drawTextWithShadow(matrices, textRenderer, versionText, this.width - textRenderer.getWidth(versionText) - 2,
|
||||
this.height - textRenderer.fontHeight - 2, 0xffffff);
|
||||
super.render(matrices, mouseX, mouseY, delta);
|
||||
}
|
||||
|
||||
public void removed() {
|
@ -1,6 +1,5 @@
|
||||
package cmods.cmods.ui;
|
||||
package cmods.cmods.client.ui;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class Constants {
|
||||
public static final int buttonWidth = 150;
|
||||
public static final int buttonHeight = 20;
|
@ -1,19 +1,17 @@
|
||||
package cmods.cmods.ui;
|
||||
package cmods.cmods.client.ui;
|
||||
|
||||
import cmods.cmods.options.IntegerOption;
|
||||
import cmods.cmods.client.options.IntegerOption;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
import net.minecraft.client.gui.widget.Widget;
|
||||
import net.minecraft.client.gui.widget.ClickableWidget;
|
||||
import net.minecraft.client.gui.widget.WrapperWidget;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.List;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class IntegerAdjustWidget extends WrapperWidget {
|
||||
private final ArrayList<ButtonWidget> elements;
|
||||
private final ArrayList<ButtonWidget> children;
|
||||
private final IntegerOption option;
|
||||
private final Text text;
|
||||
private final int delta;
|
||||
|
||||
public IntegerAdjustWidget(Text text, IntegerOption option) {
|
||||
@ -21,15 +19,25 @@ public class IntegerAdjustWidget extends WrapperWidget {
|
||||
}
|
||||
|
||||
public IntegerAdjustWidget(Text text, IntegerOption option, int delta) {
|
||||
super(0, 0, 150, 20);
|
||||
this.text = text;
|
||||
super(0, 0, 150, 20, text);
|
||||
this.option = option;
|
||||
this.delta = delta;
|
||||
elements = new ArrayList<>(3);
|
||||
children = new ArrayList<>(3);
|
||||
|
||||
refreshDimensions();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<? extends ClickableWidget> wrappedWidgets() {
|
||||
return children;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWidth(int width) {
|
||||
super.setWidth(width);
|
||||
refreshDimensions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setX(int x) {
|
||||
super.setX(x);
|
||||
@ -42,11 +50,17 @@ public class IntegerAdjustWidget extends WrapperWidget {
|
||||
refreshDimensions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPos(int x, int y) {
|
||||
super.setPos(x, y);
|
||||
refreshDimensions();
|
||||
}
|
||||
|
||||
private void refreshDimensions() {
|
||||
final int button_width = 25;
|
||||
final String labelStr = text.getString() + ": ";
|
||||
final String labelStr = getMessage().getString() + ": ";
|
||||
|
||||
elements.clear();
|
||||
children.clear();
|
||||
|
||||
ButtonWidget middle = ButtonWidget.builder(Text.literal(labelStr + option.get()), button -> {})
|
||||
.dimensions(getX() + button_width - 1, getY(),width - (button_width * 2) + 2, height).build();
|
||||
@ -59,15 +73,8 @@ public class IntegerAdjustWidget extends WrapperWidget {
|
||||
button -> middle.setMessage(Text.literal(labelStr + option.inc(delta))))
|
||||
.dimensions(getX() + width - button_width + 1, getY(), button_width, height).build();
|
||||
|
||||
elements.add(sub);
|
||||
elements.add(middle);
|
||||
elements.add(add);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forEachElement(Consumer<Widget> consumer) {
|
||||
for (Widget element: elements) {
|
||||
consumer.accept(element);
|
||||
}
|
||||
children.add(sub);
|
||||
children.add(middle);
|
||||
children.add(add);
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package cmods.cmods.ui;
|
||||
package cmods.cmods.client.ui;
|
||||
|
||||
import net.minecraft.text.Text;
|
||||
|
@ -1,8 +1,8 @@
|
||||
package cmods.cmods.ui;
|
||||
package cmods.cmods.client.ui;
|
||||
|
||||
import cmods.cmods.options.BooleanOption;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import cmods.cmods.client.options.BooleanOption;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.text.Text;
|
||||
import org.apache.http.util.TextUtils;
|
||||
|
||||
@ -15,7 +15,7 @@ public class ToggleButton extends ButtonWidget {
|
||||
|
||||
|
||||
public ToggleButton(int x, int y, int width, int height, Text name, BooleanOption option) {
|
||||
this(x, y, width, height, name, option, DEFAULT_NARRATION_SUPPLIER);
|
||||
this(x, y, width, height, name, option, ButtonWidget.DEFAULT_NARRATION_SUPPLIER);
|
||||
}
|
||||
|
||||
public ToggleButton(int x, int y, int width, int height, Text name, BooleanOption option,
|
||||
@ -36,8 +36,8 @@ public class ToggleButton extends ButtonWidget {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderWidget(DrawContext context, int mouseX, int mouseY, float delta) {
|
||||
public void renderButton(MatrixStack matrices, int mouseX, int mouseY, float delta) {
|
||||
updateText();
|
||||
super.renderWidget(context, mouseX, mouseY, delta);
|
||||
super.renderButton(matrices, mouseX, mouseY, delta);
|
||||
}
|
||||
}
|
@ -1,19 +1,19 @@
|
||||
package cmods.cmods.ui;
|
||||
package cmods.cmods.client.ui;
|
||||
|
||||
import cmods.cmods.api.ButtonBuilder;
|
||||
import cmods.cmods.options.CmodsOptions;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import cmods.cmods.client.options.CmodsOptions;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
import net.minecraft.client.gui.widget.GridWidget;
|
||||
import net.minecraft.client.gui.widget.SimplePositioningWidget;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.screen.ScreenTexts;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Pair;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static cmods.cmods.ui.Constants.*;
|
||||
import static cmods.cmods.client.ui.Constants.*;
|
||||
|
||||
public class UIOptionsScreen extends Screen {
|
||||
private final Screen parent;
|
||||
@ -42,15 +42,6 @@ public class UIOptionsScreen extends Screen {
|
||||
adder.add(new ToggleButton(0, 0, buttonWidth, buttonHeight,
|
||||
Text.translatable("cmods.options.ui.show_coordinates"), options.uiOptions.show_coordinates));
|
||||
|
||||
adder.add(new ToggleButton(0, 0, buttonWidth, buttonHeight,
|
||||
Text.translatable("cmods.options.ui.show_fps"), options.uiOptions.show_fps));
|
||||
|
||||
adder.add(new ToggleButton(0, 0, buttonWidth, buttonHeight,
|
||||
Text.translatable("cmods.options.ui.show_in_pause"), options.uiOptions.show_in_pause));
|
||||
|
||||
adder.add(new ToggleButton(0, 0, buttonWidth, buttonHeight,
|
||||
Text.translatable("cmods.options.ui.show_in_options"), options.uiOptions.show_in_options));
|
||||
|
||||
for (Pair<ArrayList<ButtonBuilder>, Integer> buttonArray : extraButtons) {
|
||||
for (ButtonBuilder buttonBuilder : buttonArray.getLeft()) {
|
||||
adder.add(buttonBuilder.build(this, client));
|
||||
@ -60,9 +51,9 @@ public class UIOptionsScreen extends Screen {
|
||||
adder.add(ButtonWidget.builder(ScreenTexts.DONE, button -> client.setScreen(parent))
|
||||
.width(doneButtonWidth).build(), 2, adder.copyPositioner().marginTop(doneButtonRowIncrement));
|
||||
|
||||
grid.refreshPositions();
|
||||
grid.recalculateDimensions();
|
||||
SimplePositioningWidget.setPos(grid, 0, startHeight, this.width, this.height, 0.5f, 0.0f);
|
||||
grid.forEachChild(this::addDrawableChild);
|
||||
addDrawableChild(grid);
|
||||
}
|
||||
|
||||
public static void addButtons(ArrayList<ButtonBuilder> buttons, int precedence) {
|
||||
@ -78,10 +69,10 @@ public class UIOptionsScreen extends Screen {
|
||||
extraButtons.add(newPair);
|
||||
}
|
||||
|
||||
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
|
||||
// this.renderBackground(context, mouseX, mouseY, delta);
|
||||
super.render(context, mouseX, mouseY, delta);
|
||||
context.drawCenteredTextWithShadow(this.textRenderer, this.title, this.width / 2, 15, 0xffffff);
|
||||
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
|
||||
this.renderBackground(matrices);
|
||||
drawCenteredText(matrices, this.textRenderer, this.title, this.width / 2, 15, 0xffffff);
|
||||
super.render(matrices, mouseX, mouseY, delta);
|
||||
}
|
||||
|
||||
public void removed() {
|
@ -1,14 +1,13 @@
|
||||
package cmods.cmods.mixin;
|
||||
|
||||
import cmods.cmods.client.options.CmodsOptions;
|
||||
import cmods.cmods.api.HudRenderCallback;
|
||||
import cmods.cmods.options.CmodsOptions;
|
||||
import cmods.cmods.ui.Line;
|
||||
import cmods.cmods.client.ui.Line;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.hud.DebugHud;
|
||||
import net.minecraft.client.gui.DrawableHelper;
|
||||
import net.minecraft.client.gui.hud.InGameHud;
|
||||
import net.minecraft.client.render.RenderTickCounter;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Pair;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@ -23,19 +22,17 @@ import java.util.ArrayList;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@Mixin(InGameHud.class)
|
||||
public abstract class HudMixin {
|
||||
public abstract class HudMixin extends DrawableHelper {
|
||||
|
||||
@Shadow @Final private MinecraftClient client;
|
||||
@Shadow public abstract TextRenderer getTextRenderer();
|
||||
|
||||
|
||||
@Shadow @Final private DebugHud debugHud;
|
||||
|
||||
@Inject(at = @At("TAIL"), method = "render")
|
||||
private void render(DrawContext context, RenderTickCounter tickCounter, CallbackInfo ci) {
|
||||
private void render(MatrixStack matrices, float tickDelta, CallbackInfo ci) {
|
||||
CmodsOptions options = CmodsOptions.getInstance();
|
||||
|
||||
if (this.debugHud.shouldShowDebugHud() || this.client.isPaused() || client.player == null ||
|
||||
if (this.client.options.debugEnabled || this.client.isPaused() || client.player == null ||
|
||||
!options.uiOptions.enabled.get()) {
|
||||
return;
|
||||
}
|
||||
@ -55,12 +52,6 @@ public abstract class HudMixin {
|
||||
lines.add(new Line(Text.literal(coordinate_string), white, 0));
|
||||
}
|
||||
|
||||
if (options.uiOptions.show_fps.get()) {
|
||||
int fps = client.getCurrentFps();
|
||||
String fps_string = String.format("FPS: %d", fps);
|
||||
lines.add(new Line(Text.literal(fps_string), white, 0));
|
||||
}
|
||||
|
||||
for (Pair<Consumer<ArrayList<Line>>, Integer> callback: HudRenderCallback.callbacks) {
|
||||
callback.getLeft().accept(lines);
|
||||
}
|
||||
@ -75,7 +66,8 @@ public abstract class HudMixin {
|
||||
y += 2;
|
||||
}
|
||||
|
||||
context.drawTextWithShadow(textRenderer, line.text(), x + (5 * line.indent()), y, line.color());
|
||||
DrawableHelper.drawTextWithShadow(matrices, textRenderer, line.text(), x + (5 * line.indent()), y,
|
||||
line.color());
|
||||
y += textRenderer.fontHeight;
|
||||
}
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
package cmods.cmods.mixin;
|
||||
|
||||
import cmods.cmods.options.CmodsOptions;
|
||||
import cmods.cmods.ui.CmodsOptionsScreen;
|
||||
import cmods.cmods.client.ui.CmodsOptionsScreen;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.screen.option.OptionsScreen;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
@ -20,7 +19,7 @@ public class OptionsMixin extends Screen {
|
||||
|
||||
@Inject(at = @At("TAIL"), method = "init")
|
||||
private void init(CallbackInfo ci) {
|
||||
if (client == null || !CmodsOptions.getInstance().uiOptions.show_in_options.get())
|
||||
if (client == null)
|
||||
return;
|
||||
|
||||
addDrawableChild(ButtonWidget.builder(Text.translatable("cmods.options"),
|
@ -1,8 +1,7 @@
|
||||
package cmods.cmods.mixin;
|
||||
|
||||
|
||||
import cmods.cmods.options.CmodsOptions;
|
||||
import cmods.cmods.ui.CmodsOptionsScreen;
|
||||
import cmods.cmods.client.ui.CmodsOptionsScreen;
|
||||
import net.minecraft.client.gui.screen.GameMenuScreen;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
@ -21,7 +20,7 @@ public class PauseMixin extends Screen {
|
||||
|
||||
@Inject(at = @At("TAIL"), method = "init")
|
||||
public void init(CallbackInfo ci) {
|
||||
if (client == null || !CmodsOptions.getInstance().uiOptions.show_in_pause.get())
|
||||
if (client == null)
|
||||
return;
|
||||
|
||||
addDrawableChild(ButtonWidget.builder(Text.translatable("cmods.options"),
|
@ -10,8 +10,5 @@
|
||||
"cmods.options.ui": "UI",
|
||||
"cmods.options.ui.title": "UI Options",
|
||||
"cmods.options.ui.hud_enabled": "Show HUD",
|
||||
"cmods.options.ui.show_coordinates": "Show Coordinates",
|
||||
"cmods.options.ui.show_fps": "Show FPS",
|
||||
"cmods.options.ui.show_in_pause": "Show In Pause",
|
||||
"cmods.options.ui.show_in_options": "Show In Options"
|
||||
"cmods.options.ui.show_coordinates": "Show Coordinates"
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
"required": true,
|
||||
"minVersion": "0.8",
|
||||
"package": "cmods.cmods.mixin",
|
||||
"compatibilityLevel": "JAVA_21",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"mixins": [
|
||||
],
|
||||
"client": [
|
@ -5,32 +5,24 @@
|
||||
"name": "Cmods",
|
||||
"description": "<description>",
|
||||
"authors": [
|
||||
"Cameron Reed"
|
||||
"CameronReed"
|
||||
],
|
||||
"contact": {
|
||||
"sources": "https://gitea.cam123.dev/"
|
||||
"repo": "https://gitea.cam123.dev/"
|
||||
},
|
||||
"license": "MIT",
|
||||
"icon": "assets/cmods/icon.png",
|
||||
"environment": "client",
|
||||
"entrypoints": {
|
||||
"client": [
|
||||
"cmods.cmods.CmodsClient"
|
||||
],
|
||||
"modmenu": [
|
||||
"cmods.cmods.ModMenuConfig"
|
||||
]
|
||||
"client": ["cmods.cmods.client.CmodsClient"],
|
||||
"modmenu": ["cmods.cmods.client.ModMenuConfig"]
|
||||
},
|
||||
"mixins": [
|
||||
{
|
||||
"config": "cmods.client.mixins.json",
|
||||
"environment": "client"
|
||||
}
|
||||
"cmods.mixins.json"
|
||||
],
|
||||
"depends": {
|
||||
"fabricloader": ">=0.14.10",
|
||||
"minecraft": "1.21.3",
|
||||
"java": ">=21",
|
||||
"fabric-api": "*"
|
||||
"fabricloader": ">=0.14.11",
|
||||
"fabric": "*",
|
||||
"minecraft": "1.19.3"
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user