Skip to content

Commit

Permalink
Start Forge 1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeprimm-mirific committed Jun 16, 2024
1 parent 5256a16 commit 540da73
Show file tree
Hide file tree
Showing 21 changed files with 3,618 additions and 15 deletions.
25 changes: 11 additions & 14 deletions bukkit-helper/.project
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,32 @@
<projectDescription>
<name>Dynmap(Spigot-Common)</name>
<comment>bukkit-helper</comment>
<projects>
</projects>
<projects/>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
<arguments/>
</buildCommand>
<buildCommand>
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
<arguments>
</arguments>
<arguments/>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
<arguments/>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
<linkedResources/>
<filteredResources>
<filter>
<id>1</id>
<name></name>
<type>30</type>
<name/>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
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 16 01:19:02 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
1 change: 1 addition & 0 deletions forge-1.21/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build/
78 changes: 78 additions & 0 deletions forge-1.21/build.gradle
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)
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 forge-1.21/src/main/java/org/dynmap/forge_1_21/DynmapMod.java
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;
}
}
Loading

0 comments on commit 540da73

Please sign in to comment.