Skip to content

Commit add4834

Browse files
committed
spilt neoforge and neotenet patches
1 parent 6ef4215 commit add4834

8 files changed

Lines changed: 242 additions & 642 deletions

File tree

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,4 @@ build
4646

4747
**/out/
4848
/projects/cb-base/
49-
/projects/neotenet-server/src/
49+
/projects/neotenet-base/src/

build.gradle

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,16 +154,25 @@ tasks.register('applyCBPatches') {
154154
}
155155
}
156156

157+
tasks.register('prepareNeoForgeBase', Copy) {
158+
group = 'neotenet'
159+
160+
from('projects/neoforge/src/main/java')
161+
into('projects/neotenet-base/src/main/java')
162+
163+
duplicatesStrategy = DuplicatesStrategy.INCLUDE
164+
}
165+
157166
tasks.register('genNeoForgePatchesJar') {
158167
group = 'neotenet'
159168

160-
inputs.dir('projects/neotenet-server/src/main/java')
169+
inputs.dir('projects/neotenet-base/src/main/java')
161170
inputs.dir('projects/neoforge/src/main/java')
162171
outputs.file('projects/neotenet/neoforge-patches.jar')
163172

164173
doLast {
165174
def baseDir = new File(rootDir, 'projects/neoforge/src/main/java').toPath()
166-
def modifiedDir = new File(rootDir, 'projects/neotenet-server/src/main/java').toPath()
175+
def modifiedDir = new File(rootDir, 'projects/neotenet-base/src/main/java').toPath()
167176
def patchesJar = new File(rootDir, 'projects/neotenet/neoforge-patches.jar').toPath()
168177

169178
java.nio.file.Files.deleteIfExists(patchesJar)
@@ -193,16 +202,16 @@ tasks.register('applyNeoForgePatches') {
193202
group = 'neotenet'
194203

195204
inputs.file('projects/neotenet/neoforge-patches.jar')
196-
outputs.dir('projects/neotenet-server/src/main/java')
205+
outputs.dir('projects/neoforge/src/main/java')
197206

198207
doLast {
199208
def patchesJar = new File(rootDir, 'projects/neotenet/neoforge-patches.jar')
200209
if (!patchesJar.exists()) {
201210
logger.lifecycle('neoforge-patches.jar Non Exist,Skip')
202211
return
203212
}
204-
def baseDir = new File(rootDir, 'projects/neoforge/src/main/java').toPath()
205-
def targetDir = new File(rootDir, 'projects/neotenet-server/src/main/java').toPath()
213+
def baseDir = new File(rootDir, 'projects/neotenet-base/src/main/java').toPath()
214+
def targetDir = new File(rootDir, 'projects/neoforge/src/main/java').toPath()
206215

207216
def builder = PatchOperation.builder()
208217
.logTo(logger::lifecycle)

patches/net/minecraft/server/MinecraftServer.java.patch

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,26 @@
11
--- a/net/minecraft/server/MinecraftServer.java
22
+++ b/net/minecraft/server/MinecraftServer.java
3-
@@ -190,7 +_,7 @@
3+
@@ -43,6 +_,8 @@
4+
import java.util.function.Function;
5+
import java.util.function.Supplier;
6+
import java.util.stream.Collectors;
7+
+
8+
+import joptsimple.OptionSet;
9+
import net.minecraft.CrashReport;
10+
import net.minecraft.CrashReportCategory;
11+
import net.minecraft.ReportType;
12+
@@ -186,11 +_,13 @@
13+
import net.minecraft.world.phys.Vec2;
14+
import net.minecraft.world.phys.Vec3;
15+
import net.minecraft.world.scores.ScoreboardSaveData;
16+
+import org.jline.terminal.Terminal;
17+
import org.jspecify.annotations.Nullable;
418
import org.slf4j.Logger;
19+
+import org.teneted.neotenet.injection.server.MinecraftServerInjection;
520

6-
public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTask> implements CommandSource, ServerInfo, ChunkIOErrorReporter {
21+
-public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTask> implements CommandSource, ServerInfo, ChunkIOErrorReporter {
722
- public static final Logger LOGGER = LogUtils.getLogger();
23+
+public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTask> implements CommandSource, ServerInfo, ChunkIOErrorReporter, MinecraftServerInjection {
824
+ private static final Logger LOGGER = LogUtils.getLogger();
925
public static final String VANILLA_BRAND = "vanilla";
1026
private static final float AVERAGE_TICK_TIME_SMOOTHING = 0.8F;
@@ -67,7 +83,21 @@
6783
private LevelData.RespawnData effectiveRespawnData = LevelData.RespawnData.DEFAULT;
6884
private final PotionBrewing potionBrewing;
6985
private FuelValues fuelValues;
70-
@@ -296,7 +_,7 @@
86+
@@ -293,10 +_,21 @@
87+
private final PacketProcessor packetProcessor;
88+
private final TimerQueue<MinecraftServer> scheduledEvents;
89+
private final ServerClockManager clockManager;
90+
+ // CraftBukkit start
91+
+ public WorldLoader.DataLoadContext worldLoader;
92+
+ public org.bukkit.craftbukkit.CraftServer server;
93+
+ public OptionSet options;
94+
+ public org.bukkit.command.ConsoleCommandSender console;
95+
+ public Terminal terminal;
96+
+ public static int currentTick = (int) (System.currentTimeMillis() / 50);
97+
+ public java.util.Queue<Runnable> processQueue = new java.util.concurrent.ConcurrentLinkedQueue<Runnable>();
98+
+ public int autosavePeriod;
99+
+ public Commands vanillaCommandDispatcher;
100+
+ // CraftBukkit end
71101

72102
public static <S extends MinecraftServer> S spin(Function<Thread, S> factory) {
73103
AtomicReference<S> serverReference = new AtomicReference<>();
@@ -364,6 +394,18 @@
364394
public RegistryAccess.Frozen registryAccess() {
365395
return this.registries.compositeAccess();
366396
}
397+
@@ -2065,6 +_,11 @@
398+
}
399+
}
400+
401+
+ // CraftBukkit start
402+
+ public final java.util.concurrent.ExecutorService chatExecutor = java.util.concurrent.Executors.newCachedThreadPool(
403+
+ new com.google.common.util.concurrent.ThreadFactoryBuilder().setDaemon(true).setNameFormat("Async Chat Thread - #%d").build());
404+
+ // CraftBukkit end
405+
+
406+
public ChatDecorator getChatDecorator() {
407+
return ChatDecorator.PLAIN;
408+
}
367409
@@ -2073,6 +_,13 @@
368410
return true;
369411
}

projects/neoforge/build.gradle

Lines changed: 65 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,20 @@ evaluationDependsOn(":neoforge-coremods")
2020

2121
gradleutils.setupSigning(project: project, signAllPublications: true)
2222

23+
tasks.withType(JavaCompile).configureEach {
24+
it.options.release = 25
25+
options.encoding = 'UTF-8'
26+
options.warnings = false
27+
options.compilerArgs << "-Xlint:-removal" << "-Xlint:-deprecation" << "-Xlint:-dep-ann" << "-Xlint:-varargs" << "-Xdiags:verbose"
28+
}
29+
2330
sourceSets {
2431
main {
2532
java {
26-
srcDirs rootProject.file('src/main/java')
33+
srcDirs rootProject.file('src/main/java'), rootProject.file('projects/neotenet/src/main/java')
2734
}
2835
resources {
29-
srcDirs rootProject.file('src/main/resources'), rootProject.file('src/generated/resources')
36+
srcDirs rootProject.file('src/main/resources'), rootProject.file('src/generated/resources'), rootProject.file('projects/neotenet/src/main/resources')
3037
}
3138
}
3239
client {
@@ -139,9 +146,51 @@ dependencies {
139146
exclude group: 'org.slf4j'
140147
}
141148

149+
// craftbukkit
150+
libraries 'javax.inject:javax.inject:1'
151+
libraries 'com.googlecode.json-simple:json-simple:1.1.1'
152+
libraries 'org.xerial:sqlite-jdbc:3.51.3.0'
153+
libraries 'com.mysql:mysql-connector-j:9.6.0'
154+
libraries 'org.apache.logging.log4j:log4j-iostreams:2.26.0'
155+
libraries 'org.apache.logging.log4j:log4j-core:2.26.0'
156+
libraries 'org.apache.logging.log4j:log4j-slf4j2-impl:2.26.0'
157+
libraries 'org.jline:jline:3.30.4'
158+
// spigot
159+
libraries 'commons-codec:commons-codec:1.22.0'
160+
libraries 'commons-lang:commons-lang:2.6'
161+
libraries 'org.apache.commons:commons-lang3:3.20.0'
162+
libraries 'org.apache.httpcomponents:httpclient:4.5.14'
163+
libraries 'org.apache.httpcomponents:httpcore:4.4.16'
164+
libraries 'net.sf.jopt-simple:jopt-simple:5.0.4'
165+
// bukkit
166+
libraries 'org.yaml:snakeyaml:2.6'
167+
// LibraryLoader start
168+
libraries 'org.checkerframework:checker-qual:3.49.2'
169+
libraries 'org.eclipse.sisu:org.eclipse.sisu.inject:0.9.0.M2'
170+
libraries 'org.codehaus.plexus:plexus-interpolation:1.26'
171+
libraries 'org.codehaus.plexus:plexus-utils:4.0.3'
172+
libraries 'com.google.protobuf:protobuf-java:4.28.2'
173+
libraries "org.apache.maven:maven-artifact:3.9.9"
174+
libraries 'org.apache.maven:maven-builder-support:3.9.6'
175+
libraries 'org.apache.maven:maven-model:3.9.6'
176+
libraries 'org.apache.maven:maven-model-builder:3.9.6'
177+
libraries 'org.apache.maven:maven-repository-metadata:3.9.6'
178+
libraries 'org.apache.maven:maven-resolver-provider:3.9.6'
179+
180+
libraries 'org.apache.maven.resolver:maven-resolver-api:1.9.18'
181+
libraries 'org.apache.maven.resolver:maven-resolver-connector-basic:1.9.18'
182+
libraries 'org.apache.maven.resolver:maven-resolver-impl:1.9.18'
183+
libraries 'org.apache.maven.resolver:maven-resolver-named-locks:1.9.18'
184+
libraries 'org.apache.maven.resolver:maven-resolver-spi:1.9.18'
185+
libraries 'org.apache.maven.resolver:maven-resolver-transport-http:1.9.18'
186+
libraries 'org.apache.maven.resolver:maven-resolver-util:1.9.18'
187+
// LibraryLoader end
188+
142189
compileOnly "org.jetbrains:annotations:${project.jetbrains_annotations_version}"
143190

144-
userdevCompileOnly jarJar("io.github.llamalad7:mixinextras-neoforge:${project.mixin_extras_version}")
191+
compileOnly(annotationProcessor("io.github.llamalad7:mixinextras-common:${project.mixin_extras_version}"))
192+
implementation(jarJar("io.github.llamalad7:mixinextras-neoforge:${project.mixin_extras_version}"))
193+
//userdevCompileOnly jarJar("io.github.llamalad7:mixinextras-neoforge:${project.mixin_extras_version}")
145194

146195
userdevTestFixtures("net.neoforged.fancymodloader:junit-fml:${project.fancy_mod_loader_version}") {
147196
endorseStrictVersions()
@@ -474,6 +523,18 @@ configurations {
474523
}
475524
javaComponent.addVariantsFromConfiguration(it) {}
476525
}
526+
changelog {
527+
canBeDeclared = false
528+
canBeResolved = false
529+
attributes {
530+
attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category, Category.DOCUMENTATION))
531+
attribute(DocsType.DOCS_TYPE_ATTRIBUTE, objects.named(DocsType, "changelog"))
532+
}
533+
// Publish it, but only for release versions
534+
if (!rootProject.isPreReleaseVersion) {
535+
javaComponent.addVariantsFromConfiguration(it) {}
536+
}
537+
}
477538
}
478539

479540
sourcesJar {
@@ -550,9 +611,4 @@ publishing {
550611
repositories {
551612
maven gradleutils.getPublishingMaven()
552613
}
553-
}
554-
555-
556-
tasks.withType(JavaCompile.class).configureEach(task -> {
557-
Collections.addAll(task.getOptions().getCompilerArgs(), "-Xmaxerrs", "9999");
558-
});
614+
}
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
plugins {
2+
id 'java-library'
3+
id 'maven-publish'
4+
}
5+
6+
sourceSets {
7+
main {
8+
java {
9+
srcDirs rootProject.file('src/main/java'), rootProject.file('projects/neotenet/src/main/java')
10+
}
11+
resources {
12+
srcDirs rootProject.file('src/main/resources'), rootProject.file('src/generated/resources'), rootProject.file('projects/neotenet/src/main/resources')
13+
}
14+
}
15+
client {
16+
java {
17+
srcDirs rootProject.file('src/client/java')
18+
}
19+
}
20+
}
21+
22+
dependencies {
23+
for (var asmModule : ["org.ow2.asm:asm", "org.ow2.asm:asm-commons", "org.ow2.asm:asm-tree", "org.ow2.asm:asm-util", "org.ow2.asm:asm-analysis"]) {
24+
compileOnly(asmModule) {
25+
// Vanilla ships with ASM 9.3 transitively (via their OpenID connect library dependency), we require
26+
// ASM in a more recent version and have to strictly require this to override the strict Minecraft version.
27+
version {
28+
strictly project.asm_version
29+
}
30+
}
31+
}
32+
compileOnly ("net.neoforged.fancymodloader:loader:${project.fancy_mod_loader_version}") {
33+
exclude group: 'org.slf4j'
34+
exclude group: 'net.fabricmc'
35+
// MC currently (as of 26.2-pre-1) uses the Unsafe-using artifact of LWJGL.
36+
// To avoid overriding that artifact, exclude it from here and rely on minecraft-dependencies to provide it.
37+
// We must specifically exclude the main LWJGL module, since FML depends on lwjgl-tinyfd.
38+
exclude group: 'org.lwjgl', module: 'lwjgl'
39+
}
40+
compileOnly ("net.neoforged.fancymodloader:earlydisplay:${project.fancy_mod_loader_version}") {
41+
exclude group: 'org.lwjgl'
42+
exclude group: 'org.slf4j'
43+
exclude group: 'net.fabricmc'
44+
}
45+
compileOnly "net.neoforged:accesstransformers:${project.accesstransformers_version}"
46+
compileOnly "net.neoforged:bus:${project.eventbus_version}"
47+
compileOnly "net.neoforged:mergetool:${project.mergetool_version}:api"
48+
compileOnly "com.electronwill.night-config:core:${project.nightconfig_version}"
49+
compileOnly "com.electronwill.night-config:toml:${project.nightconfig_version}"
50+
compileOnly "org.apache.maven:maven-artifact:${project.apache_maven_artifact_version}"
51+
compileOnly "net.jodah:typetools:${project.typetools_version}"
52+
compileOnly "net.minecrell:terminalconsoleappender:${project.terminalconsoleappender_version}"
53+
compileOnly("net.fabricmc:sponge-mixin:${project.mixin_version}") { transitive = false }
54+
compileOnly ("net.neoforged:JarJarSelector:${project.jarjar_version}") {
55+
exclude group: 'org.slf4j'
56+
}
57+
compileOnly ("net.neoforged:JarJarMetadata:${project.jarjar_version}") {
58+
exclude group: 'org.slf4j'
59+
}
60+
61+
// craftbukkit
62+
compileOnly 'javax.inject:javax.inject:1'
63+
compileOnly 'com.googlecode.json-simple:json-simple:1.1.1'
64+
compileOnly 'org.xerial:sqlite-jdbc:3.51.3.0'
65+
compileOnly 'com.mysql:mysql-connector-j:9.6.0'
66+
compileOnly 'org.apache.logging.log4j:log4j-iostreams:2.26.0'
67+
compileOnly 'org.apache.logging.log4j:log4j-core:2.26.0'
68+
compileOnly 'org.apache.logging.log4j:log4j-slf4j2-impl:2.26.0'
69+
compileOnly 'org.jline:jline:3.30.4'
70+
// spigot
71+
compileOnly 'commons-codec:commons-codec:1.22.0'
72+
compileOnly 'commons-lang:commons-lang:2.6'
73+
compileOnly 'org.apache.commons:commons-lang3:3.20.0'
74+
compileOnly 'org.apache.httpcomponents:httpclient:4.5.14'
75+
compileOnly 'org.apache.httpcomponents:httpcore:4.4.16'
76+
compileOnly 'net.sf.jopt-simple:jopt-simple:5.0.4'
77+
// bukkit
78+
compileOnly 'org.yaml:snakeyaml:2.6'
79+
// LibraryLoader start
80+
compileOnly 'org.checkerframework:checker-qual:3.49.2'
81+
compileOnly 'org.eclipse.sisu:org.eclipse.sisu.inject:0.9.0.M2'
82+
compileOnly 'org.codehaus.plexus:plexus-interpolation:1.26'
83+
compileOnly 'org.codehaus.plexus:plexus-utils:4.0.3'
84+
compileOnly 'com.google.protobuf:protobuf-java:4.28.2'
85+
compileOnly "org.apache.maven:maven-artifact:3.9.9"
86+
compileOnly 'org.apache.maven:maven-builder-support:3.9.6'
87+
compileOnly 'org.apache.maven:maven-model:3.9.6'
88+
compileOnly 'org.apache.maven:maven-model-builder:3.9.6'
89+
compileOnly 'org.apache.maven:maven-repository-metadata:3.9.6'
90+
compileOnly 'org.apache.maven:maven-resolver-provider:3.9.6'
91+
92+
compileOnly 'org.apache.maven.resolver:maven-resolver-api:1.9.18'
93+
compileOnly 'org.apache.maven.resolver:maven-resolver-connector-basic:1.9.18'
94+
compileOnly 'org.apache.maven.resolver:maven-resolver-impl:1.9.18'
95+
compileOnly 'org.apache.maven.resolver:maven-resolver-named-locks:1.9.18'
96+
compileOnly 'org.apache.maven.resolver:maven-resolver-spi:1.9.18'
97+
compileOnly 'org.apache.maven.resolver:maven-resolver-transport-http:1.9.18'
98+
compileOnly 'org.apache.maven.resolver:maven-resolver-util:1.9.18'
99+
// LibraryLoader end
100+
101+
// Vanilla Lib Start
102+
compileOnly 'com.mojang:authlib:9.0.75'
103+
compileOnly 'com.mojang:datafixerupper:10.0.21'
104+
compileOnly 'com.mojang:jtracy:1.0.37'
105+
compileOnly 'it.unimi.dsi:fastutil:8.5.18'
106+
// Vanilla Lib end
107+
compileOnly "org.jetbrains:annotations:${project.jetbrains_annotations_version}"
108+
}
109+
110+
tasks.withType(JavaCompile).configureEach {
111+
it.options.release = 25
112+
options.encoding = 'UTF-8'
113+
options.warnings = false
114+
options.compilerArgs << "-Xlint:-removal" << "-Xlint:-deprecation" << "-Xlint:-dep-ann" << "-Xlint:-varargs" << "-Xdiags:verbose"
115+
}

0 commit comments

Comments
 (0)