diff --git a/build.gradle b/build.gradle index cece3da..a414838 100644 --- a/build.gradle +++ b/build.gradle @@ -1,35 +1,24 @@ plugins { - id 'eclipse' + id 'java-library' + id 'eclipse' id 'idea' id 'maven-publish' - id 'net.minecraftforge.gradle' version '[6.0.24,6.2)' - id 'org.parchmentmc.librarian.forgegradle' version '1.+' - id 'org.spongepowered.mixin' version '0.7.+' + id 'net.neoforged.gradle.userdev' version '7.0.145' id "me.modmuss50.mod-publish-plugin" version "0.7.4" id "com.modrinth.minotaur" version "2.+" } apply from: "main.gradle" -apply plugin: 'net.minecraftforge.gradle' -// Only edit below this line, the above code adds and enables the necessary things for Forge to be setup. -apply plugin: 'eclipse' -apply plugin: 'maven-publish' -apply plugin: 'org.parchmentmc.librarian.forgegradle' -apply plugin: 'org.spongepowered.mixin' // Should exist on all loaders and is loader specific repositories { maven {url "https://modmaven.dev/" }// UnionLib - maven {url "https://girafi.dk/maven/"} maven {url "https://www.cursemaven.com"} //CurseForge maven {url = "https://repo.spongepowered.org/maven"} // mixin + maven {url "https://girafi.dk/maven/"} } dependencies { - minecraft "net.minecraftforge:forge:${_minecraft_version}-" + _loader_version - annotationProcessor "org.spongepowered:mixin:"+modMixinVersion+":processor" - implementation('net.sf.jopt-simple:jopt-simple:5.0.4') { version { strictly '5.0.4' } } + implementation ("net.neoforged:neoforge:${_loader_version}") implementation ("com.stereowalker.unionlib:UnionLib:${_minecraft_version}-${_unionlib_version}-${_loader}") } - -// These aren't loader specific and should exist on all loaders \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 9b3c886..eb07130 100644 --- a/gradle.properties +++ b/gradle.properties @@ -15,11 +15,11 @@ _modrinth_id = x _minecraft_version = 1.21.1 _minecraft_version_min = 1.21 _minecraft_version_max = 1.22 -_loader = Forge -_loader_file = META-INF/mods.toml -_loader_version = 52.0.1 -_loader_version_min = 51 -_loader_version_max = 53 +_loader = NeoForge +_loader_file = META-INF/neoforge.mods.toml +_loader_version = 21.1.1 +_loader_version_min = 4 +_loader_version_max = 5 _unionlib_version = 12.0.7 _unionlib_version_min = 12.0.3 _unionlib_version_max = 12.1.0 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index c1962a7..2c35211 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index bb6c191..09523c0 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew old mode 100755 new mode 100644 index aeb74cb..f5feea6 --- a/gradlew +++ b/gradlew @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -83,7 +85,9 @@ done # This is normally unused # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s +' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -130,10 +134,13 @@ location of your Java installation." fi else JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. @@ -141,7 +148,7 @@ 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 + # shellcheck disable=SC2039,SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac @@ -149,7 +156,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then '' | soft) :;; #( *) # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -198,11 +205,11 @@ fi # 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"' -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ diff --git a/gradlew.bat b/gradlew.bat index 93e3f59..9d21a21 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -43,11 +45,11 @@ set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 if %ERRORLEVEL% equ 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. +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -57,11 +59,11 @@ 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. +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail diff --git a/neoforge.gradle b/neoforge.gradle new file mode 100644 index 0000000..8232a12 --- /dev/null +++ b/neoforge.gradle @@ -0,0 +1,51 @@ +project.ext._mod_jar = jar + +java.toolchain.languageVersion = JavaLanguageVersion.of(21) + +tasks.named('wrapper', Wrapper).configure { + distributionType = Wrapper.DistributionType.BIN +} + +minecraft { + accessTransformers { + file('src/main/resources/META-INF/accesstransformer.cfg') + } +} + +runs { + configureEach { + systemProperty 'forge.logging.markers', 'REGISTRIES' + systemProperty 'forge.logging.console.level', 'debug' + modSource project.sourceSets.main + } + client { + systemProperty 'forge.enabledGameTestNamespaces', project._mod_id + workingDirectory project.file("run/${project._loader}-Client") + } + server { + systemProperty 'forge.enabledGameTestNamespaces', project._mod_id + workingDirectory project.file("run/${project._loader}-Server") + //programArgument '--nogui' + } +} + +sourceSets.main.resources { srcDir 'src/generated/resources' } + +configurations { + runtimeClasspath.extendsFrom localRuntime +} + +// Example for how to get properties into the manifest for reading by the runtime.. +jar { + manifest { + attributes([ + "Specification-Title": _mod_name, + "Specification-Vendor": "Stereowalker", + "Specification-Version": "1", // We are version 1 of ourselves + "Implementation-Title": project.name, + "Implementation-Version": "${version}", + "Implementation-Vendor" :"Stereowalker", + "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") + ]) + } +} diff --git a/settings.gradle b/settings.gradle index 392fcba..7e04eb0 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,8 +1,7 @@ pluginManagement { repositories { gradlePluginPortal() - maven { url = 'https://maven.minecraftforge.net/' } - maven { url = 'https://repo.spongepowered.org/repository/maven-public/' } + maven { url = 'https://maven.neoforged.net/releases' } maven { url = 'https://maven.parchmentmc.org' } } resolutionStrategy { @@ -18,5 +17,5 @@ pluginManagement { } plugins { - id 'org.gradle.toolchains.foojay-resolver-convention' version '0.7.0' + id 'org.gradle.toolchains.foojay-resolver-convention' version '0.8.0' } \ No newline at end of file diff --git a/src/main/java/net/rpgz/forge/RegistryEvents.java b/src/main/java/net/rpgz/forge/RegistryEvents.java index 1175684..068f777 100644 --- a/src/main/java/net/rpgz/forge/RegistryEvents.java +++ b/src/main/java/net/rpgz/forge/RegistryEvents.java @@ -1,17 +1,18 @@ package net.rpgz.forge; -import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.registries.ForgeRegistries; -import net.minecraftforge.registries.RegisterEvent; +import net.minecraft.core.registries.Registries; +import net.neoforged.bus.api.SubscribeEvent; +import net.neoforged.fml.common.EventBusSubscriber; +import net.neoforged.fml.common.EventBusSubscriber.Bus; +import net.neoforged.neoforge.registries.RegisterEvent; import net.rpgz.init.SoundInit; -@Mod.EventBusSubscriber(bus=Mod.EventBusSubscriber.Bus.MOD, modid = Rpgz.MOD_ID) +@EventBusSubscriber(bus=Bus.MOD, modid = Rpgz.MOD_ID) public class RegistryEvents { @SubscribeEvent public static void registerSoundEvents(final RegisterEvent event) { - event.register(ForgeRegistries.Keys.SOUND_EVENTS, + event.register(Registries.SOUND_EVENT, helper -> { SoundInit.registerAll(helper); }); diff --git a/src/main/java/net/rpgz/forge/Rpgz.java b/src/main/java/net/rpgz/forge/Rpgz.java index 830a0f7..0a97557 100644 --- a/src/main/java/net/rpgz/forge/Rpgz.java +++ b/src/main/java/net/rpgz/forge/Rpgz.java @@ -9,12 +9,10 @@ import com.stereowalker.unionlib.util.VersionHelper; import net.minecraft.resources.ResourceLocation; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.eventbus.api.IEventBus; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; -import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; -import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; +import net.neoforged.fml.common.Mod; +import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent; +import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent; +import net.neoforged.neoforge.common.NeoForge; import net.rpgz.RpgzClientSegment; import net.rpgz.init.ConfigInit; import net.rpgz.init.TagInit; @@ -52,11 +50,10 @@ public Rpgz() { super("rpgz", () -> new RpgzClientSegment(), () -> new ServerSegment()); instance = this; - final IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); TagInit.init(); - modEventBus.addListener(this::setup); - modEventBus.addListener(this::clientSetup); - MinecraftForge.EVENT_BUS.register(this); + eventBus().addListener(this::setup); + eventBus().addListener(this::clientSetup); +// NeoForge.EVENT_BUS.register(this); // NetRegistry.registerMessages(); } diff --git a/src/main/java/net/rpgz/init/SoundInit.java b/src/main/java/net/rpgz/init/SoundInit.java index 8bd1839..bea3702 100644 --- a/src/main/java/net/rpgz/init/SoundInit.java +++ b/src/main/java/net/rpgz/init/SoundInit.java @@ -4,7 +4,7 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.sounds.SoundEvent; -import net.minecraftforge.registries.RegisterEvent.RegisterHelper; +import net.neoforged.neoforge.registries.RegisterEvent.RegisterHelper; public class SoundInit { diff --git a/src/main/java/net/rpgz/mixin/ClientWorldMixin.java b/src/main/java/net/rpgz/mixin/ClientWorldMixin.java index f232a92..6baaa71 100644 --- a/src/main/java/net/rpgz/mixin/ClientWorldMixin.java +++ b/src/main/java/net/rpgz/mixin/ClientWorldMixin.java @@ -7,8 +7,8 @@ import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Mob; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.api.distmarker.OnlyIn; @Mixin(ClientLevel.class) @OnlyIn(Dist.CLIENT) diff --git a/src/main/java/net/rpgz/mixin/EntityRendererMixin.java b/src/main/java/net/rpgz/mixin/EntityRendererMixin.java index f4fa4ba..1ff031e 100644 --- a/src/main/java/net/rpgz/mixin/EntityRendererMixin.java +++ b/src/main/java/net/rpgz/mixin/EntityRendererMixin.java @@ -12,8 +12,8 @@ import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Mob; import net.minecraft.world.phys.AABB; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.api.distmarker.OnlyIn; @OnlyIn(Dist.CLIENT) @Mixin(EntityRenderer.class) diff --git a/src/main/java/net/rpgz/mixin/GameRendererMixin.java b/src/main/java/net/rpgz/mixin/GameRendererMixin.java index 542595c..d22a39a 100644 --- a/src/main/java/net/rpgz/mixin/GameRendererMixin.java +++ b/src/main/java/net/rpgz/mixin/GameRendererMixin.java @@ -18,8 +18,8 @@ import net.minecraft.world.phys.EntityHitResult; import net.minecraft.world.phys.HitResult; import net.minecraft.world.phys.Vec3; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.api.distmarker.OnlyIn; @Mixin(GameRenderer.class) @OnlyIn(Dist.CLIENT) diff --git a/src/main/java/net/rpgz/mixin/InGameHudMixin.java b/src/main/java/net/rpgz/mixin/InGameHudMixin.java index 154389f..4e1966a 100644 --- a/src/main/java/net/rpgz/mixin/InGameHudMixin.java +++ b/src/main/java/net/rpgz/mixin/InGameHudMixin.java @@ -8,20 +8,18 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import com.mojang.blaze3d.systems.RenderSystem; import com.stereowalker.unionlib.util.VersionHelper; import net.minecraft.client.DeltaTracker; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.GuiGraphics; -import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Mob; import net.minecraft.world.phys.EntityHitResult; import net.minecraft.world.phys.HitResult; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.api.distmarker.OnlyIn; @OnlyIn(Dist.CLIENT) @Mixin(Gui.class) diff --git a/src/main/java/net/rpgz/mixin/LivingEntityRendererMixin.java b/src/main/java/net/rpgz/mixin/LivingEntityRendererMixin.java index 9c6c19e..5428605 100644 --- a/src/main/java/net/rpgz/mixin/LivingEntityRendererMixin.java +++ b/src/main/java/net/rpgz/mixin/LivingEntityRendererMixin.java @@ -22,8 +22,8 @@ import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.Mob; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.api.distmarker.OnlyIn; @OnlyIn(Dist.CLIENT) @Mixin(LivingEntityRenderer.class) diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/neoforge.mods.toml similarity index 80% rename from src/main/resources/META-INF/mods.toml rename to src/main/resources/META-INF/neoforge.mods.toml index 3ef1db1..35a7e27 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/neoforge.mods.toml @@ -2,7 +2,7 @@ modLoader="javafml" loaderVersion="[${loader_version_min},${loader_version_max})" license="${mod_license}" issueTrackerURL="${mod_issue_tracker}" -logoFile="icon.png" +logoFile="pack.png" [[mods]] modId="${mod_id}" version="${mod_version}" @@ -12,10 +12,14 @@ displayURL="${mod_page}" credits="I'd like to thank all my supporters on Patreon for giving me a reason to continue modding, and you for downloading and playing with this mod" authors="${mod_authors}" description='''${mod_description}''' +[[mixins]] +config="${mod_id}.mixins.json" +[[accessTransformers]] +file="META-INF/accesstransformer.cfg" [[dependencies.${mod_id}]] #optional - modId="forge" #mandatory + modId="neoforge" #mandatory mandatory=true #mandatory - versionRange="[50,)" #mandatory + versionRange="[21.0.0-beta,)" #mandatory ordering="NONE" side="BOTH" [[dependencies.${mod_id}]] @@ -29,4 +33,4 @@ description='''${mod_description}''' mandatory=true versionRange="[${unionlib_version_min},${unionlib_version_max})" ordering="BEFORE" - side="BOTH" + side="BOTH" \ No newline at end of file