Skip to content

NeoForge support (1.20.6, 1.21.1, 1.21.4) #4183

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: v3.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* [Where to go for questions and discussions](#where-to-go-for-questions-and-discussions)
* [Where to go to make donations](#where-to-go-to-make-donations)
# How to build
Dynmap 3.x+ uses Gradle v8.7 for building support for all platforms, with all resulting artifacts produced in the /targets directory. Due to Minecraft 1.18.x+ requirements, the developer's
Dynmap 3.x+ uses Gradle v8.12 for building support for all platforms, with all resulting artifacts produced in the /targets directory. Due to Minecraft 1.18.x+ requirements, the developer's
default JDK must be a JDK 21 version - older versions will still be compiled
to run on the default JDK for those platforms (JDK 8 for 1.16 and earlier, JDK 16 for 1.17.x, JDK 17 for 1.18 to 1.20.4, JDK 21 for 1.20.5+), and
common libraries are built using JDK 8.
Expand Down Expand Up @@ -48,6 +48,7 @@ The following target platforms are supported, and you can find them at the links
| ------------ | ------- | ---------- | ------ |
| Spigot/PaperMC | ≤1.21.4 | `Dynmap-<version>-spigot.jar` | [SpigotMC](https://www.spigotmc.org/resources/dynmap%C2%AE.274/) |
| Spigot/PaperMC | ≤1.21.4 | `Dynmap-<version>-spigot.jar` | [Modrinth](https://modrinth.com/plugin/dynmap/versions?l=paper&l=spigot) |
| NeoForge | 1.20.6 - 1.21.4 | `Dynmap-<version>-neoforge-<MC_VERSION>.jar` | [Curseforge](https://www.curseforge.com/minecraft/mc-mods/dynmapforge) |
| Forge | 1.12.2 - 1.20.6 | `Dynmap-<version>-forge-<MC_VERSION>.jar` | [Curseforge](https://www.curseforge.com/minecraft/mc-mods/dynmapforge) |
| Fabric | 1.14.4 - 1.21.4 | `Dynmap-<version>-fabric-<MC_VERSION>.jar` | [Curseforge](https://www.curseforge.com/minecraft/mc-mods/dynmapforge) |

Expand Down
2 changes: 1 addition & 1 deletion fabric-1.14.4/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.9-SNAPSHOT'
id 'fabric-loom' version '1.9.2'
}

apply plugin: 'eclipse'
Expand Down
2 changes: 1 addition & 1 deletion fabric-1.15.2/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.9-SNAPSHOT'
id 'fabric-loom' version '1.9.2'
}

archivesBaseName = "Dynmap"
Expand Down
2 changes: 1 addition & 1 deletion fabric-1.16.4/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.9-SNAPSHOT'
id 'fabric-loom' version '1.9.2'
}

archivesBaseName = "Dynmap"
Expand Down
2 changes: 1 addition & 1 deletion fabric-1.17.1/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.9-SNAPSHOT'
id 'fabric-loom' version '1.9.2'
}

archivesBaseName = "Dynmap"
Expand Down
2 changes: 1 addition & 1 deletion fabric-1.18.2/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

plugins {
id 'fabric-loom' version '1.9-SNAPSHOT'
id 'fabric-loom' version '1.9.2'
}

archivesBaseName = "Dynmap"
Expand Down
2 changes: 1 addition & 1 deletion fabric-1.19.4/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.9-SNAPSHOT'
id 'fabric-loom' version '1.9.2'
}

archivesBaseName = "Dynmap"
Expand Down
2 changes: 1 addition & 1 deletion fabric-1.20.6/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.9-SNAPSHOT'
id 'fabric-loom' version '1.9.2'
}

archivesBaseName = "Dynmap"
Expand Down
2 changes: 1 addition & 1 deletion fabric-1.21/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.9-SNAPSHOT'
id 'fabric-loom' version '1.9.2'
}

archivesBaseName = "Dynmap"
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
6 changes: 4 additions & 2 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

##############################################################################
#
Expand Down Expand Up @@ -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/.
Expand Down Expand Up @@ -84,7 +86,7 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down
2 changes: 2 additions & 0 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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 ##########################################################################
Expand Down
4 changes: 4 additions & 0 deletions neoforge-1.20.6/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/.gradle
/bin
/build
/runs
70 changes: 70 additions & 0 deletions neoforge-1.20.6/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
buildscript {
repositories {
jcenter()
mavenCentral()
}
}
plugins {
id 'eclipse'
id 'net.neoforged.gradle.userdev' version '7.0.178'
}

eclipse {
project {
name = "Dynmap(NeoForge-1.20.6)"
}
}

minecraft {
accessTransformers {
file('src/main/resources/META-INF/accesstransformer.cfg')
}
}

sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = JavaLanguageVersion.of(21) // Need this here so eclipse task generates correctly.
java.toolchain.languageVersion = JavaLanguageVersion.of(21)

println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))

ext.buildNumber = System.getenv().BUILD_NUMBER ?: "Dev"


project.archivesBaseName = "${project.archivesBaseName}-neoforge-1.20.6"

dependencies {
implementation project(path: ":DynmapCore", configuration: "shadow")
implementation project(path: ':DynmapCoreAPI')
implementation "net.neoforged:neoforge:20.6.124"
}

processResources
{
filesMatching('META-INF/neoforge.mods.toml') {
// replace version and mcversion
expand(
version: project.version + '-' + project.ext.buildNumber,
mcversion: "1.20.6"
)
}
}

shadowJar {
dependencies {
include(dependency(':DynmapCore'))
include(dependency("commons-codec:commons-codec:"))
exclude("META-INF/maven/**")
exclude("META-INF/services/**")
}
relocate('org.apache.commons.codec', 'org.dynmap.neoforge_1_20_6.commons.codec')

archiveBaseName = "Dynmap"
archiveClassifier = "neoforge-1.20.6"
destinationDirectory = file '../target'
}

shadowJar.doLast {
task ->
ant.checksum file: task.archivePath
}

build.dependsOn(shadowJar)
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package org.dynmap.neoforge_1_20_6;

public class ClientProxy extends Proxy {
public ClientProxy() {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
package org.dynmap.neoforge_1_20_6;

import java.io.File;

import net.minecraft.server.MinecraftServer;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.ModList;
import net.neoforged.fml.ModLoadingContext;
import net.neoforged.fml.common.Mod;
import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent;
import net.neoforged.fml.event.lifecycle.FMLLoadCompleteEvent;
import net.neoforged.fml.loading.FMLEnvironment;
import net.neoforged.neoforge.common.NeoForge;
import net.neoforged.neoforge.event.server.ServerAboutToStartEvent;
import net.neoforged.neoforge.event.server.ServerStartedEvent;
import net.neoforged.neoforge.event.server.ServerStoppingEvent;

import org.dynmap.DynmapCommonAPI;
import org.dynmap.DynmapCommonAPIListener;
import org.dynmap.Log;
import org.dynmap.neoforge_1_20_6.DynmapPlugin.OurLog;

@Mod("dynmap")
public class DynmapMod {
// The instance of your mod that NeoForge uses.
public static DynmapMod instance;

// Says where the client and server 'proxy' code is loaded.
public static Proxy proxy;

public static DynmapPlugin plugin;
public static File jarfile;
public static String ver;
public static boolean useforcedchunks;

public class APICallback extends DynmapCommonAPIListener {
@Override
public void apiListenerAdded() {
if (plugin == null) {
plugin = proxy.startServer(server);
}
}

@Override
public void apiEnabled(DynmapCommonAPI api) {
}
}

// TODO
// public class LoadingCallback implements
// net.minecraftforge.common.ForgeChunkManager.LoadingCallback {
// @Override
// public void ticketsLoaded(List<Ticket> tickets, World world) {
// if (tickets.size() > 0) {
// DynmapPlugin.setBusy(world, tickets.get(0));
// for (int i = 1; i < tickets.size(); i++) {
// ForgeChunkManager.releaseTicket(tickets.get(i));
// }
// }
// }
// }

public DynmapMod() {
instance = this;

if (FMLEnvironment.dist == Dist.CLIENT) {
proxy = new ClientProxy();
} else {
proxy = new Proxy();
}

ModLoadingContext.get().getActiveContainer().getEventBus().addListener(this::setup);
ModLoadingContext.get().getActiveContainer().getEventBus().addListener(this::init);

NeoForge.EVENT_BUS.register(this);

// NeoForge removed DisplayTest, with no current replacement.
// A replacement may arrive in a future networking rework
// ModLoadingContext.get().registerExtensionPoint(IExtensionPoint.DisplayTest.class,
// () -> new IExtensionPoint.DisplayTest(() -> IExtensionPoint.DisplayTest.IGNORESERVERONLY,
// (remote, isServer) -> true));

Log.setLogger(new OurLog());
org.dynmap.modsupport.ModSupportImpl.init();
}

public void setup(final FMLCommonSetupEvent event) {
// TOOO
jarfile = ModList.get().getModFileById("dynmap").getFile().getFilePath().toFile();

ver = ModList.get().getModContainerById("dynmap").get().getModInfo().getVersion().toString();

// // Load configuration file - use suggested (config/WesterosBlocks.cfg)
// Configuration cfg = new Configuration(event.getSuggestedConfigurationFile());
// try {
// cfg.load();

// useforcedchunks = cfg.get("Settings", "UseForcedChunks",
// // true).getBoolean(true);
// } finally {
// cfg.save();
// }
}

public void init(FMLLoadCompleteEvent event) {
/* Set up for chunk loading notice from chunk manager */
// TODO
// if (useforcedchunks) {
// ForgeChunkManager.setForcedChunkLoadingCallback(DynmapMod.instance, new LoadingCallback());
// } else {
// Log.info("[Dynmap] World loading using forced chunks is disabled");
// }
}

private MinecraftServer server;

@SubscribeEvent
public void onServerStarting(ServerAboutToStartEvent event) {
server = event.getServer();
if (plugin == null)
plugin = proxy.startServer(server);
plugin.onStarting(server.getCommands().getDispatcher());
}

@SubscribeEvent
public void onServerStarted(ServerStartedEvent event) {
DynmapCommonAPIListener.register(new APICallback());
plugin.serverStarted();
}

@SubscribeEvent
public void serverStopping(ServerStoppingEvent event) {
proxy.stopServer(plugin);
plugin = null;
}
}
Loading