Skip to content

Commit

Permalink
Merge pull request #40 from Basicprogrammer10/update-mc-1.20.3
Browse files Browse the repository at this point in the history
Update MC 1.20.3
  • Loading branch information
connorslade authored Dec 30, 2023
2 parents bc4822b + 96beb28 commit 2b542b8
Show file tree
Hide file tree
Showing 36 changed files with 200 additions and 195 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# SigmaUtils ![build](https://github.com/Basicprogrammer10/SigmaUtils/actions/workflows/build.yml/badge.svg) ![GitHub release (latest SemVer including pre-releases)](https://img.shields.io/github/v/release/Basicprogrammer10/SigmaUtils?include_prereleases) ![GitHub all releases](https://img.shields.io/github/downloads/Basicprogrammer10/SigmaUtils/total)

Requires: <kbd>[Minecraft 1.20.2](https://minecraft.fandom.com/wiki/Java_Edition_1.20.2)</kbd> <kbd>[Fabric API](https://modrinth.com/mod/fabric-api/version/0.89.2+1.20.2)</kbd>
Requires: <kbd>[Minecraft 1.20.3](https://minecraft.wiki/w/Java_Edition_1.20.3)</kbd> <kbd>[Fabric API](https://modrinth.com/mod/fabric-api/version/0.91.1+1.20.3)</kbd>

SigmaUtils is a utility mod for Minecraft 1.20.2.
SigmaUtils is a utility mod for Minecraft 1.20.3.
It is made up of 'modules', which are discrete features that can be toggled and configured.
By default, SigmaUtils changes nothing about the game, except adding a button to the title screen to open the config
GUI.
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '0.12-SNAPSHOT'
id 'fabric-loom' version '1.4-SNAPSHOT'
id 'maven-publish'
}

Expand Down
12 changes: 6 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx1G
# Fabric Properties
minecraft_version=1.20.2
yarn_mappings=1.20.2+build.2
loader_version=0.14.22
minecraft_version=1.20.3
yarn_mappings=1.20.3+build.1
loader_version=0.15.3
# Mod Properties
mod_version=0.1.7-alpha
mod_version=0.1.8-alpha
maven_group=com.connorcode
archives_base_name=sigma-utils
# Dependencies
fabric_version=0.89.2+1.20.2
mod_menu_version=8.0.0
fabric_version=0.91.1+1.20.3
mod_menu_version=9.0.0
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
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.5-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
18 changes: 14 additions & 4 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand All @@ -80,10 +80,10 @@ do
esac
done

APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

APP_NAME="Gradle"
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
Expand Down Expand Up @@ -143,12 +143,16 @@ fi
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -205,6 +209,12 @@ set -- \
org.gradle.wrapper.GradleWrapperMain \
"$@"

# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi

# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
Expand Down
15 changes: 9 additions & 6 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
@rem limitations under the License.
@rem

@if "%DEBUG%" == "" @echo off
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
Expand All @@ -25,7 +25,8 @@
if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

Expand All @@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Expand Down Expand Up @@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar

:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
if %ERRORLEVEL% equ 0 goto mainEnd

:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%

:mainEnd
if "%OS%"=="Windows_NT" endlocal
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/com/connorcode/sigmautils/SigmaUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

@Environment(EnvType.CLIENT)
public class SigmaUtils implements ClientModInitializer {
public static final String VERSION = "0.1.6-alpha";
public static final String VERSION = "0.1.8-alpha";
public static final MinecraftClient client = MinecraftClient.getInstance();
public static final Logger logger = LogUtils.getLogger();

Expand Down Expand Up @@ -87,5 +87,7 @@ void onClientStop(GameLifecycle.ClientStoppingEvent event) throws IOException {
// TODO: Item translate module, mode for shields in offhands
// TODO: camera no clip - disable culling
// TODO: Entiry selector custom type
// TODO: Allow viewing / specifing resource pack uuids
// TODO: Hide icons with no relms

// TODO Document Hid, Meta, and Misc packages
10 changes: 5 additions & 5 deletions src/main/java/com/connorcode/sigmautils/commands/About.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
public class About implements Command {
public void register(CommandDispatcher<FabricClientCommandSource> dispatcher) {
dispatcher.register(ClientCommandManager.literal("util")
.then(ClientCommandManager.literal("about")
.executes(context -> {
var gameVersion = client.getGameVersion();
var fabricVersion = FabricLoader.getInstance()
.getModContainer("fabricloader")
.then(ClientCommandManager.literal("about")
.executes(context -> {
var gameVersion = client.getGameVersion();
var fabricVersion = FabricLoader.getInstance()
.getModContainer("fabricloader")
.orElseThrow()
.getMetadata()
.getVersion()
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/connorcode/sigmautils/commands/Dump.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ public class Dump implements Command {
public void register(CommandDispatcher<FabricClientCommandSource> dispatcher) {
if (!FabricLoader.getInstance().isDevelopmentEnvironment()) return;
dispatcher.register(ClientCommandManager.literal("util")
.then(ClientCommandManager.literal("dump")
.then(ClientCommandManager.argument("resource", string())
.suggests(((context, builder) -> suggestMatching(new String[]{
"packets",
.then(ClientCommandManager.literal("dump")
.then(ClientCommandManager.argument("resource", string())
.suggests(((context, builder) -> suggestMatching(new String[]{
"packets",
"docs"
}, builder)))
.executes(ctx -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ public class PlayerCommand implements Command {
@Override
public void register(CommandDispatcher<FabricClientCommandSource> dispatcher) {
dispatcher.register(ClientCommandManager.literal("util")
.then(ClientCommandManager.literal("player")
.then(ClientCommandManager.literal("attack")
.then(ClientCommandManager.literal("continuous").executes((arg) -> {
Player.player.addAction(new Player.AttackAction(Player.InteractTime.continuous()));
.then(ClientCommandManager.literal("player")
.then(ClientCommandManager.literal("attack")
.then(ClientCommandManager.literal("continuous").executes((arg) -> {
Player.player.addAction(new Player.AttackAction(Player.InteractTime.continuous()));
return 0;
})).then(ClientCommandManager.literal("once").executes((arg) -> {
Player.player.addAction(new Player.AttackAction(Player.InteractTime.once()));
Expand Down
23 changes: 14 additions & 9 deletions src/main/java/com/connorcode/sigmautils/commands/ResourcePack.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Objects;
import java.util.UUID;

import static com.connorcode.sigmautils.SigmaUtils.client;
import static com.mojang.brigadier.arguments.StringArgumentType.getString;
Expand All @@ -21,20 +22,25 @@ static int serverPackUninstall(CommandContext<FabricClientCommandSource> context
return 0;
}

int serverPackInstall(CommandContext<FabricClientCommandSource> context, boolean isHash) {
static int serverPackInstall(CommandContext<FabricClientCommandSource> context) {
String urlRaw = getString(context, "url");
String hash = isHash ? getString(context, "hash") : "";
UUID uuid = null;

try {
uuid = UUID.fromString(getString(context, "uuid"));
} catch (IllegalArgumentException ignored) {}

URL url;
try {
url = new URL(urlRaw);
} catch (MalformedURLException e) {
e.printStackTrace();
context.getSource()
.sendError(Text.of(String.format("Invalid url! (%s)", e.getMessage())));
context.getSource().sendError(Text.of(String.format("Invalid url! (%s)", e.getMessage())));
return 0;
}

Objects.requireNonNull(client.getServerResourcePackProvider()).download(url, hash, true);
var packs = client.getServerResourcePackProvider();
packs.addResourcePack(uuid == null ? UUID.randomUUID() : uuid, url, null);
return 0;
}

Expand All @@ -44,10 +50,9 @@ public void register(CommandDispatcher<FabricClientCommandSource> dispatcher) {
.then(ClientCommandManager.literal("resourcepack")
.then(ClientCommandManager.literal("server")
.then(ClientCommandManager.literal("install")
.then(ClientCommandManager.argument("url", string())
.executes(ctx -> serverPackInstall(ctx, false))
.then(ClientCommandManager.argument("hash", string())
.executes(ctx -> serverPackInstall(ctx, true)))))
.then(ClientCommandManager.argument("url", string())
.executes(ResourcePack::serverPackInstall)
.then(ClientCommandManager.argument("uuid", string()).executes(ResourcePack::serverPackInstall))))
.then(ClientCommandManager.literal("remove")
.executes(ResourcePack::serverPackUninstall)))));
}
Expand Down
15 changes: 11 additions & 4 deletions src/main/java/com/connorcode/sigmautils/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,17 @@ public static <T extends Module> boolean getEnabled(Class<T> moduleClass) {

public static void load() throws IOException {
if (!configFile.exists()) return;
NbtCompound nbt = Objects.requireNonNull(NbtIo.read(configFile)).getCompound("modules");
if (nbt == null) return;
var nbt = Objects.requireNonNull(NbtIo.read(configFile.toPath()));
var version = nbt.getString("version");
if (!version.equals("SigmaUtils " + VERSION)) {
logger.warn("Config version mismatch, backing up config");
var version_num = version.split(" ")[1].replace(" ", "-");
NbtIo.write(nbt, new File(directory.toFile(), String.format("config_backup_%s.nbt", version_num)).toPath());
}

var modules = nbt.getCompound("modules");
for (Module i : SigmaUtils.modules.values()) {
i.loadConfig(nbt.getCompound(i.id));
i.loadConfig(modules.getCompound(i.id));
if (i.enabled) i.enable();
}
}
Expand All @@ -79,6 +86,6 @@ public static void save() throws IOException {
configFile.getParentFile().mkdirs();
nbt.put("modules", modules);

NbtIo.write(nbt, configFile);
NbtIo.write(nbt, configFile.toPath());
}
}
Loading

0 comments on commit 2b542b8

Please sign in to comment.