diff --git a/build.gradle b/build.gradle index 1faecea5..76e819ce 100644 --- a/build.gradle +++ b/build.gradle @@ -1,70 +1,77 @@ plugins { - id 'fabric-loom' version '0.12-SNAPSHOT' - id 'maven-publish' + id "dev.architectury.loom" version "0.12.0-SNAPSHOT" + id "maven-publish" } -sourceCompatibility = JavaVersion.VERSION_17 -targetCompatibility = JavaVersion.VERSION_17 +sourceCompatibility = targetCompatibility = JavaVersion.VERSION_17 archivesBaseName = project.archives_base_name 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. +loom { + forge { + mixinConfigs = [ + "fastload.mixins.json" + ] + } + + launches { + data { + arg "--existing", file("src/main/resources").absolutePath + } + } } -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}" +repositories {} +dependencies { + minecraft "com.mojang:minecraft:${project.minecraft_version}" + mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" + forge "net.minecraftforge:forge:${project.forge_version}" } processResources { - inputs.property "version", project.version - - filesMatching("fabric.mod.json") { - expand "version": project.version - } + inputs.property "version", project.version + filesMatching("META-INF/mods.toml") { + expand "version": project.version + } } -tasks.withType(JavaCompile).configureEach { - // Minecraft 1.18 (1.18-pre2) upwards uses Java 17. - it.options.release = 17 +tasks.withType(JavaCompile) { + options.encoding = "UTF-8" + options.release = 17 } -java { - // 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() -} +//java { + //withSourcesJar() +//} jar { - from("LICENSE") { - rename { "${it}_${project.archivesBaseName}"} - } + manifest { + attributes([ + "Specification-Title" : project.mod_id, + "Specification-Vendor" : project.mod_author, + "Specification-Version" : "1", + "Implementation-Title" : project.name, + "Implementation-Version" : version, + "Implementation-Vendor" : project.mod_author, + "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") + ]) + } } -// configure the maven publication publishing { - publications { - mavenJava(MavenPublication) { - from components.java - } - } + publications { + mavenJava(MavenPublication) { + artifact(remapJar) { + builtBy remapJar + } + //artifact(sourcesJar) { + // builtBy remapSourcesJar + //} + } + } - // 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. - } + repositories {} } diff --git a/gradle.properties b/gradle.properties index 52bc3551..6efde0da 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,12 +1,13 @@ -# Done to increase the memory available to gradle. org.gradle.jvmargs=-Xmx1G +loom.platform=forge -# Fabric Properties - minecraft_version=1.19 - yarn_mappings=1.19+build.2 - loader_version=0.14.7 + minecraft_version=1.18.2 + forge_version=1.18.2-40.1.31 + yarn_mappings=1.18.2+build.3 -# Mod Properties - mod_version = 1.0.6+1.19 - maven_group = io.github.bumblesoftware.fastload - archives_base_name = Fastload + + mod_version=1.0.6+1.18.2 + maven_group=com.abdelaziz333.fastload + archives_base_name=Fastload-Reforged + mod_id=fastload + mod_author=AbdElAziz333 diff --git a/gradlew b/gradlew index c53aefaa..1b6c7873 100644 --- a/gradlew +++ b/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015-2021 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -32,10 +32,10 @@ # Busybox and similar reduced shells will NOT work, because this script # requires all of these POSIX shell features: # * functions; -# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», -# «${var#prefix}», «${var%suffix}», and «$( cmd )»; -# * compound commands having a testable exit status, especially «case»; -# * various built-in commands including «command», «set», and «ulimit». +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». # # Important for patching: # diff --git a/gradlew.bat b/gradlew.bat index 107acd32..ac1b06f9 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,89 +1,89 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="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 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="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 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/settings.gradle b/settings.gradle index b02216ba..c3bd64d0 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,10 +1,8 @@ pluginManagement { repositories { - maven { - name = 'Fabric' - url = 'https://maven.fabricmc.net/' - } - mavenCentral() + maven { url "https://maven.fabricmc.net/" } + maven { url "https://maven.architectury.dev/" } + maven { url "https://files.minecraftforge.net/maven/" } gradlePluginPortal() } } diff --git a/src/main/java/com/abdelaziz333/fastload/FastLoad.java b/src/main/java/com/abdelaziz333/fastload/FastLoad.java new file mode 100644 index 00000000..91ca621a --- /dev/null +++ b/src/main/java/com/abdelaziz333/fastload/FastLoad.java @@ -0,0 +1,10 @@ +package com.abdelaziz333.fastload; + +import net.minecraftforge.fml.common.Mod; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@Mod("fastload") +public class FastLoad { + public static final Logger LOGGER = LoggerFactory.getLogger("Fastload"); +} \ No newline at end of file diff --git a/src/main/java/com/abdelaziz333/fastload/mixin/DownloadingTerrainScreenMixin.java b/src/main/java/com/abdelaziz333/fastload/mixin/DownloadingTerrainScreenMixin.java new file mode 100644 index 00000000..b9a5852b --- /dev/null +++ b/src/main/java/com/abdelaziz333/fastload/mixin/DownloadingTerrainScreenMixin.java @@ -0,0 +1,23 @@ +package com.abdelaziz333.fastload.mixin; + +import net.minecraft.client.gui.screen.DownloadingTerrainScreen; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + + +@Mixin(DownloadingTerrainScreen.class) +public class DownloadingTerrainScreenMixin { + + //Code is from 'kennytv'. All credits are to this person. This is not our code. + //Permission granted to do so from MIT License of 'forcecloseloadingscreen'. + + @Shadow private boolean closeOnNextTick; + + @Inject(at = @At("HEAD"), method = "setReady") + public void tick(final CallbackInfo ci) { + this.closeOnNextTick = true; + } +} diff --git a/src/main/java/com/abdelaziz333/fastload/mixin/MinecraftClientMixin.java b/src/main/java/com/abdelaziz333/fastload/mixin/MinecraftClientMixin.java new file mode 100644 index 00000000..a06c0948 --- /dev/null +++ b/src/main/java/com/abdelaziz333/fastload/mixin/MinecraftClientMixin.java @@ -0,0 +1,59 @@ +package com.abdelaziz333.fastload.mixin; + +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.screen.DownloadingTerrainScreen; +import net.minecraft.client.gui.screen.Screen; +import org.jetbrains.annotations.Nullable; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(MinecraftClient.class) +public abstract class MinecraftClientMixin { + //Original code is from 'kennytv, forceloadingscreen'. Code is modified to our needs. + @Shadow + public void setScreen(@Nullable Screen screen) {} + @Inject(method = "setScreen", at = @At("HEAD"), cancellable = true) + private void setScreen(final Screen screen, final CallbackInfo ci) { + if (screen instanceof DownloadingTerrainScreen) { + render(true); + ci.cancel(); + setScreen(null); + justLoaded = true; + } + } + + @Shadow + private void render(boolean tick) {} + @Inject(method = "startIntegratedServer*", at = @At("HEAD")) + private void renderOnStartServer(CallbackInfo ci) { + render(true); + } + + @Shadow + public boolean skipGameRender; + + @Shadow private boolean windowFocused; + + @Inject(method = "render", at = @At("HEAD")) + private void setSkipGameRender(boolean tick, CallbackInfo ci) { + skipGameRender = false; + } + + private boolean justLoaded; + + @Shadow private volatile boolean running; + + @Inject(method = "openPauseMenu", at = @At("HEAD"), cancellable = true) + private void cancelOpenPauseMenu(boolean pause, CallbackInfo ci) { + if (windowFocused && justLoaded) { + justLoaded = false; + } + else if (!windowFocused && running && justLoaded) { + ci.cancel(); + justLoaded = false; + } + } +} diff --git a/src/main/java/com/abdelaziz333/fastload/mixin/MinecraftServerMixin.java b/src/main/java/com/abdelaziz333/fastload/mixin/MinecraftServerMixin.java new file mode 100644 index 00000000..d271bd9e --- /dev/null +++ b/src/main/java/com/abdelaziz333/fastload/mixin/MinecraftServerMixin.java @@ -0,0 +1,21 @@ +package com.abdelaziz333.fastload.mixin; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.Constant; +import org.spongepowered.asm.mixin.injection.ModifyConstant; + +import net.minecraft.server.MinecraftServer; + + +/* +* This code is inspired by: https://github.com/VidTu/Ksyxis of which it's under the MIT License. +* The BumbleSoftware team modified the code to make this possible. +*/ + +@Mixin(MinecraftServer.class) +public class MinecraftServerMixin { + @ModifyConstant(method = "prepareStartRegion", constant = @Constant(intValue = 441)) + public int onPrepareRedirectChunksLoaded(int value) { + return 49; + } +} diff --git a/src/main/java/com/abdelaziz333/fastload/mixin/WorldGenerationProcessLoggerMixin.java b/src/main/java/com/abdelaziz333/fastload/mixin/WorldGenerationProcessLoggerMixin.java new file mode 100644 index 00000000..018e18ac --- /dev/null +++ b/src/main/java/com/abdelaziz333/fastload/mixin/WorldGenerationProcessLoggerMixin.java @@ -0,0 +1,14 @@ +package com.abdelaziz333.fastload.mixin; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.*; + +import net.minecraft.server.WorldGenerationProgressLogger; + +@Mixin(WorldGenerationProgressLogger.class) +public class WorldGenerationProcessLoggerMixin { + @ModifyVariable(method = "", at = @At("HEAD"), argsOnly = true) + private static int injected(int radius){ + return 3; + } +} diff --git a/src/main/java/com/abdelaziz333/fastload/mixin/WorldGenerationProgressTrackerMixin.java b/src/main/java/com/abdelaziz333/fastload/mixin/WorldGenerationProgressTrackerMixin.java new file mode 100644 index 00000000..c42a8f41 --- /dev/null +++ b/src/main/java/com/abdelaziz333/fastload/mixin/WorldGenerationProgressTrackerMixin.java @@ -0,0 +1,12 @@ +package com.abdelaziz333.fastload.mixin; + +import net.minecraft.client.gui.WorldGenerationProgressTracker; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.ModifyVariable; + +@Mixin(WorldGenerationProgressTracker.class) +public class WorldGenerationProgressTrackerMixin { + @ModifyVariable(method = "", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/WorldGenerationProgressLogger;(I)V"), argsOnly = true) + public int getRadius(int radius) {return 3;} +} diff --git a/src/main/java/io/github/bumblesoftware/fastload/FastLoad.java b/src/main/java/io/github/bumblesoftware/fastload/FastLoad.java deleted file mode 100644 index 7ed5e2fe..00000000 --- a/src/main/java/io/github/bumblesoftware/fastload/FastLoad.java +++ /dev/null @@ -1,20 +0,0 @@ -package io.github.bumblesoftware.fastload; - -import net.fabricmc.api.ModInitializer; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class FastLoad implements ModInitializer { - // This logger is used to write text to the console and the log file. - // It is considered best practice to use your mod id as the logger's name. - // That way, it's clear which mod wrote info, warnings, and errors. - public static final Logger LOGGER = LoggerFactory.getLogger("Fastload"); - - @Override - public void onInitialize() { - // This code runs as soon as Minecraft is in a mod-load-ready state. - // However, some things (like resources) may still be uninitialized. - // Proceed with mild caution. - LOGGER.warn("Fastload may cause issues, report them to us instead of other mod authors"); - } -} diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg new file mode 100644 index 00000000..e69de29b diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml new file mode 100644 index 00000000..d7815a00 --- /dev/null +++ b/src/main/resources/META-INF/mods.toml @@ -0,0 +1,32 @@ +modLoader = "javafml" +loaderVersion = "[40,)" +license = "All rights reserved" + +#issueTrackerURL="https://github.com/BumbleSoftware/Fastload/issues" + +[[mods]] +modId = "fastload" +version = "${version}" +displayName = "Fastload" +#updateJSONURL="https://changeme.dev/updates.json" +#displayURL="https://changeme.dev/" +logoFile="icon.png" +credits="" +authors="AbdElAziz333, FluffyBumblebees, JoostMSoftware, VidTu, kennytv" +description = ''' +Fastload is a simple performance mod that reduces world loading time. +''' + +[[dependencies.fastload]] +modId = "forge" +mandatory = true +versionRange = "[40,)" +ordering = "NONE" +side = "BOTH" + +[[dependencies.fastload]] +modId = "minecraft" +mandatory = true +versionRange = "[1.18.2,)" +ordering = "NONE" +side = "BOTH" diff --git a/src/main/resources/fastload.mixins.json b/src/main/resources/fastload.mixins.json index ba266255..bf3e8695 100644 --- a/src/main/resources/fastload.mixins.json +++ b/src/main/resources/fastload.mixins.json @@ -1,7 +1,7 @@ { "required": true, "minVersion": "0.8", - "package": "io.github.bumblesoftware.fastload.mixin", + "package": "com.abdelaziz333.fastload.mixin", "compatibilityLevel": "JAVA_17", "mixins": [ "DownloadingTerrainScreenMixin", diff --git a/src/main/resources/icon.png b/src/main/resources/icon.png new file mode 100644 index 00000000..0eb8c89d Binary files /dev/null and b/src/main/resources/icon.png differ diff --git a/src/main/resources/pack.mcmeta b/src/main/resources/pack.mcmeta new file mode 100644 index 00000000..0e50ecd7 --- /dev/null +++ b/src/main/resources/pack.mcmeta @@ -0,0 +1,7 @@ +{ + "pack": { + "description": "", + "pack_format": 8, + "_comment": "" + } +}