-
Notifications
You must be signed in to change notification settings - Fork 424
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
425ca0f
commit 402a835
Showing
21 changed files
with
3,587 additions
and
2 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,2 @@ | ||
/build/ | ||
/.gradle/ |
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,64 @@ | ||
buildscript { | ||
repositories { | ||
jcenter() | ||
mavenCentral() | ||
} | ||
} | ||
plugins { | ||
id 'eclipse' | ||
id 'net.neoforged.gradle.userdev' version '7.0.133' | ||
} | ||
|
||
eclipse { | ||
project { | ||
name = "Dynmap(NeoForge-1.20.6)" | ||
} | ||
} | ||
|
||
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}-forge-1.20.6" | ||
|
||
dependencies { | ||
implementation project(path: ":DynmapCore", configuration: "shadow") | ||
implementation project(path: ':DynmapCoreAPI') | ||
implementation "net.neoforged:neoforge:20.6.62-beta" | ||
} | ||
|
||
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) |
6 changes: 6 additions & 0 deletions
6
neoforge-1.20.6/src/main/java/org/dynmap/neoforge_1_20_6/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.neoforge_1_20_6; | ||
|
||
public class ClientProxy extends Proxy { | ||
public ClientProxy() { | ||
} | ||
} |
125 changes: 125 additions & 0 deletions
125
neoforge-1.20.6/src/main/java/org/dynmap/neoforge_1_20_6/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,125 @@ | ||
package org.dynmap.neoforge_1_20_6; | ||
|
||
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.neoforge_1_20_6.DynmapPlugin.OurLog; | ||
|
||
import net.minecraft.server.MinecraftServer; | ||
import net.neoforged.fml.common.Mod; | ||
import net.neoforged.neoforge.event.server.ServerAboutToStartEvent; | ||
import net.neoforged.neoforge.event.server.ServerStartedEvent; | ||
import net.neoforged.neoforge.event.server.ServerStartingEvent; | ||
import net.neoforged.neoforge.event.server.ServerStoppingEvent; | ||
|
||
@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.