Skip to content

Commit

Permalink
Start NeoForge 1.20.6
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeprimm-mirific committed Jun 3, 2024
1 parent 425ca0f commit 402a835
Show file tree
Hide file tree
Showing 21 changed files with 3,587 additions and 2 deletions.
2 changes: 1 addition & 1 deletion bukkit-helper/.settings/org.eclipse.buildship.core.prefs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ arguments=
auto.sync=false
build.scans.enabled=false
connection.gradle.distribution=GRADLE_DISTRIBUTION(VERSION(6.3))
connection.project.dir=../forge-1.20.6
connection.project.dir=../neoforge-1.20.6
eclipse.preferences.version=1
gradle.user.home=
java.home=/Library/Java/JavaVirtualMachines/jdk1.8.0_251.jdk/Contents/Home
Expand Down
2 changes: 1 addition & 1 deletion bukkit-helper/.settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
#Sun Jun 02 15:52:13 CDT 2024
#Sun Jun 02 22:23:44 CDT 2024
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.annotation.nonnull=javax.annotation.Nonnull
org.eclipse.jdt.core.compiler.annotation.nullable=javax.annotation.Nullable
Expand Down
2 changes: 2 additions & 0 deletions neoforge-1.20.6/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/build/
/.gradle/
64 changes: 64 additions & 0 deletions neoforge-1.20.6/build.gradle
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)
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,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;
}
}
Loading

0 comments on commit 402a835

Please sign in to comment.