-
Notifications
You must be signed in to change notification settings - Fork 420
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5256a16
commit 540da73
Showing
21 changed files
with
3,618 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
buildscript { | ||
repositories { | ||
maven { url = 'https://files.minecraftforge.net/maven' } | ||
jcenter() | ||
mavenCentral() | ||
} | ||
dependencies { | ||
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '[6.0.24,6.2)', changing: true | ||
} | ||
} | ||
apply plugin: 'net.minecraftforge.gradle' | ||
//apply plugin: 'com.github.johnrengelman.shadow' | ||
apply plugin: 'eclipse' | ||
|
||
eclipse { | ||
project { | ||
name = "Dynmap(Forge-1.21)" | ||
} | ||
} | ||
|
||
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = JavaLanguageVersion.of(21) // Need this here so eclipse task generates correctly. | ||
|
||
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" | ||
|
||
minecraft { | ||
mappings channel: 'official', version: '1.21' | ||
accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') | ||
reobf = false | ||
copyIdeResources = true | ||
runs { | ||
server { | ||
workingDirectory project.file('run').canonicalPath | ||
} | ||
} | ||
} | ||
|
||
project.archivesBaseName = "${project.archivesBaseName}-forge-1.21" | ||
|
||
dependencies { | ||
implementation project(path: ":DynmapCore", configuration: "shadow") | ||
implementation project(path: ':DynmapCoreAPI') | ||
|
||
minecraft 'net.minecraftforge:forge:1.21-51.0.8' | ||
} | ||
|
||
processResources | ||
{ | ||
filesMatching('META-INF/mods.toml') { | ||
// replace version and mcversion | ||
expand( | ||
version: project.version + '-' + project.ext.buildNumber, | ||
mcversion: "1.21" | ||
) | ||
} | ||
} | ||
|
||
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.forge_1_21.commons.codec') | ||
|
||
archiveBaseName = "Dynmap" | ||
archiveClassifier = "forge-1.21" | ||
destinationDirectory = file '../target' | ||
} | ||
|
||
shadowJar.doLast { | ||
task -> | ||
ant.checksum file: task.archivePath | ||
} | ||
|
||
build.dependsOn(shadowJar) |
6 changes: 6 additions & 0 deletions
6
forge-1.21/src/main/java/org/dynmap/forge_1_21/ClientProxy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package org.dynmap.forge_1_21; | ||
|
||
public class ClientProxy extends Proxy { | ||
public ClientProxy() { | ||
} | ||
} |
135 changes: 135 additions & 0 deletions
135
forge-1.21/src/main/java/org/dynmap/forge_1_21/DynmapMod.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
package org.dynmap.forge_1_21; | ||
|
||
import java.io.File; | ||
|
||
import org.apache.commons.lang3.tuple.Pair; | ||
import org.dynmap.DynmapCommonAPI; | ||
import org.dynmap.DynmapCommonAPIListener; | ||
import org.dynmap.Log; | ||
import org.dynmap.forge_1_21.DynmapPlugin.OurLog; | ||
|
||
import net.minecraft.server.MinecraftServer; | ||
import net.minecraftforge.fml.common.Mod; | ||
import net.minecraftforge.common.MinecraftForge; | ||
import net.minecraftforge.event.server.ServerAboutToStartEvent; | ||
import net.minecraftforge.event.server.ServerStartedEvent; | ||
import net.minecraftforge.event.server.ServerStartingEvent; | ||
import net.minecraftforge.event.server.ServerStoppingEvent; | ||
import net.minecraftforge.eventbus.api.SubscribeEvent; | ||
import net.minecraftforge.fml.DistExecutor; | ||
import net.minecraftforge.fml.IExtensionPoint; | ||
import net.minecraftforge.fml.ModList; | ||
import net.minecraftforge.fml.ModLoadingContext; | ||
import net.minecraftforge.fml.StartupMessageManager; | ||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; | ||
import net.minecraftforge.fml.event.lifecycle.FMLLoadCompleteEvent; | ||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; | ||
|
||
@Mod("dynmap") | ||
public class DynmapMod | ||
{ | ||
// The instance of your mod that Forge uses. | ||
public static DynmapMod instance; | ||
|
||
// Says where the client and server 'proxy' code is loaded. | ||
public static Proxy proxy = DistExecutor.runForDist(() -> ClientProxy::new, () -> Proxy::new); | ||
|
||
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; | ||
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup); | ||
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::init); | ||
|
||
MinecraftForge.EVENT_BUS.register(this); | ||
|
||
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; | ||
} | ||
} |
Oops, something went wrong.