Skip to content

Commit 4daa33f

Browse files
committed
Add forge 1.21.11 support
1 parent 6234683 commit 4daa33f

20 files changed

Lines changed: 3685 additions & 45 deletions

forge-1.21.11/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build/

forge-1.21.11/build.gradle

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
buildscript {
2+
repositories {
3+
maven { url = 'https://files.minecraftforge.net/maven' }
4+
jcenter()
5+
mavenCentral()
6+
}
7+
dependencies {
8+
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '[6.0.24,6.2)', changing: true
9+
}
10+
}
11+
apply plugin: 'net.minecraftforge.gradle'
12+
//apply plugin: 'com.github.johnrengelman.shadow'
13+
apply plugin: 'eclipse'
14+
15+
eclipse {
16+
project {
17+
name = "Dynmap(Forge-1.21.11)"
18+
}
19+
}
20+
21+
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = JavaLanguageVersion.of(21) // Need this here so eclipse task generates correctly.
22+
23+
println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))
24+
25+
ext.buildNumber = System.getenv().BUILD_NUMBER ?: "Dev"
26+
27+
minecraft {
28+
mappings channel: 'official', version: '1.21.11'
29+
accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
30+
reobf = false
31+
copyIdeResources = true
32+
runs {
33+
server {
34+
property 'eventbus.api.strictRuntimeChecks', 'true'
35+
workingDirectory project.file('run').canonicalPath
36+
}
37+
}
38+
}
39+
40+
project.archivesBaseName = "${project.archivesBaseName}-forge-1.21.11"
41+
42+
dependencies {
43+
implementation project(path: ":DynmapCore", configuration: "shadow")
44+
implementation project(path: ':DynmapCoreAPI')
45+
annotationProcessor 'net.minecraftforge:eventbus-validator:7.0-beta.7'
46+
47+
minecraft 'net.minecraftforge:forge:1.21.11-61.0.5'
48+
}
49+
50+
processResources
51+
{
52+
filesMatching('META-INF/mods.toml') {
53+
// replace version and mcversion
54+
expand(
55+
version: project.version + '-' + project.ext.buildNumber,
56+
mcversion: "1.21.11"
57+
)
58+
}
59+
}
60+
61+
shadowJar {
62+
dependencies {
63+
include(dependency(':DynmapCore'))
64+
include(dependency("commons-codec:commons-codec:"))
65+
exclude("META-INF/maven/**")
66+
exclude("META-INF/services/**")
67+
}
68+
relocate('org.apache.commons.codec', 'org.dynmap.forge_1_21_11.commons.codec')
69+
70+
archiveBaseName = "Dynmap"
71+
archiveClassifier = "forge-1.21.11"
72+
destinationDirectory = file '../target'
73+
}
74+
75+
shadowJar.doLast {
76+
task ->
77+
ant.checksum file: task.archivePath
78+
}
79+
80+
build.dependsOn(shadowJar)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package org.dynmap.forge_1_21_11;
2+
3+
public class ClientProxy extends Proxy {
4+
public ClientProxy() {
5+
}
6+
}
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
package org.dynmap.forge_1_21_11;
2+
3+
import java.io.File;
4+
5+
import org.apache.commons.lang3.tuple.Pair;
6+
import org.dynmap.DynmapCommonAPI;
7+
import org.dynmap.DynmapCommonAPIListener;
8+
import org.dynmap.Log;
9+
import org.dynmap.forge_1_21_11.DynmapPlugin.OurLog;
10+
11+
import net.minecraft.server.MinecraftServer;
12+
import net.minecraftforge.fml.common.Mod;
13+
import net.minecraftforge.common.MinecraftForge;
14+
import net.minecraftforge.event.server.ServerAboutToStartEvent;
15+
import net.minecraftforge.event.server.ServerStartedEvent;
16+
import net.minecraftforge.event.server.ServerStartingEvent;
17+
import net.minecraftforge.event.server.ServerStoppingEvent;
18+
import net.minecraftforge.eventbus.api.bus.BusGroup;
19+
import net.minecraftforge.eventbus.api.bus.EventBus;
20+
import net.minecraftforge.eventbus.api.listener.SubscribeEvent;
21+
import net.minecraftforge.fml.DistExecutor;
22+
import net.minecraftforge.fml.IExtensionPoint;
23+
import net.minecraftforge.fml.ModList;
24+
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
25+
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
26+
27+
@Mod("dynmap")
28+
public class DynmapMod
29+
{
30+
// The instance of your mod that Forge uses.
31+
public static DynmapMod instance;
32+
public static BusGroup modBusGroup;
33+
34+
// Says where the client and server 'proxy' code is loaded.
35+
public static Proxy proxy = DistExecutor.runForDist(() -> ClientProxy::new, () -> Proxy::new);
36+
37+
public static DynmapPlugin plugin;
38+
public static File jarfile;
39+
public static String ver;
40+
public static boolean useforcedchunks;
41+
42+
public class APICallback extends DynmapCommonAPIListener {
43+
@Override
44+
public void apiListenerAdded() {
45+
if(plugin == null) {
46+
plugin = proxy.startServer(server);
47+
}
48+
}
49+
@Override
50+
public void apiEnabled(DynmapCommonAPI api) {
51+
}
52+
}
53+
54+
public DynmapMod(FMLJavaModLoadingContext context) {
55+
instance = this;
56+
57+
modBusGroup = context.getModBusGroup();
58+
59+
// Register the commonSetup method for modloading
60+
FMLCommonSetupEvent.getBus(modBusGroup).addListener(this::setup);
61+
62+
ServerStartedEvent.BUS.addListener(this::onServerStarted);
63+
ServerAboutToStartEvent.BUS.addListener(this::onServerStarting);
64+
ServerStoppingEvent.BUS.addListener(this::onServerStopping);
65+
66+
context.registerExtensionPoint(IExtensionPoint.DisplayTest.class,
67+
()->new IExtensionPoint.DisplayTest(()->IExtensionPoint.DisplayTest.IGNORESERVERONLY, (remote, isServer)-> true));
68+
69+
Log.setLogger(new OurLog());
70+
org.dynmap.modsupport.ModSupportImpl.init();
71+
}
72+
73+
public void setup(final FMLCommonSetupEvent event)
74+
{
75+
//TOOO
76+
jarfile = ModList.get().getModFileById("dynmap").getFile().getFilePath().toFile();
77+
78+
ver = ModList.get().getModContainerById("dynmap").get().getModInfo().getVersion().toString();
79+
80+
//// Load configuration file - use suggested (config/WesterosBlocks.cfg)
81+
//Configuration cfg = new Configuration(event.getSuggestedConfigurationFile());
82+
//try {
83+
// cfg.load();
84+
//
85+
// useforcedchunks = cfg.get("Settings", "UseForcedChunks", true).getBoolean(true);
86+
//}
87+
//finally
88+
//{
89+
// cfg.save();
90+
//}
91+
}
92+
93+
private MinecraftServer server;
94+
95+
public void onServerStarting(ServerAboutToStartEvent event) {
96+
server = event.getServer();
97+
if(plugin == null)
98+
plugin = proxy.startServer(server);
99+
plugin.onStarting(server.getCommands().getDispatcher());
100+
}
101+
102+
public void onServerStarted(ServerStartedEvent event) {
103+
DynmapCommonAPIListener.register(new APICallback());
104+
plugin.serverStarted();
105+
}
106+
107+
public void onServerStopping(ServerStoppingEvent event)
108+
{
109+
proxy.stopServer(plugin);
110+
plugin = null;
111+
}
112+
}

0 commit comments

Comments
 (0)