Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
551c74ad13 | |||
371f5effad | |||
563ac4a06e | |||
21c32388a6 | |||
8e30d8c2ee | |||
8369034f10 | |||
d2ef12f718 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,5 +1,6 @@
|
||||
# User-specific stuff
|
||||
.idea/
|
||||
remappedSrc/
|
||||
|
||||
*.iml
|
||||
*.ipr
|
||||
|
129
build.gradle
129
build.gradle
@ -1,11 +1,15 @@
|
||||
plugins {
|
||||
id 'fabric-loom' version '1.1-SNAPSHOT'
|
||||
id 'fabric-loom' version '1.7-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
|
||||
@ -18,6 +22,17 @@ 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}"
|
||||
@ -31,47 +46,37 @@ 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 {
|
||||
// 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
|
||||
}
|
||||
it.options.release = 21
|
||||
}
|
||||
|
||||
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.archivesBaseName}" }
|
||||
rename { "${it}_${project.base.archivesName.get()}"}
|
||||
}
|
||||
}
|
||||
|
||||
// configure the maven publication
|
||||
publishing {
|
||||
publications {
|
||||
mavenJava(MavenPublication) {
|
||||
create("mavenJava", MavenPublication) {
|
||||
artifactId = project.archives_base_name
|
||||
from components.java
|
||||
}
|
||||
}
|
||||
@ -84,3 +89,91 @@ 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,14 +1,15 @@
|
||||
# Done to increase the memory available to gradle.
|
||||
org.gradle.jvmargs=-Xmx1G
|
||||
org.gradle.jvmargs=-Xmx4G
|
||||
org.gradle.parallel=true
|
||||
# Fabric Properties
|
||||
# check these on https://modmuss50.me/fabric.html
|
||||
minecraft_version=1.19.3
|
||||
yarn_mappings=1.19.3+build.5
|
||||
loader_version=0.14.13
|
||||
minecraft_version=1.21.3
|
||||
yarn_mappings=1.21.3+build.2
|
||||
loader_version=0.16.7
|
||||
# Mod Properties
|
||||
mod_version=1.0.0
|
||||
mod_version=1.2.3
|
||||
maven_group=cmods
|
||||
archives_base_name=cmods
|
||||
# Dependencies
|
||||
# check this on https://modmuss50.me/fabric.html
|
||||
fabric_version=0.73.0+1.19.3
|
||||
fabric_version=0.107.0+1.21.3
|
||||
|
3
gradle/wrapper/gradle-wrapper.properties
vendored
3
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,5 +1,6 @@
|
||||
#Sun Jun 30 01:31:47 MDT 2024
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
@ -1,4 +1,4 @@
|
||||
package cmods.cmods.client;
|
||||
package cmods.cmods;
|
||||
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
import net.fabricmc.api.EnvType;
|
@ -1,10 +1,11 @@
|
||||
package cmods.cmods.client;
|
||||
package cmods.cmods;
|
||||
|
||||
import cmods.cmods.client.ui.CmodsOptionsScreen;
|
||||
import cmods.cmods.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,6 +1,6 @@
|
||||
package cmods.cmods.api;
|
||||
|
||||
import cmods.cmods.client.ui.Line;
|
||||
import cmods.cmods.ui.Line;
|
||||
import net.minecraft.util.Pair;
|
||||
|
||||
import java.util.ArrayList;
|
@ -1,9 +1,9 @@
|
||||
package cmods.cmods.api;
|
||||
|
||||
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 cmods.cmods.options.CmodsOptions;
|
||||
import cmods.cmods.ui.CmodsOptionsScreen;
|
||||
import cmods.cmods.ui.Line;
|
||||
import cmods.cmods.ui.UIOptionsScreen;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
18
src/client/java/cmods/cmods/api/PropertyUtils.java
Normal file
18
src/client/java/cmods/cmods/api/PropertyUtils.java
Normal file
@ -0,0 +1,18 @@
|
||||
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,13 +1,14 @@
|
||||
package cmods.cmods.mixin;
|
||||
|
||||
import cmods.cmods.client.options.CmodsOptions;
|
||||
import cmods.cmods.api.HudRenderCallback;
|
||||
import cmods.cmods.client.ui.Line;
|
||||
import cmods.cmods.options.CmodsOptions;
|
||||
import cmods.cmods.ui.Line;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
import net.minecraft.client.gui.DrawableHelper;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.hud.DebugHud;
|
||||
import net.minecraft.client.gui.hud.InGameHud;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.client.render.RenderTickCounter;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Pair;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@ -22,17 +23,19 @@ import java.util.ArrayList;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@Mixin(InGameHud.class)
|
||||
public abstract class HudMixin extends DrawableHelper {
|
||||
public abstract class HudMixin {
|
||||
|
||||
@Shadow @Final private MinecraftClient client;
|
||||
@Shadow public abstract TextRenderer getTextRenderer();
|
||||
|
||||
|
||||
@Shadow @Final private DebugHud debugHud;
|
||||
|
||||
@Inject(at = @At("TAIL"), method = "render")
|
||||
private void render(MatrixStack matrices, float tickDelta, CallbackInfo ci) {
|
||||
private void render(DrawContext context, RenderTickCounter tickCounter, CallbackInfo ci) {
|
||||
CmodsOptions options = CmodsOptions.getInstance();
|
||||
|
||||
if (this.client.options.debugEnabled || this.client.isPaused() || client.player == null ||
|
||||
if (this.debugHud.shouldShowDebugHud() || this.client.isPaused() || client.player == null ||
|
||||
!options.uiOptions.enabled.get()) {
|
||||
return;
|
||||
}
|
||||
@ -52,6 +55,12 @@ public abstract class HudMixin extends DrawableHelper {
|
||||
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);
|
||||
}
|
||||
@ -66,8 +75,7 @@ public abstract class HudMixin extends DrawableHelper {
|
||||
y += 2;
|
||||
}
|
||||
|
||||
DrawableHelper.drawTextWithShadow(matrices, textRenderer, line.text(), x + (5 * line.indent()), y,
|
||||
line.color());
|
||||
context.drawTextWithShadow(textRenderer, line.text(), x + (5 * line.indent()), y, line.color());
|
||||
y += textRenderer.fontHeight;
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package cmods.cmods.mixin;
|
||||
|
||||
import cmods.cmods.client.ui.CmodsOptionsScreen;
|
||||
import cmods.cmods.options.CmodsOptions;
|
||||
import cmods.cmods.ui.CmodsOptionsScreen;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.screen.option.OptionsScreen;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
@ -19,7 +20,7 @@ public class OptionsMixin extends Screen {
|
||||
|
||||
@Inject(at = @At("TAIL"), method = "init")
|
||||
private void init(CallbackInfo ci) {
|
||||
if (client == null)
|
||||
if (client == null || !CmodsOptions.getInstance().uiOptions.show_in_options.get())
|
||||
return;
|
||||
|
||||
addDrawableChild(ButtonWidget.builder(Text.translatable("cmods.options"),
|
@ -1,7 +1,8 @@
|
||||
package cmods.cmods.mixin;
|
||||
|
||||
|
||||
import cmods.cmods.client.ui.CmodsOptionsScreen;
|
||||
import cmods.cmods.options.CmodsOptions;
|
||||
import cmods.cmods.ui.CmodsOptionsScreen;
|
||||
import net.minecraft.client.gui.screen.GameMenuScreen;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
@ -20,7 +21,7 @@ public class PauseMixin extends Screen {
|
||||
|
||||
@Inject(at = @At("TAIL"), method = "init")
|
||||
public void init(CallbackInfo ci) {
|
||||
if (client == null)
|
||||
if (client == null || !CmodsOptions.getInstance().uiOptions.show_in_pause.get())
|
||||
return;
|
||||
|
||||
addDrawableChild(ButtonWidget.builder(Text.translatable("cmods.options"),
|
@ -1,10 +1,11 @@
|
||||
package cmods.cmods.client.options;
|
||||
package cmods.cmods.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.client.options;
|
||||
package cmods.cmods.options;
|
||||
|
||||
import cmods.cmods.api.ModuleOptions;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
@ -11,6 +11,8 @@ 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;
|
||||
|
||||
@ -82,31 +84,34 @@ 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", true);
|
||||
show_coordinates.value = getBooleanProperty(properties, PREFIX + "show_coordinates", true);
|
||||
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);
|
||||
}
|
||||
|
||||
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,5 +1,6 @@
|
||||
package cmods.cmods.client.options;
|
||||
package cmods.cmods.options;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class IntegerOption extends Option<Integer> {
|
||||
public IntegerOption(Integer default_value) {
|
||||
super(default_value);
|
@ -1,5 +1,6 @@
|
||||
package cmods.cmods.client.options;
|
||||
package cmods.cmods.options;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class Option<T> {
|
||||
public T value;
|
||||
|
@ -1,20 +1,20 @@
|
||||
package cmods.cmods.client.ui;
|
||||
package cmods.cmods.ui;
|
||||
|
||||
import cmods.cmods.api.ButtonBuilder;
|
||||
import cmods.cmods.client.CmodsClient;
|
||||
import cmods.cmods.client.options.CmodsOptions;
|
||||
import cmods.cmods.CmodsClient;
|
||||
import cmods.cmods.options.CmodsOptions;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
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.client.ui.Constants.*;
|
||||
import static cmods.cmods.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.recalculateDimensions();
|
||||
grid.refreshPositions();
|
||||
SimplePositioningWidget.setPos(grid, 0, startHeight, this.width, this.height, 0.5f, 0.0f);
|
||||
addDrawableChild(grid);
|
||||
grid.forEachChild(this::addDrawableChild);
|
||||
}
|
||||
|
||||
public static void addExtraButtons(ArrayList<ButtonBuilder> buttons, int precedence) {
|
||||
@ -67,15 +67,15 @@ public class CmodsOptionsScreen extends Screen {
|
||||
extraWidgets.add(newPair);
|
||||
}
|
||||
|
||||
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
|
||||
renderBackground(matrices);
|
||||
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
|
||||
// renderBackground(context, mouseX, mouseY, delta);
|
||||
super.render(context, mouseX, mouseY, delta);
|
||||
|
||||
Text versionText = Text.literal("v" + CmodsClient.version);
|
||||
|
||||
|
||||
drawCenteredText(matrices, textRenderer, title, this.width / 2, 15, 0xffffff);
|
||||
drawTextWithShadow(matrices, textRenderer, versionText, this.width - textRenderer.getWidth(versionText) - 2,
|
||||
context.drawCenteredTextWithShadow(textRenderer, title, this.width / 2, 15, 0xffffff);
|
||||
context.drawTextWithShadow(textRenderer, versionText, this.width - textRenderer.getWidth(versionText) - 2,
|
||||
this.height - textRenderer.fontHeight - 2, 0xffffff);
|
||||
super.render(matrices, mouseX, mouseY, delta);
|
||||
}
|
||||
|
||||
public void removed() {
|
@ -1,5 +1,6 @@
|
||||
package cmods.cmods.client.ui;
|
||||
package cmods.cmods.ui;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class Constants {
|
||||
public static final int buttonWidth = 150;
|
||||
public static final int buttonHeight = 20;
|
@ -1,17 +1,19 @@
|
||||
package cmods.cmods.client.ui;
|
||||
package cmods.cmods.ui;
|
||||
|
||||
import cmods.cmods.client.options.IntegerOption;
|
||||
import cmods.cmods.options.IntegerOption;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
import net.minecraft.client.gui.widget.ClickableWidget;
|
||||
import net.minecraft.client.gui.widget.Widget;
|
||||
import net.minecraft.client.gui.widget.WrapperWidget;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class IntegerAdjustWidget extends WrapperWidget {
|
||||
private final ArrayList<ButtonWidget> children;
|
||||
private final ArrayList<ButtonWidget> elements;
|
||||
private final IntegerOption option;
|
||||
private final Text text;
|
||||
private final int delta;
|
||||
|
||||
public IntegerAdjustWidget(Text text, IntegerOption option) {
|
||||
@ -19,25 +21,15 @@ public class IntegerAdjustWidget extends WrapperWidget {
|
||||
}
|
||||
|
||||
public IntegerAdjustWidget(Text text, IntegerOption option, int delta) {
|
||||
super(0, 0, 150, 20, text);
|
||||
super(0, 0, 150, 20);
|
||||
this.text = text;
|
||||
this.option = option;
|
||||
this.delta = delta;
|
||||
children = new ArrayList<>(3);
|
||||
elements = 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);
|
||||
@ -50,17 +42,11 @@ 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 = getMessage().getString() + ": ";
|
||||
final String labelStr = text.getString() + ": ";
|
||||
|
||||
children.clear();
|
||||
elements.clear();
|
||||
|
||||
ButtonWidget middle = ButtonWidget.builder(Text.literal(labelStr + option.get()), button -> {})
|
||||
.dimensions(getX() + button_width - 1, getY(),width - (button_width * 2) + 2, height).build();
|
||||
@ -73,8 +59,15 @@ 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();
|
||||
|
||||
children.add(sub);
|
||||
children.add(middle);
|
||||
children.add(add);
|
||||
elements.add(sub);
|
||||
elements.add(middle);
|
||||
elements.add(add);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forEachElement(Consumer<Widget> consumer) {
|
||||
for (Widget element: elements) {
|
||||
consumer.accept(element);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package cmods.cmods.client.ui;
|
||||
package cmods.cmods.ui;
|
||||
|
||||
import net.minecraft.text.Text;
|
||||
|
@ -1,8 +1,8 @@
|
||||
package cmods.cmods.client.ui;
|
||||
package cmods.cmods.ui;
|
||||
|
||||
import cmods.cmods.client.options.BooleanOption;
|
||||
import cmods.cmods.options.BooleanOption;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
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, ButtonWidget.DEFAULT_NARRATION_SUPPLIER);
|
||||
this(x, y, width, height, name, option, 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 renderButton(MatrixStack matrices, int mouseX, int mouseY, float delta) {
|
||||
public void renderWidget(DrawContext context, int mouseX, int mouseY, float delta) {
|
||||
updateText();
|
||||
super.renderButton(matrices, mouseX, mouseY, delta);
|
||||
super.renderWidget(context, mouseX, mouseY, delta);
|
||||
}
|
||||
}
|
@ -1,19 +1,19 @@
|
||||
package cmods.cmods.client.ui;
|
||||
package cmods.cmods.ui;
|
||||
|
||||
import cmods.cmods.api.ButtonBuilder;
|
||||
import cmods.cmods.client.options.CmodsOptions;
|
||||
import cmods.cmods.options.CmodsOptions;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
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.client.ui.Constants.*;
|
||||
import static cmods.cmods.ui.Constants.*;
|
||||
|
||||
public class UIOptionsScreen extends Screen {
|
||||
private final Screen parent;
|
||||
@ -42,6 +42,15 @@ 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));
|
||||
@ -51,9 +60,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.recalculateDimensions();
|
||||
grid.refreshPositions();
|
||||
SimplePositioningWidget.setPos(grid, 0, startHeight, this.width, this.height, 0.5f, 0.0f);
|
||||
addDrawableChild(grid);
|
||||
grid.forEachChild(this::addDrawableChild);
|
||||
}
|
||||
|
||||
public static void addButtons(ArrayList<ButtonBuilder> buttons, int precedence) {
|
||||
@ -69,10 +78,10 @@ public class UIOptionsScreen extends Screen {
|
||||
extraButtons.add(newPair);
|
||||
}
|
||||
|
||||
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 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 removed() {
|
@ -2,7 +2,7 @@
|
||||
"required": true,
|
||||
"minVersion": "0.8",
|
||||
"package": "cmods.cmods.mixin",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"compatibilityLevel": "JAVA_21",
|
||||
"mixins": [
|
||||
],
|
||||
"client": [
|
@ -10,5 +10,8 @@
|
||||
"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_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"
|
||||
}
|
@ -8,21 +8,29 @@
|
||||
"Cameron Reed"
|
||||
],
|
||||
"contact": {
|
||||
"repo": "https://gitea.cam123.dev/"
|
||||
"sources": "https://gitea.cam123.dev/"
|
||||
},
|
||||
"license": "MIT",
|
||||
"icon": "assets/cmods/icon.png",
|
||||
"environment": "client",
|
||||
"entrypoints": {
|
||||
"client": ["cmods.cmods.client.CmodsClient"],
|
||||
"modmenu": ["cmods.cmods.client.ModMenuConfig"]
|
||||
"client": [
|
||||
"cmods.cmods.CmodsClient"
|
||||
],
|
||||
"modmenu": [
|
||||
"cmods.cmods.ModMenuConfig"
|
||||
]
|
||||
},
|
||||
"mixins": [
|
||||
"cmods.mixins.json"
|
||||
{
|
||||
"config": "cmods.client.mixins.json",
|
||||
"environment": "client"
|
||||
}
|
||||
],
|
||||
"depends": {
|
||||
"fabricloader": ">=0.14.11",
|
||||
"fabric": "*",
|
||||
"minecraft": "1.19.3"
|
||||
"fabricloader": ">=0.14.10",
|
||||
"minecraft": "1.21.3",
|
||||
"java": ">=21",
|
||||
"fabric-api": "*"
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user