Skip to content

Commit

Permalink
Start Forge 1.20.6 code (not yet functional)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeprimm-mirific committed Jun 2, 2024
1 parent d00ff62 commit d78a4fd
Show file tree
Hide file tree
Showing 32 changed files with 3,649 additions and 24 deletions.
5 changes: 3 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ buildscript {
}

plugins {
id "com.github.johnrengelman.shadow" version "7.1.0"
//id "com.github.johnrengelman.shadow" version "7.1.0"
id "io.github.goooler.shadow" version "8.1.7"
id 'java'
id 'maven-publish'
}
Expand Down Expand Up @@ -52,7 +53,7 @@ ext {
}

subprojects {
apply plugin: "com.github.johnrengelman.shadow"
apply plugin: "io.github.goooler.shadow"
apply plugin: 'java'
apply plugin: 'maven-publish'

Expand Down
25 changes: 14 additions & 11 deletions bukkit-helper/.project
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,35 @@
<projectDescription>
<name>Dynmap(Spigot-Common)</name>
<comment>bukkit-helper</comment>
<projects/>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
<projects>
</projects>
<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>
<linkedResources/>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
<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.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=../bukkit-helper-120-5
connection.project.dir=../forge-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 Apr 28 13:34:57 CDT 2024
#Sun Jun 02 15:52:13 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: 1 addition & 1 deletion forge-1.14.4/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ buildscript {
}
}
apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'com.github.johnrengelman.shadow'
//apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'eclipse'

eclipse {
Expand Down
2 changes: 1 addition & 1 deletion forge-1.15.2/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ buildscript {
}
}
apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'com.github.johnrengelman.shadow'
//apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'eclipse'

eclipse {
Expand Down
2 changes: 1 addition & 1 deletion forge-1.16.5/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ buildscript {
}
}
apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'com.github.johnrengelman.shadow'
//apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'eclipse'

eclipse {
Expand Down
2 changes: 1 addition & 1 deletion forge-1.17.1/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ buildscript {
}
}
apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'com.github.johnrengelman.shadow'
//apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'eclipse'

eclipse {
Expand Down
2 changes: 1 addition & 1 deletion forge-1.18.2/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ buildscript {
}
}
apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'com.github.johnrengelman.shadow'
//apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'eclipse'

eclipse {
Expand Down
2 changes: 1 addition & 1 deletion forge-1.19.3/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ buildscript {
}
}
apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'com.github.johnrengelman.shadow'
//apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'eclipse'

eclipse {
Expand Down
2 changes: 1 addition & 1 deletion forge-1.20.2/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ buildscript {
}
}
apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'com.github.johnrengelman.shadow'
//apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'eclipse'

eclipse {
Expand Down
2 changes: 1 addition & 1 deletion forge-1.20.2/src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ Dynamic, Google-maps style rendered maps for your Minecraft server
[[dependencies.dynmap]]
modId="minecraft"
mandatory=true
versionRange="[1.20.2,1.21)"
versionRange="[1.20.2,1.20.4)"
ordering="NONE"
side="SERVER"
1 change: 1 addition & 0 deletions forge-1.20.6/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build/
93 changes: 93 additions & 0 deletions forge-1.20.6/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
buildscript {
repositories {
maven { url = 'https://files.minecraftforge.net/maven' }
jcenter()
mavenCentral()
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '6.+', changing: true
}
}
apply plugin: 'net.minecraftforge.gradle'
//apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'eclipse'

eclipse {
project {
name = "Dynmap(Forge-1.20.6)"
}
}

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.20.6'
accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
runs {
server {
workingDirectory project.file('run').canonicalPath
}
}
}

project.archivesBaseName = "${project.archivesBaseName}-forge-1.20.6"

dependencies {
implementation project(path: ":DynmapCore", configuration: "shadow")
implementation project(path: ':DynmapCoreAPI')

minecraft 'net.minecraftforge:forge:1.20.6-50.0.31'
}

processResources
{
filesMatching('META-INF/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.forge_1_20_6.commons.codec')

archiveBaseName = "Dynmap"
archiveClassifier = "forge-1.20.6"
destinationDirectory = file '../target'
}

shadowJar.doLast {
task ->
ant.checksum file: task.archivePath
}

afterEvaluate {
reobf {
shadowJar {
mappings = createMcpToSrg.output
}
}
}

task deobfJar(type: Jar) {
from sourceSets.main.output
archiveClassifier = 'dev'
}

artifacts {
archives deobfJar
}

build.dependsOn(shadowJar)
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package org.dynmap.forge_1_20_6;

public class ClientProxy extends Proxy {
public ClientProxy() {
}
}
135 changes: 135 additions & 0 deletions forge-1.20.6/src/main/java/org/dynmap/forge_1_20_6/DynmapMod.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
package org.dynmap.forge_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.forge_1_20_6.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 d78a4fd

Please sign in to comment.