Skip to content

Commit

Permalink
[1.18.2] Merge dev branch (#765)
Browse files Browse the repository at this point in the history
* Fix sign can not edit

* Update Forge to 40.2.4

* Fix CatServerCallbackExecutor throw Already queued

* Full BukkitInjector and fix unknown villagerProfession

* Break redstone on top of trap doors early

* [PATCH] Prevent hoppers from loading chunks

* Fix inject attribute

* Handle CraftMetaItem unhandled custom nbt

* Make sure thread safety and method parameters are correct

* Fix call wrong method

* Fix chunk save
  • Loading branch information
Luohuayu authored May 26, 2023
1 parent c9ed115 commit 6c3f596
Show file tree
Hide file tree
Showing 52 changed files with 755 additions and 1,057 deletions.
24 changes: 11 additions & 13 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:[5.1.39,)'
classpath 'net.minecraftforge.gradle:ForgeGradle:[5.1.39,5.2.0)'
classpath "dev.vankka:gradle-plugin:1.2.1"
}
}
Expand Down Expand Up @@ -49,20 +49,19 @@ ext {
COREMODS_VERSION = '5.0.1'
EVENTBUS_VERSION = '5.0.3'
MODLAUNCHER_VERSION = '9.1.3'
SECUREJARHANDLER_VERSION = '1.0.3'
SECUREJARHANDLER_VERSION = '1.0.8'
BOOTSTRAPLAUNCHER_VERSION = '1.0.0'
ASM_VERSION = '9.2'
ASM_VERSION = '9.5'
INSTALLER_VERSION = '2.1.+'
MIXIN_VERSION = '0.8.5'
JARJAR_VERSION = '0.3.0'
JARJAR_VERSION = '0.3.19'

GIT_INFO = gradleutils.gitInfo
FORGE_VERSION = "40.2.2"
FORGE_VERSION = "40.2.4"
VERSION = "1.18.2-$FORGE_VERSION"
CATSERVER_VERSION = "1.18.2-" + gitVersion
// FML_VERSION = gradleutils.getFilteredMCTagOffsetBranchVersion(true, 'FML', MC_VERSION)

SPECIAL_SOURCE = 'net.md-5:SpecialSource:1.10.0'
BINPATCH_TOOL = 'net.minecraftforge:binarypatcher:1.0.12:fatjar'
INSTALLER_TOOLS = 'net.minecraftforge:installertools:1.2.10'
JAR_SPLITTER = 'net.minecraftforge:jarsplitter:1.1.4'
Expand Down Expand Up @@ -195,6 +194,7 @@ def sharedDeps = {
moduleonly "org.ow2.asm:asm-util:${ASM_VERSION}"
moduleonly "org.ow2.asm:asm-analysis:${ASM_VERSION}"
moduleonly "cpw.mods:bootstraplauncher:${BOOTSTRAPLAUNCHER_VERSION}"
moduleonly "net.minecraftforge:JarJarFileSystems:${JARJAR_VERSION}"

installer "cpw.mods:securejarhandler:${SECUREJARHANDLER_VERSION}"
installer "org.ow2.asm:asm:${ASM_VERSION}"
Expand All @@ -220,7 +220,8 @@ def sharedDeps = {
installer 'org.jline:jline-terminal-jansi:3.12.1'
installer "org.spongepowered:mixin:${MIXIN_VERSION}"
installer 'org.openjdk.nashorn:nashorn-core:15.3'
installer "net.minecraftforge:JarJar:${JARJAR_VERSION}"
installer "net.minecraftforge:JarJarSelector:${JARJAR_VERSION}"
installer "net.minecraftforge:JarJarMetadata:${JARJAR_VERSION}"

// bukkit
moduleonly 'commons-lang:commons-lang:2.6'
Expand All @@ -247,12 +248,6 @@ def sharedDeps = {
installer 'org.lwjgl:lwjgl-opengl:3.2.2'
installer 'org.lwjgl:lwjgl-stb:3.2.2'
*/

autolibraries BIN_PATCHER
autolibraries SPECIAL_SOURCE
autolibraries INSTALLER_TOOLS
autolibraries JAR_SPLITTER
autolibraries FART
}

def sharedFmlonlyForge = { Project prj ->
Expand Down Expand Up @@ -393,6 +388,7 @@ def sharedFmlonlyForge = { Project prj ->
run.jvmArgs '--add-modules', 'ALL-MODULE-PATH'
// Additions to these JVM module args should be mirrored to server_files/args.txt and other similar blocks in the buildscript
run.jvmArgs '--add-opens', 'java.base/java.util.jar=cpw.mods.securejarhandler'
run.jvmArgs '--add-opens', 'java.base/java.lang.invoke=cpw.mods.securejarhandler'
run.jvmArgs '--add-exports', 'java.base/sun.security.util=cpw.mods.securejarhandler'
run.jvmArgs '--add-exports', 'jdk.naming.dns/com.sun.jndi.dns=java.naming'
}
Expand Down Expand Up @@ -606,6 +602,7 @@ project(':fmlonly') {
'--add-modules', 'ALL-MODULE-PATH',
// Additions to these JVM module args should be mirrored to server_files/args.txt and other similar blocks in the buildscript
'--add-opens', 'java.base/java.util.jar=cpw.mods.securejarhandler',
'--add-opens', 'java.base/java.lang.invoke=cpw.mods.securejarhandler',
'--add-exports', 'java.base/sun.security.util=cpw.mods.securejarhandler',
'--add-exports', 'jdk.naming.dns/com.sun.jndi.dns=java.naming'
]
Expand Down Expand Up @@ -1258,6 +1255,7 @@ project(':forge') {
'--add-modules', 'ALL-MODULE-PATH',
// Additions to these JVM module args should be mirrored to server_files/args.txt and other similar blocks in the buildscript
'--add-opens', 'java.base/java.util.jar=cpw.mods.securejarhandler',
'--add-opens', 'java.base/java.lang.invoke=cpw.mods.securejarhandler',
'--add-exports', 'java.base/sun.security.util=cpw.mods.securejarhandler',
'--add-exports', 'jdk.naming.dns/com.sun.jndi.dns=java.naming'
]
Expand Down
4 changes: 2 additions & 2 deletions buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ repositories {
mavenCentral()
}
dependencies {
implementation 'org.ow2.asm:asm:9.1'
implementation 'org.ow2.asm:asm-tree:9.1'
implementation 'org.ow2.asm:asm:9.5'
implementation 'org.ow2.asm:asm-tree:9.5'
implementation 'net.minecraftforge:srgutils:0.4.+'
implementation 'commons-io:commons-io:2.8.0'
implementation 'com.google.code.gson:gson:2.10'
Expand Down
3 changes: 2 additions & 1 deletion fmlloader/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ dependencies {
api('com.electronwill.night-config:toml:3.6.4')
api('cpw.mods:modlauncher:9.0.+')
api('net.minecraftforge:coremods:5.0.+')
api "net.minecraftforge:JarJar:${JARJAR_VERSION}"
api "net.minecraftforge:JarJarSelector:${JARJAR_VERSION}"
api "net.minecraftforge:JarJarMetadata:${JARJAR_VERSION}"
implementation("cpw.mods:securejarhandler:${SECUREJARHANDLER_VERSION}")
implementation('org.apache.logging.log4j:log4j-core:2.17.0')
annotationProcessor('org.apache.logging.log4j:log4j-core:2.17.0')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

package net.minecraftforge.fml.loading.moddiscovery;

import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import net.minecraftforge.fml.loading.EarlyLoadingException;
import net.minecraftforge.forgespi.language.IModInfo;
Expand All @@ -16,10 +17,15 @@
import org.apache.maven.artifact.versioning.VersionRange;
import org.jetbrains.annotations.NotNull;

import java.net.URI;
import java.nio.file.FileSystem;
import java.nio.file.FileSystems;
import java.nio.file.Path;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.Stream;

Expand All @@ -34,20 +40,16 @@ public String name()
}

@Override
public List<IModFile> scanMods(final Iterable<IModFile> loadedMods) {
public List<IModFile> scanMods(final Iterable<IModFile> loadedMods)
{
final List<IModFile> sources = Lists.newArrayList();
loadedMods.forEach(sources::add);


final List<IModFile> dependenciesToLoad = JarSelector.detectAndSelect(
sources,
this::loadResourceFromModFile,
this::loadModFileFrom,
this::identifyMod,
this::exception
);
final List<IModFile> dependenciesToLoad = JarSelector.detectAndSelect(sources, this::loadResourceFromModFile, this::loadModFileFrom, this::identifyMod, this::exception);

if (dependenciesToLoad.isEmpty()) {
if (dependenciesToLoad.isEmpty())
{
LOGGER.info("No dependencies to load found. Skipping!");
return Collections.emptyList();
}
Expand All @@ -68,46 +70,87 @@ protected String getDefaultJarModType()
return IModFile.Type.GAMELIBRARY.name();
}

@SuppressWarnings("resource")
@Override
protected Optional<IModFile> loadModFileFrom(final IModFile file, final Path path)
{
try
{
final Path pathInModFile = file.findResource(path.toString());
final URI filePathUri = new URI("jij:" + (pathInModFile.toAbsolutePath().toUri().getRawSchemeSpecificPart())).normalize();
final Map<String, ?> outerFsArgs = ImmutableMap.of("packagePath", pathInModFile);
final FileSystem zipFS = FileSystems.newFileSystem(filePathUri, outerFsArgs);
final Path pathInFS = zipFS.getPath("/");
return createMod(pathInFS);
}
catch (Exception e)
{
LOGGER.error("Failed to load mod file {} from {}", path, file.getFileName());

throw new RuntimeException("Failed to load mod file " + file.getFileName(), e);
}
}

protected EarlyLoadingException exception(Collection<JarSelector.ResolutionFailureInformation<IModFile>> failedDependencies)
{

final List<EarlyLoadingException.ExceptionData> errors = failedDependencies.stream()
.filter(entry -> !entry.sources().isEmpty()) //Should never be the case, but just to be sure
.map(entry -> new EarlyLoadingException.ExceptionData(
getErrorTranslationKey(entry),
entry.identifier().group() + ":" + entry.identifier().artifact(),
entry.sources()
.stream()
.flatMap(this::getModWithVersionRangeStream)
.map(this::formatError)
.collect(Collectors.joining(", ")))).toList();
.filter(entry -> !entry.sources().isEmpty()) //Should never be the case, but just to be sure
.map(this::buildExceptionData)
.toList();

return new EarlyLoadingException(failedDependencies.size() + " Dependency restrictions were not met.", null, errors);
}

@NotNull
private EarlyLoadingException.ExceptionData buildExceptionData(final JarSelector.ResolutionFailureInformation<IModFile> entry)
{
return new EarlyLoadingException.ExceptionData(
getErrorTranslationKey(entry),
entry.identifier().group() + ":" + entry.identifier().artifact(),
entry.sources()
.stream()
.flatMap(this::getModWithVersionRangeStream)
.map(this::formatError)
.collect(Collectors.joining(", "))
);
}

@NotNull
private String getErrorTranslationKey(final JarSelector.ResolutionFailureInformation<IModFile> entry)
{
return entry.failureReason() == JarSelector.FailureReason.VERSION_RESOLUTION_FAILED
? "fml.dependencyloading.conflictingdependencies"
: "fml.dependencyloading.mismatchedcontaineddependencies";
return entry.failureReason() == JarSelector.FailureReason.VERSION_RESOLUTION_FAILED ?
"fml.dependencyloading.conflictingdependencies" :
"fml.dependencyloading.mismatchedcontaineddependencies";
}

@NotNull
private Stream<ModWithVersionRange> getModWithVersionRangeStream(final JarSelector.SourceWithRequestedVersionRange<IModFile> file)
{
return file.sources().stream().map(IModFile::getModFileInfo)
return file.sources()
.stream()
.map(IModFile::getModFileInfo)
.flatMap(modFileInfo -> modFileInfo.getMods().stream())
.map(modInfo -> new ModWithVersionRange(modInfo, file.requestedVersionRange(), file.includedVersion()));
}

@NotNull
private String formatError(final ModWithVersionRange modWithVersionRange)
{
return "\u00a7e" + modWithVersionRange.modInfo().getModId() + "\u00a7r - \u00a74"
+ modWithVersionRange.versionRange().toString() + "\u00a74 - \u00a72"
+ modWithVersionRange.artifactVersion().toString() + "\u00a72";
return "\u00a7e" + modWithVersionRange.modInfo().getModId() + "\u00a7r - \u00a74" + modWithVersionRange.versionRange().toString() + "\u00a74 - \u00a72" + modWithVersionRange.artifactVersion().toString() + "\u00a72";
}

@Override
protected String identifyMod(final IModFile modFile)
{
if (modFile.getModFileInfo() == null || modFile.getModInfos().isEmpty())
{
return modFile.getFileName();
}

return modFile.getModInfos().stream().map(IModInfo::getModId).collect(Collectors.joining());
}

private record ModWithVersionRange(IModInfo modInfo, VersionRange versionRange, ArtifactVersion artifactVersion) {}
private record ModWithVersionRange(IModInfo modInfo, VersionRange versionRange, ArtifactVersion artifactVersion)
{}
}
1 change: 1 addition & 0 deletions foxlaunch/src/main/java/foxlaunch/DataManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public static void setup() {
librariesWithoutLaunchMap.put("minecraft_server.1.18.2.jar", new File("foxlaunch-data/"));
librariesWithoutLaunchMap.put("commons-lang-2.6.jar", new File("libraries/commons-lang/commons-lang/2.6/"));
librariesMap.put("bootstraplauncher-1.0.0.jar", new File("libraries/cpw/mods/bootstraplauncher/1.0.0/"));
librariesMap.put("JarJarFileSystems-0.3.19.jar", new File("libraries/net/minecraftforge/JarJarFileSystems/0.3.19/"));

versionData.put("minecraft", Objects.requireNonNull(serverJar.getManifest().getAttributes("net/minecraftforge/versions/mcp/").getValue(Attributes.Name.SPECIFICATION_VERSION)));
versionData.put("mcp", Objects.requireNonNull(serverJar.getManifest().getAttributes("net/minecraftforge/versions/mcp/").getValue(Attributes.Name.IMPLEMENTATION_VERSION)));
Expand Down
2 changes: 1 addition & 1 deletion foxlaunch/src/main/java/foxlaunch/FoxServerLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static void main(String[] args) throws Throwable {
LegacyLauncher.loadJars();

System.setProperty("java.net.preferIPv6Addresses", "system");
System.setProperty("ignoreList", "bootstraplauncher-1.0.0.jar,securejarhandler-1.0.3.jar,asm-commons-9.2.jar,asm-util-9.2.jar,asm-analysis-9.2.jar,asm-tree-9.2.jar,asm-9.2.jar");
System.setProperty("ignoreList", "bootstraplauncher-1.0.0.jar,securejarhandler-1.0.8.jar,asm-commons-9.5.jar,asm-util-9.5.jar,asm-analysis-9.5.jar,asm-tree-9.5.jar,asm-9.5.jar,JarJarFileSystems-0.3.19.jar");
System.setProperty("libraryDirectory", "libraries");
System.setProperty("legacyClassPath", String.join(Utils.isWindows() ? ";" : ":", DataManager.getLibrariesMap().entrySet().stream().map(entry -> entry.getValue().getAbsolutePath() + "/" + entry.getKey()).toArray(String[]::new)));

Expand Down
16 changes: 8 additions & 8 deletions foxlaunch/src/main/java/foxlaunch/legacy/InstallTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ public static boolean install(String minecraftVersion, String mcpVersion, String
Utils.pathToURL("libraries/net/md-5/SpecialSource/1.10.0/SpecialSource-1.10.0.jar"),
Utils.pathToURL("libraries/net/sf/jopt-simple/jopt-simple/5.0.4/jopt-simple-5.0.4.jar"),
Utils.pathToURL("libraries/com/google/guava/guava/31.0.1-jre/guava-31.0.1-jre.jar"),
Utils.pathToURL("libraries/org/ow2/asm/asm-commons/9.2/asm-commons-9.2.jar"),
Utils.pathToURL("libraries/org/ow2/asm/asm-analysis/9.2/asm-analysis-9.2.jar"),
Utils.pathToURL("libraries/org/ow2/asm/asm-tree/9.2/asm-tree-9.2.jar"),
Utils.pathToURL("libraries/org/ow2/asm/asm/9.2/asm-9.2.jar")
Utils.pathToURL("libraries/org/ow2/asm/asm-commons/9.5/asm-commons-9.5.jar"),
Utils.pathToURL("libraries/org/ow2/asm/asm-analysis/9.5/asm-analysis-9.5.jar"),
Utils.pathToURL("libraries/org/ow2/asm/asm-tree/9.5/asm-tree-9.5.jar"),
Utils.pathToURL("libraries/org/ow2/asm/asm/9.5/asm-9.5.jar")
};

URL[] libJarSplitter = new URL[] {
Expand All @@ -43,10 +43,10 @@ public static boolean install(String minecraftVersion, String mcpVersion, String
Utils.pathToURL("foxlaunch-libs/ForgeAutoRenamingTool-0.1.22.jar"),
Utils.pathToURL("foxlaunch-libs/srgutils-0.4.11.jar"),
Utils.pathToURL("libraries/net/sf/jopt-simple/jopt-simple/5.0.4/jopt-simple-5.0.4.jar"),
Utils.pathToURL("libraries/org/ow2/asm/asm-commons/9.2/asm-commons-9.2.jar"),
Utils.pathToURL("libraries/org/ow2/asm/asm-analysis/9.2/asm-analysis-9.2.jar"),
Utils.pathToURL("libraries/org/ow2/asm/asm-tree/9.2/asm-tree-9.2.jar"),
Utils.pathToURL("libraries/org/ow2/asm/asm/9.2/asm-9.2.jar")
Utils.pathToURL("libraries/org/ow2/asm/asm-commons/9.5/asm-commons-9.5.jar"),
Utils.pathToURL("libraries/org/ow2/asm/asm-analysis/9.5/asm-analysis-9.5.jar"),
Utils.pathToURL("libraries/org/ow2/asm/asm-tree/9.5/asm-tree-9.5.jar"),
Utils.pathToURL("libraries/org/ow2/asm/asm/9.5/asm-9.5.jar")
};

URL[] libBinaryPatcher = new URL[] {
Expand Down
16 changes: 10 additions & 6 deletions foxlaunch/src/main/java/foxlaunch/legacy/LegacyLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,19 @@ public static boolean setup() {
}

public static void loadJars() throws Exception {
JVMHack.addModuleDynamic("libraries/org/ow2/asm/asm/9.2/asm-9.2.jar");
JVMHack.addModuleDynamic("libraries/org/ow2/asm/asm-tree/9.2/asm-tree-9.2.jar");
JVMHack.addModuleDynamic("libraries/org/ow2/asm/asm-analysis/9.2/asm-analysis-9.2.jar");
JVMHack.addModuleDynamic("libraries/org/ow2/asm/asm-util/9.2/asm-util-9.2.jar");
JVMHack.addModuleDynamic("libraries/org/ow2/asm/asm-commons/9.2/asm-commons-9.2.jar");
JVMHack.addModuleDynamic("libraries/cpw/mods/securejarhandler/1.0.3/securejarhandler-1.0.3.jar");
JVMHack.addModuleDynamic("libraries/org/ow2/asm/asm/9.5/asm-9.5.jar");
JVMHack.addModuleDynamic("libraries/org/ow2/asm/asm-tree/9.5/asm-tree-9.5.jar");
JVMHack.addModuleDynamic("libraries/org/ow2/asm/asm-analysis/9.5/asm-analysis-9.5.jar");
JVMHack.addModuleDynamic("libraries/org/ow2/asm/asm-util/9.5/asm-util-9.5.jar");
JVMHack.addModuleDynamic("libraries/org/ow2/asm/asm-commons/9.5/asm-commons-9.5.jar");
JVMHack.addModuleDynamic("libraries/cpw/mods/securejarhandler/1.0.8/securejarhandler-1.0.8.jar");
JVMHack.addModuleDynamic("libraries/cpw/mods/bootstraplauncher/1.0.0/bootstraplauncher-1.0.0.jar");
JVMHack.addModuleDynamic("libraries/net/minecraftforge/JarJarFileSystems/0.3.19/JarJarFileSystems-0.3.19.jar");

JVMHack.addModuleOptionDynamic("addExportsToAllUnnamed", "cpw.mods.bootstraplauncher", "cpw.mods.bootstraplauncher", null);
JVMHack.addModuleOptionDynamic("addOpens", "java.base", "java.util.jar", "cpw.mods.securejarhandler");
JVMHack.addModuleOptionDynamic("addOpens", "java.base", "java.lang.invoke", "cpw.mods.securejarhandler");
JVMHack.addModuleOptionDynamic("addExports", "java.base", "sun.security.util", "cpw.mods.securejarhandler");

JarLoader.loadJar(new File("libraries/commons-lang/commons-lang/2.6/commons-lang-2.6.jar"));
}
Expand Down
Loading

0 comments on commit 6c3f596

Please sign in to comment.