mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-12 16:27:47 +00:00
26.1 Update
Minecraft is now Unobfuscated and requires Java 25 Lots of changes/code cleanup. See https://github.com/MinecraftForge/MinecraftForge-Experimental/tree/26.1-dev for non-squashed commits. Co-authored-by: Paint_Ninja <PaintNinja@users.noreply.github.com>
This commit is contained in:
1558 files changed
+11117
-16291
No files matched your search
@@ -2,7 +2,7 @@ name: Publish
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ '1.21.11' ]
|
||||
branches: [ '26.1' ]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
@@ -46,3 +46,4 @@ src/*/generated/**/.cache/
|
||||
/*/.gitignore
|
||||
/*/.factorypath
|
||||
/*/.apt_generated/
|
||||
/fmlcore/logs/
|
||||
+6
-3
@@ -7,10 +7,10 @@ plugins {
|
||||
id 'net.minecraftforge.gradleutils' version '[2.6.4,2.7)'
|
||||
id 'eclipse'
|
||||
id 'de.undercouch.download' version '5.4.0'
|
||||
id 'net.minecraftforge.gradle.patcher' version '[6.0.46,6.2)' apply false
|
||||
id 'net.minecraftforge.gradle.mcp' version '[6.0.46,6.2)' apply false
|
||||
id 'net.minecraftforge.gradle.patcher' version '[6.0.51,6.2)' apply false
|
||||
id 'net.minecraftforge.gradle.mcp' version '[6.0.51,6.2)' apply false
|
||||
id 'net.minecraftforge.gradlejarsigner' version '1.0.4'
|
||||
id 'org.barfuin.gradle.taskinfo' version '2.1.0'
|
||||
id 'org.barfuin.gradle.taskinfo' version '3.0.1'
|
||||
}
|
||||
|
||||
Util.init() //Init all our extension methods!
|
||||
@@ -41,6 +41,9 @@ project(':mcp') {
|
||||
config MC_VERSION + '-' + MCP_VERSION
|
||||
pipeline = 'joined'
|
||||
}
|
||||
repositories {
|
||||
mavenLocal()
|
||||
}
|
||||
}
|
||||
|
||||
if (System.env.TEAMCITY_VERSION) {
|
||||
|
||||
@@ -4,8 +4,8 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'org.ow2.asm:asm:9.8'
|
||||
implementation 'org.ow2.asm:asm-tree:9.8'
|
||||
implementation 'org.ow2.asm:asm:9.9.1'
|
||||
implementation 'org.ow2.asm:asm-tree:9.9.1'
|
||||
implementation 'net.minecraftforge:srgutils:0.6.2'
|
||||
implementation 'net.minecraftforge:JarJarMetadata:0.3.27'
|
||||
implementation 'commons-io:commons-io:2.13.0'
|
||||
|
||||
@@ -10,13 +10,11 @@ import java.util.zip.ZipFile
|
||||
|
||||
abstract class BundleList extends DefaultTask {
|
||||
@InputFiles abstract ConfigurableFileCollection getConfig()
|
||||
@InputFiles abstract ConfigurableFileCollection getConfigExtra()
|
||||
@InputFile abstract RegularFileProperty getServerBundle()
|
||||
@OutputFile abstract RegularFileProperty getOutput()
|
||||
|
||||
BundleList() {
|
||||
config.setFrom(project.configurations.installer)
|
||||
configExtra.setFrom(project.configurations.installerextra)
|
||||
output.convention(project.layout.buildDirectory.file("$name/output.list"))
|
||||
configure {
|
||||
dependsOn(project.tasks.universalJar)
|
||||
@@ -36,13 +34,6 @@ abstract class BundleList extends DefaultTask {
|
||||
entries.put("$info.art.group:$info.art.name", "$dep.file.sha256\t$info.name\t$info.path")
|
||||
}
|
||||
|
||||
resolved = project.configurations.installerextra.resolvedConfiguration.resolvedArtifacts
|
||||
for (def dep : resolved) {
|
||||
def info = Util.getMavenInfoFromDep(dep)
|
||||
//println("$dep.file.sha1\t$info.name\t$info.path")
|
||||
entries.put("$info.art.group:$info.art.name", "$dep.file.sha256\t$info.name\t$info.path")
|
||||
}
|
||||
|
||||
var packed = (AbstractArchiveTask) project.tasks.universalJar
|
||||
var info = Util.getMavenInfoFromTask(packed)
|
||||
def file = packed.archiveFile.get().asFile
|
||||
|
||||
@@ -24,7 +24,6 @@ abstract class LauncherJson extends DefaultTask {
|
||||
dependsOn(project.tasks.universalJar)
|
||||
input.from(project.tasks.universalJar.archiveFile)
|
||||
input.from(project.configurations.installer)
|
||||
input.from(project.configurations.installerextra)
|
||||
configure {
|
||||
def mc = project.rootProject.ext.MC_VERSION
|
||||
def forge = project.rootProject.ext.FORGE_VERSION
|
||||
@@ -89,7 +88,6 @@ abstract class LauncherJson extends DefaultTask {
|
||||
]
|
||||
])
|
||||
|
||||
json.libraries.addAll(getArtifacts(project.configurations.installerextra).values())
|
||||
json.libraries.addAll(getArtifacts(project.configurations.installer).values())
|
||||
Files.writeString(output.get().asFile.toPath(), new JsonBuilder(json).toPrettyString())
|
||||
}
|
||||
|
||||
@@ -17,17 +17,15 @@ abstract class CheckATs extends CheckTask {
|
||||
|
||||
@InputFile abstract RegularFileProperty getInheritance()
|
||||
@InputFiles abstract ConfigurableFileCollection getAts()
|
||||
@InputFile @Optional abstract RegularFileProperty getMappings()
|
||||
|
||||
@Override
|
||||
void check(Reporter reporter, boolean fix) {
|
||||
final IMappingFile mappings = mappings.map { RegularFile it -> IMappingFile.load(it.asFile) }.getOrNull()
|
||||
final inheritance = InheritanceData.parse(this.inheritance.get().asFile)
|
||||
|
||||
ats.each {
|
||||
final lines = process(it, reporter, inheritance)
|
||||
if (fix) {
|
||||
it.text = joinBack(lines, inheritance, mappings).join('\n')
|
||||
it.text = joinBack(lines, inheritance).join('\n')
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -170,45 +168,18 @@ abstract class CheckATs extends CheckTask {
|
||||
return lines
|
||||
}
|
||||
|
||||
private static List<String> joinBack(TreeMap<String, ATParser.Entry> lines, Map<String, InheritanceData> inheritance, IMappingFile mappings) {
|
||||
private static List<String> joinBack(TreeMap<String, ATParser.Entry> lines, Map<String, InheritanceData> inheritance) {
|
||||
final data = [] as List<String>
|
||||
final remapComment = { ATParser.Entry entry ->
|
||||
if (!mappings || !entry || !entry.desc) return null
|
||||
final comment = entry.comment?.substring(1)?.trim()
|
||||
final jsonCls = inheritance.get(entry.cls.replaceAll('\\.', '/'))
|
||||
final mappingsClass = mappings?.getClass(jsonCls.name)
|
||||
if (mappingsClass === null) return entry.comment
|
||||
final idx = entry.desc.indexOf('(')
|
||||
|
||||
String mappedName = idx == -1
|
||||
? mappingsClass.remapField(entry.desc)
|
||||
: mappingsClass.remapMethod(entry.desc.substring(0, idx), entry.desc.substring(idx))
|
||||
if (!mappedName) return entry.comment
|
||||
if (mappedName == '<init>')
|
||||
mappedName = 'constructor'
|
||||
|
||||
if (comment?.startsWith(mappedName))
|
||||
return '# ' + comment
|
||||
if (comment && comment.indexOf(' ') !== -1) {
|
||||
def split = comment.split(' - ').toList()
|
||||
if (split[0].indexOf(' ') !== -1)
|
||||
// The first string is more than one word, so append before it
|
||||
return "# ${mappedName} - ${comment}"
|
||||
split.remove(0)
|
||||
return "# ${mappedName} - ${String.join(' - ', split)}"
|
||||
}
|
||||
return '# ' + mappedName
|
||||
}
|
||||
lines.each { key, value ->
|
||||
if (!value.group) {
|
||||
def comment = remapComment.call(value)
|
||||
def comment = null //value.comment
|
||||
data.add(value.modifier + ' ' + key + (comment ? ' ' + comment : ''))
|
||||
} else {
|
||||
data.add(('#group ' + value.modifier + ' ' + key + ' ' + (value.comment ?: '')).trim())
|
||||
value.children.each {
|
||||
final line = value.modifier + ' ' + it
|
||||
final entry = ATParser.parseEntry(line)
|
||||
final comment = remapComment(entry)
|
||||
final comment = null //entry.comment
|
||||
data.add(line + (comment ? ' ' + comment : ''))
|
||||
}
|
||||
data.add('#endgroup')
|
||||
|
||||
+40
-141
@@ -89,7 +89,7 @@ ext {
|
||||
final String MAVEN_PATH = ext.MAVEN_PATH
|
||||
|
||||
final String BINPATCH_TOOL = 'net.minecraftforge:binarypatcher:1.2.0:fatjar'
|
||||
final String INSTALLER_TOOLS = 'net.minecraftforge:installertools:1.4.3'
|
||||
final String INSTALLER_TOOLS = 'net.minecraftforge:installertools:1.4.5'
|
||||
final String FART = 'net.minecraftforge:ForgeAutoRenamingTool:1.0.6'
|
||||
final String S2S_TOOL = 'net.minecraftforge:Srg2Source:8.2.0:fatjar'
|
||||
|
||||
@@ -100,10 +100,6 @@ configurations {
|
||||
extendsFrom(bootstrap)
|
||||
transitive = false
|
||||
}
|
||||
installerextra {
|
||||
extendsFrom(bootstrap)
|
||||
transitive = false
|
||||
}
|
||||
api.extendsFrom(installer)
|
||||
}
|
||||
|
||||
@@ -145,8 +141,6 @@ dependencies {
|
||||
installer(project(':mclanguage'))
|
||||
installer(project(':forge-transformers'))
|
||||
|
||||
installerextra("${MCP_ARTIFACT.group}:${MCP_ARTIFACT.name}:${MCP_ARTIFACT.version}:srg2off")
|
||||
|
||||
runtimeOnly(libs.bootstrap)
|
||||
runtimeOnly(libs.bootstrap.dev)
|
||||
|
||||
@@ -163,6 +157,11 @@ tasks.named('applyRangeMapBase').configure {
|
||||
tool = S2S_TOOL
|
||||
}
|
||||
|
||||
// Disable all tests, we have GameTests not JUnit tests
|
||||
test {
|
||||
exclude '**/*'
|
||||
}
|
||||
|
||||
patcher {
|
||||
excs.from file("$rootDir/src/main/resources/forge.exc")
|
||||
parent = project(':mcp')
|
||||
@@ -270,21 +269,6 @@ afterEvaluate {
|
||||
userdevJar {
|
||||
onlyIf = { t -> true }
|
||||
}
|
||||
def patches = project.file('build/genPatchesForUserdev/output/')
|
||||
patches.mkdirs()
|
||||
def genPatchesForUserdev = tasks.register('genPatchesForUserdev', GeneratePatches){
|
||||
base = project(':mcp').setupMCP.output
|
||||
modified = applyRangeMapBase.output
|
||||
originalPrefix = genPatches.originalPrefix
|
||||
modifiedPrefix = genPatches.modifiedPrefix
|
||||
output = patches
|
||||
autoHeader true
|
||||
lineEnding = '\n'
|
||||
}
|
||||
bakePatches {
|
||||
dependsOn = []
|
||||
input = genPatchesForUserdev.get().output
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -351,7 +335,7 @@ for (def run in patcher.runs + tasks.userdevConfig.runs) {
|
||||
if (run.parents) continue // We already added this to the parent run config
|
||||
//run.property 'bsl.debug', 'true'
|
||||
run.args '--gameDir', '.'
|
||||
run.jvmArgs '-Djava.net.preferIPv6Addresses=system'
|
||||
run.jvmArgs '-Djava.net.preferIPv6Addresses=system', '-XX:+UseCompactObjectHeaders'
|
||||
run.client run.name.contains('client')
|
||||
run.main 'net.minecraftforge.bootstrap.ForgeBootstrap'
|
||||
}
|
||||
@@ -424,7 +408,8 @@ tasks.register('extractInheritance', ExtractInheritance) {
|
||||
}
|
||||
}
|
||||
tasks.register("findFinalizeSpawnTargets", BytecodePredicateFinder) {
|
||||
jar = createClientOfficial.output
|
||||
dependsOn downloadClientRaw
|
||||
jar = downloadClientRaw.dest
|
||||
output = rootProject.file('forge-transformers/src/main/resources/coremods/finalize_spawn_targets.json')
|
||||
predicate = {
|
||||
parent, node, insn ->
|
||||
@@ -449,60 +434,37 @@ tasks.register("downloadServerShim", DownloadMavenArtifact) {
|
||||
artifact = libs.bootstrap.shim.get().toString()
|
||||
changing = true
|
||||
}
|
||||
tasks.register('downloadClientMappings', net.minecraftforge.gradle.common.tasks.JarExec) {
|
||||
ext.output = file('build/client_mappings.tsrg')
|
||||
tool = INSTALLER_TOOLS + ':fatjar'
|
||||
args = ['--task', 'DOWNLOAD_MOJMAPS', '--sanitize', '--version', MC_VERSION, '--side', 'client', '--output', output.absolutePath]
|
||||
outputs.file(output)
|
||||
}
|
||||
tasks.register('downloadServerMappings', net.minecraftforge.gradle.common.tasks.JarExec) {
|
||||
ext.output = file('build/server_mappings.tsrg')
|
||||
tool = INSTALLER_TOOLS + ':fatjar'
|
||||
args = ['--task', 'DOWNLOAD_MOJMAPS', '--sanitize', '--version', MC_VERSION, '--side', 'server', '--output', output.absolutePath]
|
||||
outputs.file(output)
|
||||
}
|
||||
tasks.register("createJoinedSRG", DownloadMavenArtifact) {
|
||||
artifact = "net.minecraft:joined:${MC_VERSION}-${MCP_VERSION}:srg"
|
||||
}
|
||||
tasks.register("createClientOfficial", RenameJar) {
|
||||
tool = FART + ':all'
|
||||
args = ['--input', '{input}', '--output', '{output}', '--names', '{mappings}', '--ann-fix', '--ids-fix', '--src-fix', '--record-fix', '--strip-sigs', '--reverse']
|
||||
mappings = downloadClientMappings.output
|
||||
dependsOn(downloadClientRaw, downloadClientMappings)
|
||||
input = downloadClientRaw.dest
|
||||
output = file("build/createClientOfficial/output.jar")
|
||||
}
|
||||
tasks.register("createServerOfficial", RenameJar) {
|
||||
tool = FART + ':all'
|
||||
args = ['--input', '{input}', '--output', '{output}', '--names', '{mappings}', '--ann-fix', '--ids-fix', '--src-fix', '--record-fix', '--strip-sigs', '--reverse']
|
||||
mappings = downloadServerMappings.output
|
||||
dependsOn(downloadServerMappings)
|
||||
input = extractServer.output
|
||||
output = file("build/createServerOfficial/output.jar")
|
||||
artifact = "net.minecraft:joined:${MC_VERSION}-${MCP_VERSION}"
|
||||
}
|
||||
tasks.named('genClientBinPatches').configure {
|
||||
dependsOn(downloadClientRaw)
|
||||
tool = BINPATCH_TOOL
|
||||
cleanJar = createClientOfficial.output
|
||||
cleanJar = downloadClientRaw.dest
|
||||
dirtyJar = jar.archiveFile
|
||||
}
|
||||
tasks.named('genServerBinPatches').configure {
|
||||
dependsOn(extractServer)
|
||||
tool = BINPATCH_TOOL
|
||||
cleanJar = createServerOfficial.output
|
||||
cleanJar = extractServer.output
|
||||
dirtyJar = jar.archiveFile
|
||||
}
|
||||
tasks.named('genJoinedBinPatches').configure {
|
||||
tool = BINPATCH_TOOL
|
||||
cleanJar = createJoinedSRG.output
|
||||
dirtyJar = jar.archiveFile
|
||||
}
|
||||
tasks.register('applyClientBinPatches', ApplyBinPatches) {
|
||||
dependsOn downloadClientRaw
|
||||
tool = BINPATCH_TOOL
|
||||
clean = createClientOfficial.output
|
||||
clean = downloadClientRaw.dest
|
||||
patch = genClientBinPatches.output
|
||||
args.addAll(['--data', '--unpatched'])
|
||||
}
|
||||
tasks.register('applyServerBinPatches', ApplyBinPatches) {
|
||||
dependsOn extractServer
|
||||
tool = BINPATCH_TOOL
|
||||
clean = createServerOfficial.output
|
||||
clean = extractServer.output
|
||||
patch = genServerBinPatches.output
|
||||
args.addAll(['--data', '--unpatched'])
|
||||
}
|
||||
@@ -520,7 +482,7 @@ tasks.register('createServerShimConfig') {
|
||||
doLast {
|
||||
var cfg = new CleanProperties()
|
||||
cfg['Main-Class'] = 'net.minecraftforge.bootstrap.ForgeBootstrap'
|
||||
cfg['Java-Version'] = '21'
|
||||
cfg['Java-Version'] = '25'
|
||||
cfg['Arguments'] = '--launchTarget forge_server'
|
||||
cfg.store(output)
|
||||
}
|
||||
@@ -552,10 +514,9 @@ tasks.register('checkAllAndFix') {
|
||||
}
|
||||
|
||||
CheckTask.registerTask(tasks, 'ATs', CheckATs) {
|
||||
dependsOn extractInheritance, createSrg2Mcp
|
||||
dependsOn extractInheritance
|
||||
ats.from patcher.accessTransformers
|
||||
inheritance = extractInheritance.output
|
||||
mappings = createSrg2Mcp.output
|
||||
}
|
||||
|
||||
CheckTask.registerTask(tasks, 'SAS', CheckSAS) {
|
||||
@@ -642,7 +603,8 @@ tasks.register('launcherJson', LauncherJson).configure {
|
||||
'--launchTarget', 'forge_client'
|
||||
],
|
||||
jvm: [
|
||||
'-Djava.net.preferIPv6Addresses=system'
|
||||
'-Djava.net.preferIPv6Addresses=system',
|
||||
'-XX:+UseCompactObjectHeaders'
|
||||
]
|
||||
]
|
||||
] as LinkedHashMap)
|
||||
@@ -655,15 +617,9 @@ tasks.register('installerJson', InstallerJson) {
|
||||
dependsOn(launcherJson)
|
||||
input.from(launcherJson.output)
|
||||
|
||||
// Download Official Mappings
|
||||
dependsOn(downloadClientMappings, downloadServerMappings)
|
||||
input.from(downloadClientMappings.output, downloadServerMappings.output)
|
||||
// Get 'base' MC jar, Client is straight download, server is extracted from the bundle
|
||||
dependsOn(downloadClientRaw, extractServer)
|
||||
input.from(downloadClientRaw.dest, extractServer.output)
|
||||
// Rename MC Jar
|
||||
dependsOn(createClientOfficial, createServerOfficial)
|
||||
input.from(createClientOfficial.output, createServerOfficial.output)
|
||||
// Apply Binary patches to vanilla jar
|
||||
dependsOn(applyClientBinPatches, applyServerBinPatches)
|
||||
input.from(applyClientBinPatches.output, applyServerBinPatches.output, genClientBinPatches.toolJar)
|
||||
@@ -681,14 +637,6 @@ tasks.register('installerJson', InstallerJson) {
|
||||
minecraft: MC_VERSION,
|
||||
serverJarPath: '{LIBRARY_DIR}/net/minecraft/server/{MINECRAFT_VERSION}/server-{MINECRAFT_VERSION}-bundled.jar',
|
||||
data: [
|
||||
MOJMAPS: [
|
||||
client: "[net.minecraft:client:${MC_VERSION}:mappings@tsrg]",
|
||||
server: "[net.minecraft:server:${MC_VERSION}:mappings@tsrg]"
|
||||
],
|
||||
MOJMAPS_SHA: [
|
||||
client: "'${downloadClientMappings.output.sha1}'",
|
||||
server: "'${downloadServerMappings.output.sha1}'"
|
||||
],
|
||||
MC_UNPACKED: [
|
||||
client: "[net.minecraft:client:${MC_VERSION}]",
|
||||
server: "[net.minecraft:server:${MC_VERSION}:unpacked]"
|
||||
@@ -697,14 +645,6 @@ tasks.register('installerJson', InstallerJson) {
|
||||
client: "'${downloadClientRaw.dest.sha1}'",
|
||||
server: "'${extractServer.output.get().asFile.sha1}'"
|
||||
],
|
||||
MC_OFF: [
|
||||
client: "[net.minecraft:client:${MC_VERSION}:official]",
|
||||
server: "[net.minecraft:server:${MC_VERSION}:official]"
|
||||
],
|
||||
MC_OFF_SHA: [
|
||||
client: "'${createClientOfficial.output.get().asFile.sha1}'",
|
||||
server: "'${createServerOfficial.output.get().asFile.sha1}'"
|
||||
],
|
||||
BINPATCH: [
|
||||
client: '/data/client.lzma',
|
||||
server: '/data/server.lzma'
|
||||
@@ -770,50 +710,25 @@ tasks.register('installerJson', InstallerJson) {
|
||||
outputs: [
|
||||
'{MC_UNPACKED}': '{MC_UNPACKED_SHA}'
|
||||
]
|
||||
], [
|
||||
jar: INSTALLER_TOOLS,
|
||||
classpath: INSTALLER_TOOLS_CLASSPATH,
|
||||
args: [
|
||||
'--task', 'DOWNLOAD_MOJMAPS',
|
||||
'--sanitize',
|
||||
'--version', MC_VERSION,
|
||||
'--side', '{SIDE}',
|
||||
'--output', '{MOJMAPS}'
|
||||
],
|
||||
outputs: [
|
||||
'{MOJMAPS}': '{MOJMAPS_SHA}'
|
||||
]
|
||||
], [
|
||||
sides: ['server'],
|
||||
jar: FART,
|
||||
classpath: getClasspath(project, libs, FART),
|
||||
args: [
|
||||
'--input', '{MC_UNPACKED}',
|
||||
'--output', '{MC_OFF}',
|
||||
'--names', '{MOJMAPS}',
|
||||
'--ann-fix', '--ids-fix', '--src-fix', '--record-fix', '--strip-sigs', '--reverse'
|
||||
],
|
||||
outputs: [
|
||||
'{MC_OFF}': '{MC_OFF_SHA}'
|
||||
]
|
||||
], [
|
||||
sides: ['client'],
|
||||
jar: FART,
|
||||
classpath: getClasspath(project, libs, FART),
|
||||
args: [
|
||||
'--input', '{MINECRAFT_JAR}',
|
||||
'--output', '{MC_OFF}',
|
||||
'--names', '{MOJMAPS}',
|
||||
'--ann-fix', '--ids-fix', '--src-fix', '--record-fix', '--strip-sigs', '--reverse'
|
||||
],
|
||||
outputs: [
|
||||
'{MC_OFF}': '{MC_OFF_SHA}'
|
||||
]
|
||||
], [
|
||||
jar: BINPATCH_TOOL.rsplit(':', 1)[0], // remove :fatjar
|
||||
classpath: getClasspath(project, libs, BINPATCH_TOOL.rsplit(':', 1)[0]),
|
||||
args: [
|
||||
'--clean', '{MC_OFF}',
|
||||
'--clean', '{MC_UNPACKED}',
|
||||
'--output', '{PATCHED}',
|
||||
'--apply', '{BINPATCH}',
|
||||
'--data', '--unpatched'
|
||||
],
|
||||
outputs: [
|
||||
'{PATCHED}': '{PATCHED_SHA}'
|
||||
]
|
||||
], [
|
||||
sides: ['client'],
|
||||
jar: BINPATCH_TOOL.rsplit(':', 1)[0], // remove :fatjar
|
||||
classpath: getClasspath(project, libs, BINPATCH_TOOL.rsplit(':', 1)[0]),
|
||||
args: [
|
||||
'--clean', '{MINECRAFT_JAR}',
|
||||
'--output', '{PATCHED}',
|
||||
'--apply', '{BINPATCH}',
|
||||
'--data', '--unpatched'
|
||||
@@ -841,12 +756,7 @@ tasks.register('officialClassesOnly', Zip).configure {
|
||||
tasks.named('filterJarNew').configure {
|
||||
dependsOn('officialClassesOnly')
|
||||
input = officialClassesOnly.archiveFile
|
||||
}
|
||||
|
||||
tasks.register('filterJarNewSRG', FilterNewJar).configure {
|
||||
input = reobfJar.output
|
||||
srg = filterJarNew.srg
|
||||
blacklist = filterJarNew.blacklist
|
||||
filterInners = true
|
||||
}
|
||||
|
||||
tasks.named('universalJar').configure {
|
||||
@@ -883,18 +793,8 @@ tasks.named('universalJar').configure {
|
||||
jarSigner.sign(it)
|
||||
}
|
||||
|
||||
tasks.register('universalJarSrg', Jar).configure {
|
||||
from zipTree(filterJarNewSRG.output)
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
from zipTree(universalJar.archiveFile)
|
||||
destinationDirectory = file('build/libs')
|
||||
archiveClassifier = 'universal-srg'
|
||||
manifest.from(universalJar.manifest)
|
||||
jarSigner.sign(it)
|
||||
}
|
||||
|
||||
tasks.named('userdevConfig').configure {
|
||||
universal = "$project.group:$project.name:$project.version:universal-srg@jar"
|
||||
universal = "$project.group:$project.name:$project.version:universal@jar"
|
||||
}
|
||||
|
||||
tasks.register('installerJar', InstallerJar) {
|
||||
@@ -1001,7 +901,7 @@ license {
|
||||
}
|
||||
|
||||
tasks.register('genAllData') {
|
||||
dependsOn 'forge_data', 'forge_test_data'
|
||||
dependsOn 'forge_data', 'forge_data_test', 'forge_client_data_test'
|
||||
}
|
||||
|
||||
if (project.hasProperty('UPDATE_MAPPINGS')) {
|
||||
@@ -1095,7 +995,6 @@ tasks.named('javadoc', Javadoc).configure {
|
||||
publishing {
|
||||
publications.register('mavenJava', MavenPublication).configure {
|
||||
artifact universalJar
|
||||
artifact universalJarSrg
|
||||
artifact installerJar
|
||||
artifact mdkZip
|
||||
artifact userdevJar
|
||||
|
||||
+9
-7
@@ -3,7 +3,7 @@
|
||||
MinecraftForge
|
||||
=============
|
||||
[][Download]
|
||||
[][Download] [][Discord] [][Patreon]
|
||||
|
||||
Forge is a free, open-source modding API all of your favourite mods use!
|
||||
@@ -34,12 +34,13 @@ For support and questions, visit [the Support Forum][Support-Forum] or [the Forg
|
||||
|
||||
We require the version of Java that Minecraft requires, which is currently:
|
||||
|
||||
| Minecraft | Java |
|
||||
|---------------|-------------------|
|
||||
| 1.20.6+ | [21][Adoptium-21] |
|
||||
| 1.18 - 1.20.4 | [17][Adoptium-17] |
|
||||
| 1.17.1 | [16][Adoptium-16] |
|
||||
| 1.16.5- | [8][Adoptium-8] |
|
||||
| Minecraft | Java |
|
||||
|------------------|-------------------|
|
||||
| 26.1+ | [25][Adoptium-25] |
|
||||
| 1.20.6 - 1.21.11 | [21][Adoptium-21] |
|
||||
| 1.18 - 1.20.4 | [17][Adoptium-17] |
|
||||
| 1.17.1 | [16][Adoptium-16] |
|
||||
| 1.16.5- | [8][Adoptium-8] |
|
||||
|
||||
**If you are on Windows and have difficulty using Java to launch JAR files, consider using [Jarfix by Johann Löfflmann][Jarfix].**
|
||||
|
||||
@@ -80,6 +81,7 @@ YourKit for providing us accesss to their [YourKit Java Profiler] which helps id
|
||||
|
||||
[Download]: https://files.minecraftforge.net/
|
||||
|
||||
[Adoptium-25]: https://adoptium.net/temurin/releases/?version=25
|
||||
[Adoptium-21]: https://adoptium.net/temurin/releases/?version=21
|
||||
[Adoptium-17]: https://adoptium.net/temurin/releases/?version=17
|
||||
[Adoptium-16]: https://adoptium.net/temurin/releases/?version=16
|
||||
|
||||
@@ -1,273 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.fml;
|
||||
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.fml.loading.FMLEnvironment;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.lang.invoke.SerializedLambda;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Use to execute code conditionally based on sidedness.
|
||||
* <ul>
|
||||
* <li>When you want to call something on one side and return a result {@link #safeCallWhenOn(Dist, Supplier)}</li>
|
||||
* <li>When you want to call one thing on one side, another thing on the other and return a result {@link #safeRunForDist(Supplier, Supplier)}</li>
|
||||
* <li>When you want to run something on one side {@link #safeRunWhenOn(Dist, Supplier)}</li>
|
||||
* </ul>
|
||||
*
|
||||
* @deprecated Historically, this allowed for safe execution of code on the correct side by exploiting a low-level
|
||||
* detail in Java 8, but in newer versions a simple if check is enough.
|
||||
* <br>
|
||||
* For example:
|
||||
* <pre>{@code
|
||||
* if (FMLEnvironment.dist.isClient()) {
|
||||
* // client code here
|
||||
* }
|
||||
* }</pre>
|
||||
*/
|
||||
@Deprecated(since = "1.21.5", forRemoval = true)
|
||||
public final class DistExecutor
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
private DistExecutor() {}
|
||||
|
||||
/**
|
||||
* Run the callable in the supplier only on the specified {@link Dist}.
|
||||
* This method is NOT sided-safe and special care needs to be taken in code using this method that implicit class
|
||||
* loading is not triggered by the Callable.
|
||||
*
|
||||
* This method can cause unexpected ClassNotFound exceptions.
|
||||
*
|
||||
* Use {@link #safeCallWhenOn(Dist, Supplier)} where possible.
|
||||
*
|
||||
* @param dist The dist to run on
|
||||
* @param toRun A supplier of the callable to run (Supplier wrapper to ensure classloading only on the appropriate dist)
|
||||
* @param <T> The return type from the callable
|
||||
* @return The callable's result
|
||||
* @deprecated use {@link #safeCallWhenOn(Dist, Supplier)} instead. This remains for advanced use cases.
|
||||
*/
|
||||
@Deprecated
|
||||
public static <T> T callWhenOn(Dist dist, Supplier<Callable<T>> toRun) {
|
||||
return unsafeCallWhenOn(dist, toRun);
|
||||
}
|
||||
|
||||
public static <T> T unsafeCallWhenOn(Dist dist, Supplier<Callable<T>> toRun) {
|
||||
if (dist == FMLEnvironment.dist) {
|
||||
try
|
||||
{
|
||||
return toRun.get().call();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Call the SafeCallable when on the correct {@link Dist}.
|
||||
*
|
||||
* <strong>The lambda supplied here is required to be a method reference to a method defined in
|
||||
* another class, otherwise an invalid SafeReferent error will be thrown</strong>
|
||||
* @param dist the dist which this will run on
|
||||
* @param toRun the SafeCallable to run and return the result from
|
||||
* @param <T> The type of the SafeCallable
|
||||
* @return the result of the SafeCallable or null if on the wrong side
|
||||
*/
|
||||
public static <T> T safeCallWhenOn(Dist dist, Supplier<SafeCallable<T>> toRun) {
|
||||
validateSafeReferent(toRun);
|
||||
return callWhenOn(dist, toRun::get);
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs the supplied Runnable on the speicified side. Same warnings apply as {@link #callWhenOn(Dist, Supplier)}.
|
||||
*
|
||||
* This method can cause unexpected ClassNotFound exceptions.
|
||||
*
|
||||
* @see #callWhenOn(Dist, Supplier)
|
||||
* @param dist Dist to run this code on
|
||||
* @param toRun The code to run
|
||||
* @deprecated use {@link #safeRunWhenOn(Dist, Supplier)} where possible. Advanced uses only.
|
||||
*/
|
||||
@Deprecated
|
||||
public static void runWhenOn(Dist dist, Supplier<Runnable> toRun) {
|
||||
unsafeRunWhenOn(dist, toRun);
|
||||
}
|
||||
/**
|
||||
* Runs the supplied Runnable on the speicified side. Same warnings apply as {@link #unsafeCallWhenOn(Dist, Supplier)}.
|
||||
*
|
||||
* This method can cause unexpected ClassNotFoundException problems in common scenarios. Understand the pitfalls of
|
||||
* the way the class verifier works to load classes before using this.
|
||||
*
|
||||
* Use {@link #safeRunWhenOn(Dist, Supplier)} if you can.
|
||||
*
|
||||
* @see #unsafeCallWhenOn(Dist, Supplier)
|
||||
* @param dist Dist to run this code on
|
||||
* @param toRun The code to run
|
||||
*/
|
||||
public static void unsafeRunWhenOn(Dist dist, Supplier<Runnable> toRun) {
|
||||
if (dist == FMLEnvironment.dist) {
|
||||
toRun.get().run();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Call the supplied SafeRunnable when on the correct Dist.
|
||||
* @param dist The dist to run on
|
||||
* @param toRun The code to run
|
||||
*/
|
||||
public static void safeRunWhenOn(Dist dist, Supplier<SafeRunnable> toRun) {
|
||||
validateSafeReferent(toRun);
|
||||
if (dist == FMLEnvironment.dist) {
|
||||
toRun.get().run();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Executes one of the two suppliers, based on which side is active.
|
||||
*
|
||||
* <p>
|
||||
* Example (replacement for old SidedProxy):<br/>
|
||||
* {@code Proxy p = DistExecutor.runForDist(()->ClientProxy::new, ()->ServerProxy::new);}
|
||||
*
|
||||
* NOTE: the double supplier is required to avoid classloading the secondary target.
|
||||
*
|
||||
* @param clientTarget The supplier supplier to run when on the {@link Dist#CLIENT}
|
||||
* @param serverTarget The supplier supplier to run when on the {@link Dist#DEDICATED_SERVER}
|
||||
* @param <T> The common type to return
|
||||
* @return The returned instance
|
||||
* @deprecated Use {@link #safeRunForDist(Supplier, Supplier)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static <T> T runForDist(Supplier<Supplier<T>> clientTarget, Supplier<Supplier<T>> serverTarget) {
|
||||
return unsafeRunForDist(clientTarget, serverTarget);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsafe version of {@link #safeRunForDist(Supplier, Supplier)}. Use only when you know what you're doing
|
||||
* and understand why the verifier can cause unexpected ClassNotFoundException crashes even when code is apparently
|
||||
* not sided. Ensure you test both sides fully to be confident in using this.
|
||||
*
|
||||
* @param clientTarget The supplier supplier to run when on the {@link Dist#CLIENT}
|
||||
* @param serverTarget The supplier supplier to run when on the {@link Dist#DEDICATED_SERVER}
|
||||
* @param <T> The common type to return
|
||||
* @return The returned instance
|
||||
*/
|
||||
public static <T> T unsafeRunForDist(Supplier<Supplier<T>> clientTarget, Supplier<Supplier<T>> serverTarget) {
|
||||
switch (FMLEnvironment.dist)
|
||||
{
|
||||
case CLIENT:
|
||||
return clientTarget.get().get();
|
||||
case DEDICATED_SERVER:
|
||||
return serverTarget.get().get();
|
||||
default:
|
||||
throw new IllegalArgumentException("UNSIDED?");
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Executes one of the two suppliers, based on which side is active.
|
||||
*
|
||||
* <p>
|
||||
* Example (replacement for old SidedProxy):<br/>
|
||||
* {@code Proxy p = DistExecutor.safeRunForDist(()->ClientProxy::new, ()->ServerProxy::new);}
|
||||
*
|
||||
* NOTE: the double supplier is required to avoid classloading the secondary target.
|
||||
*
|
||||
* @param clientTarget The supplier supplier to run when on the {@link Dist#CLIENT}
|
||||
* @param serverTarget The supplier supplier to run when on the {@link Dist#DEDICATED_SERVER}
|
||||
* @param <T> The common type to return
|
||||
* @return The returned instance
|
||||
*/
|
||||
public static <T> T safeRunForDist(Supplier<SafeSupplier<T>> clientTarget, Supplier<SafeSupplier<T>> serverTarget) {
|
||||
validateSafeReferent(clientTarget);
|
||||
validateSafeReferent(serverTarget);
|
||||
switch (FMLEnvironment.dist)
|
||||
{
|
||||
case CLIENT:
|
||||
return clientTarget.get().get();
|
||||
case DEDICATED_SERVER:
|
||||
return serverTarget.get().get();
|
||||
default:
|
||||
throw new IllegalArgumentException("UNSIDED?");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A safe referent. This will assert that it is being called via a separated class method reference. This will
|
||||
* avoid the common pitfalls of {@link #callWhenOn(Dist, Supplier)} above.
|
||||
*
|
||||
* SafeReferents assert that they are defined as a separate method outside the scope of the calling class.
|
||||
*
|
||||
* <strong>Implementations need to be defined in a separate class to the referring site, with appropriate
|
||||
* visibility to be accessible at the callsite (generally, avoid private methods).</strong>
|
||||
*
|
||||
* <p>
|
||||
* Valid:<br/>
|
||||
*
|
||||
* {@code DistExecutor.safeCallWhenOn(Dist.CLIENT, ()->AnotherClass::clientOnlyMethod);}
|
||||
*
|
||||
* <p>
|
||||
* Invalid:<br/>
|
||||
*
|
||||
* {@code DistExecutor.safeCallWhenOn(Dist.CLIENT, ()->()->Minecraft.getInstance().world);}
|
||||
*/
|
||||
public interface SafeReferent {}
|
||||
|
||||
/**
|
||||
* SafeCallable version of {@link SafeReferent}.
|
||||
* @see SafeReferent
|
||||
* @param <T> The return type of the Callable
|
||||
*/
|
||||
public interface SafeCallable<T> extends SafeReferent, Callable<T>, Serializable {}
|
||||
|
||||
/**
|
||||
* SafeSupplier version of {@link SafeReferent}
|
||||
* @param <T> The return type of the Supplier
|
||||
*/
|
||||
public interface SafeSupplier<T> extends SafeReferent, Supplier<T>, Serializable {}
|
||||
|
||||
/**
|
||||
* SafeRunnable version of {@link SafeReferent}
|
||||
*/
|
||||
public interface SafeRunnable extends SafeReferent, Runnable, Serializable {}
|
||||
|
||||
private static final void validateSafeReferent(Supplier<? extends SafeReferent> safeReferentSupplier) {
|
||||
if (FMLEnvironment.production) return;
|
||||
final SafeReferent setter;
|
||||
try {
|
||||
setter = safeReferentSupplier.get();
|
||||
} catch (Exception e) {
|
||||
// Typically a class cast exception, just return out, expected.
|
||||
return;
|
||||
}
|
||||
|
||||
for (Class<?> cl = setter.getClass(); cl != null; cl = cl.getSuperclass()) {
|
||||
try {
|
||||
Method m = cl.getDeclaredMethod("writeReplace");
|
||||
m.setAccessible(true);
|
||||
Object replacement = m.invoke(setter);
|
||||
if (!(replacement instanceof SerializedLambda))
|
||||
break;// custom interface implementation
|
||||
SerializedLambda l = (SerializedLambda) replacement;
|
||||
if (Objects.equals(l.getCapturingClass(), l.getImplClass())) {
|
||||
LOGGER.fatal("Detected unsafe referent usage, please view the code at {}",Thread.currentThread().getStackTrace()[3]);
|
||||
throw new RuntimeException("Unsafe Referent usage found in safe referent method");
|
||||
}
|
||||
} catch (NoSuchMethodException e) {
|
||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,13 +6,14 @@
|
||||
package net.minecraftforge.fml;
|
||||
|
||||
import net.minecraftforge.fml.loading.progress.ProgressMeter;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.ToIntFunction;
|
||||
import java.util.function.IntSupplier;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* A mod loading state. During mod loading, the mod loader transitions between states in a defined sorted list of states,
|
||||
@@ -20,6 +21,7 @@ import java.util.function.ToIntFunction;
|
||||
*
|
||||
* @see IModStateProvider
|
||||
*/
|
||||
@NullMarked
|
||||
public interface IModLoadingState {
|
||||
/**
|
||||
* {@return the name of this state}
|
||||
@@ -42,19 +44,21 @@ public interface IModLoadingState {
|
||||
/**
|
||||
* {@return a function returning a human-friendly message for this state}
|
||||
*/
|
||||
Function<ModList, String> message();
|
||||
Supplier<String> message();
|
||||
|
||||
/**
|
||||
* @return a function that computes the size of this transition based on the size of the modlist.
|
||||
* Used to compute progress.
|
||||
*/
|
||||
ToIntFunction<ModList> size();
|
||||
default IntSupplier size() {
|
||||
return ModList::size;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return an optional runnable, which runs before starting the transition from this state to the next}
|
||||
* @see #buildTransition(Executor, Executor, ProgressMeter, Function, Function)
|
||||
*/
|
||||
Optional<Consumer<ModList>> inlineRunnable();
|
||||
@Nullable Runnable inlineRunnable();
|
||||
|
||||
/**
|
||||
* Builds the transition task for this state with a blank pre-sync and post-sync task.
|
||||
@@ -65,14 +69,14 @@ public interface IModLoadingState {
|
||||
* @return a transition task for this state
|
||||
* @see #buildTransition(Executor, Executor, ProgressMeter, Function, Function)
|
||||
*/
|
||||
default Optional<CompletableFuture<Void>> buildTransition(
|
||||
default @Nullable CompletableFuture<Void> buildTransition(
|
||||
final Executor syncExecutor,
|
||||
final Executor parallelExecutor,
|
||||
final ProgressMeter progressBar
|
||||
) {
|
||||
return buildTransition(syncExecutor, parallelExecutor, progressBar,
|
||||
e -> CompletableFuture.completedFuture(null),
|
||||
e -> CompletableFuture.completedFuture(null)
|
||||
_ -> CompletableFuture.completedFuture(null),
|
||||
_ -> CompletableFuture.completedFuture(null)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -87,7 +91,7 @@ public interface IModLoadingState {
|
||||
* @param postSyncTask a function which returns a task to run after event post-dispatch hook
|
||||
* @return a transition task for this state
|
||||
*/
|
||||
Optional<CompletableFuture<Void>> buildTransition(final Executor syncExecutor,
|
||||
@Nullable CompletableFuture<Void> buildTransition(final Executor syncExecutor,
|
||||
final Executor parallelExecutor,
|
||||
final ProgressMeter progressBar,
|
||||
final Function<Executor, CompletableFuture<Void>> preSyncTask,
|
||||
|
||||
@@ -6,21 +6,16 @@
|
||||
package net.minecraftforge.fml;
|
||||
|
||||
import net.minecraftforge.fml.event.IModBusEvent;
|
||||
import net.minecraftforge.fml.loading.progress.ProgressMeter;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import net.minecraftforge.fml.loading.progress.ProgressMeter;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public interface IModStateTransition {
|
||||
/** Magic value to allow me to optimize the futures list by ignoring the default value without making old methods nullable. */
|
||||
BiFunction<Executor, ? extends EventGenerator<?>, CompletableFuture<Void>> NULL_HOOK = (e, g) -> CompletableFuture.completedFuture(null);
|
||||
|
||||
static IModStateTransition buildNoopTransition() {
|
||||
return ModStateTransitionHelper.NOOP;
|
||||
}
|
||||
@@ -40,15 +35,6 @@ public interface IModStateTransition {
|
||||
return ModLoadingStage::nextState;
|
||||
}
|
||||
|
||||
/**
|
||||
* This used to allow you to fire multiple events during the transition. However, in doing so it would cause issues with the default
|
||||
* ModContainer's event handlers causing issues such as mod classes being constructed multiple times.
|
||||
*/
|
||||
@Deprecated(since = "1.21.3", forRemoval = true)
|
||||
default Supplier<Stream<EventGenerator<?>>> eventFunctionStream() {
|
||||
return () -> Stream.ofNullable(eventFunction());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
default <T extends IModBusEvent> EventGenerator<T> eventFunction() {
|
||||
return null;
|
||||
@@ -57,25 +43,9 @@ public interface IModStateTransition {
|
||||
ThreadSelector threadSelector();
|
||||
BiFunction<Executor, CompletableFuture<Void>, CompletableFuture<Void>> finalActivityGenerator();
|
||||
|
||||
/**
|
||||
* I think this was meant as a way to do some things for each mod container beforge/after the transition had been sent to the container.
|
||||
* However, the Future returned by this was never linked to the main transition future in any way. Which means that it was run
|
||||
* in parallel and couldn't guarantee the state of the ModContainer.
|
||||
* <p>
|
||||
* Plus all existing code that I could find returned a completedFuture, so I don't think anyone ever used this.
|
||||
* <p>
|
||||
* If I were to add this back it would be a CompletableFuture wrap(ModContainer, CompletableFuture)
|
||||
* <p>
|
||||
* Added magic value NULL_HOOK to allow me to optimize the futures list by ignoring the default value without making this method nullable.
|
||||
*/
|
||||
@Deprecated(since = "1.21.3", forRemoval = true)
|
||||
default BiFunction<Executor, ? extends EventGenerator<?>, CompletableFuture<Void>> preDispatchHook() { return NULL_HOOK; }
|
||||
@Deprecated(since = "1.21.3", forRemoval = true)
|
||||
default BiFunction<Executor, ? extends EventGenerator<?>, CompletableFuture<Void>> postDispatchHook() { return NULL_HOOK; }
|
||||
|
||||
interface EventGenerator<T extends IModBusEvent> extends Function<ModContainer, T> {
|
||||
static <FN extends IModBusEvent> EventGenerator<FN> fromFunction(Function<ModContainer, FN> fn) {
|
||||
return fn::apply;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,63 +5,20 @@
|
||||
|
||||
package net.minecraftforge.fml;
|
||||
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Spliterator;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Stream;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
public class InterModComms
|
||||
{
|
||||
public record IMCMessage(String senderModId, String modId, String method, Supplier<?> messageSupplier) {
|
||||
public final class InterModComms {
|
||||
public record IMCMessage(String senderModId, String modId, String method, Supplier<?> messageSupplier) {}
|
||||
|
||||
/**
|
||||
* Deprecated: use {@link #senderModId()}
|
||||
* @return The modid of the sender. This is supplied by the caller, or by the active mod container context.
|
||||
* Consider it unreliable.
|
||||
*/
|
||||
@Deprecated
|
||||
public final String getSenderModId() {
|
||||
return this.senderModId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated: use {@link #modId()}
|
||||
* @return The modid being sent to.
|
||||
*/
|
||||
@Deprecated
|
||||
public final String getModId() {
|
||||
return this.modId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated: use {@link #method()}
|
||||
* @return The method being sent to.
|
||||
*/
|
||||
@Deprecated
|
||||
public final String getMethod() {
|
||||
return this.method;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param <T> The type of the message.
|
||||
* @return A {@link Supplier} of the message.
|
||||
* Use {@link #messageSupplier()}
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Deprecated
|
||||
public final <T> Supplier<T> getMessageSupplier() {
|
||||
return (Supplier<T>) this.messageSupplier;
|
||||
}
|
||||
}
|
||||
|
||||
private static final ConcurrentMap<String, ConcurrentLinkedQueue<IMCMessage>> containerQueues = new ConcurrentHashMap<>();
|
||||
private static final ConcurrentHashMap<String, ConcurrentLinkedQueue<IMCMessage>> containerQueues = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* Send IMC to remote. Sender will default to the active modcontainer, or minecraft if not.
|
||||
@@ -72,8 +29,9 @@ public class InterModComms
|
||||
* @return true if the message was enqueued for sending (the target modid is loaded)
|
||||
*/
|
||||
public static boolean sendTo(final String modId, final String method, final Supplier<?> thing) {
|
||||
if (!ModList.get().isLoaded(modId)) return false;
|
||||
containerQueues.computeIfAbsent(modId, k->new ConcurrentLinkedQueue<>()).add(new IMCMessage(ModLoadingContext.get().getActiveContainer().getModId(), modId, method, thing));
|
||||
if (!ModList.isLoaded(modId)) return false;
|
||||
containerQueues.computeIfAbsent(modId, _ -> new ConcurrentLinkedQueue<>())
|
||||
.add(new IMCMessage(ModLoadingContext.get().getContainer().getModId(), modId, method, thing));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -87,8 +45,9 @@ public class InterModComms
|
||||
* @return true if the message was enqueued for sending (the target modid is loaded)
|
||||
*/
|
||||
public static boolean sendTo(final String senderModId, final String modId, final String method, final Supplier<?> thing) {
|
||||
if (!ModList.get().isLoaded(modId)) return false;
|
||||
containerQueues.computeIfAbsent(modId, k->new ConcurrentLinkedQueue<>()).add(new IMCMessage(senderModId, modId, method, thing));
|
||||
if (!ModList.isLoaded(modId)) return false;
|
||||
containerQueues.computeIfAbsent(modId, _ -> new ConcurrentLinkedQueue<>())
|
||||
.add(new IMCMessage(senderModId, modId, method, thing));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -112,7 +71,7 @@ public class InterModComms
|
||||
* @return All messages
|
||||
*/
|
||||
public static Stream<IMCMessage> getMessages(final String modId) {
|
||||
return getMessages(modId, s->Boolean.TRUE);
|
||||
return getMessages(modId, _ -> true);
|
||||
}
|
||||
|
||||
private record QueueFilteringSpliterator(
|
||||
@@ -136,13 +95,10 @@ public class InterModComms
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean tryAdvance(final Consumer<? super IMCMessage> action)
|
||||
{
|
||||
public boolean tryAdvance(final Consumer<? super IMCMessage> action) {
|
||||
IMCMessage next;
|
||||
do
|
||||
{
|
||||
if (!iterator.hasNext())
|
||||
{
|
||||
do {
|
||||
if (!iterator.hasNext()) {
|
||||
return false;
|
||||
}
|
||||
next = this.iterator.next();
|
||||
@@ -157,6 +113,5 @@ public class InterModComms
|
||||
public Spliterator<IMCMessage> trySplit() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,6 @@ import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.function.BiPredicate;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
@@ -41,11 +40,6 @@ public abstract class ModContainer {
|
||||
protected final Map<Class<? extends IExtensionPoint<?>>, Supplier<?>> extensionPoints = new IdentityHashMap<>();
|
||||
protected final EnumMap<ModConfig.Type, ModConfig> configs = new EnumMap<>(ModConfig.Type.class);
|
||||
final Set<ModContainer> dependencies = new HashSet<>();
|
||||
/**
|
||||
* If you want to handle the event, override {@link #dispatchConfigEvent(IConfigEvent)}
|
||||
*/
|
||||
@Deprecated(since = "1.21.3", forRemoval = true)
|
||||
protected Optional<Consumer<IConfigEvent>> configHandler = Optional.empty();
|
||||
|
||||
public ModContainer(IModInfo info) {
|
||||
this.modId = info.getModId();
|
||||
@@ -138,12 +132,7 @@ public abstract class ModContainer {
|
||||
configs.put(modConfig.getType(), modConfig);
|
||||
}
|
||||
|
||||
public void dispatchConfigEvent(IConfigEvent event) {
|
||||
var handler = configHandler.orElse(null);
|
||||
if (handler != null) {
|
||||
handler.accept(event);
|
||||
}
|
||||
}
|
||||
public void dispatchConfigEvent(IConfigEvent event) {}
|
||||
|
||||
/**
|
||||
* Does this mod match the supplied mod?
|
||||
|
||||
@@ -5,14 +5,14 @@
|
||||
|
||||
package net.minecraftforge.fml;
|
||||
|
||||
import net.minecraftforge.fml.loading.LoadingModList;
|
||||
import net.minecraftforge.forgespi.language.IModFileInfo;
|
||||
import net.minecraftforge.forgespi.language.IModInfo;
|
||||
import net.minecraftforge.forgespi.language.ModFileScanData;
|
||||
import net.minecraftforge.fml.loading.moddiscovery.ModFile;
|
||||
import net.minecraftforge.fml.loading.moddiscovery.ModFileInfo;
|
||||
import net.minecraftforge.fml.loading.moddiscovery.ModInfo;
|
||||
import net.minecraftforge.forgespi.locating.IModFile;
|
||||
import java.util.Collections;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -30,33 +30,36 @@ import java.util.stream.Stream;
|
||||
* Master list of all mods - game-side version. This is classloaded in the game scope and
|
||||
* can dispatch game level events as a result.
|
||||
*/
|
||||
public class ModList {
|
||||
private static ModList INSTANCE;
|
||||
private final List<IModFileInfo> modFiles;
|
||||
private final List<IModInfo> sortedList;
|
||||
private final Map<String, IModFileInfo> fileById;
|
||||
private List<ModContainer> mods;
|
||||
private Map<String, ModContainer> indexedMods;
|
||||
private List<ModFileScanData> modFileScanData;
|
||||
private List<ModContainer> sortedContainers;
|
||||
public final class ModList {
|
||||
private ModList() {}
|
||||
|
||||
private ModList(final List<ModFile> modFiles, final List<ModInfo> sortedList) {
|
||||
var modFileInfos = this.modFiles = modFiles.stream().map(ModFile::getModFileInfo).toList();
|
||||
this.sortedList = sortedList.stream().map(IModInfo.class::cast).toList();
|
||||
private static final List<IModFileInfo> MOD_FILES;
|
||||
private static final List<IModInfo> SORTED_LIST;
|
||||
private static final Map<String, IModFileInfo> FILE_BY_ID;
|
||||
private static List<ModContainer> mods;
|
||||
private static Map<String, ModContainer> indexedMods;
|
||||
private static List<ModContainer> sortedContainers;
|
||||
|
||||
static {
|
||||
var loadingModFiles = LoadingModList.getModFiles().stream().map(ModFileInfo::getFile).toList();
|
||||
var loadingSortedList = LoadingModList.getMods();
|
||||
|
||||
var modFileInfos = MOD_FILES = loadingModFiles.stream().map(ModFile::getModFileInfo).toList();
|
||||
SORTED_LIST = loadingSortedList.stream().map(IModInfo.class::cast).toList();
|
||||
var byId = new HashMap<String, IModFileInfo>();
|
||||
for (var file : modFileInfos) {
|
||||
for (var mod : file.getMods())
|
||||
byId.put(mod.getModId(), mod.getOwningFile());
|
||||
}
|
||||
this.fileById = Map.copyOf(byId);
|
||||
CrashReportCallables.registerCrashCallable("Mod List", this::crashReport);
|
||||
FILE_BY_ID = Map.copyOf(byId);
|
||||
CrashReportCallables.registerCrashCallable("Mod List", ModList::crashReport);
|
||||
}
|
||||
|
||||
private String getModContainerState(String modId) {
|
||||
private static String getModContainerState(String modId) {
|
||||
return getModContainerById(modId).map(ModContainer::getCurrentState).map(Object::toString).orElse("NONE");
|
||||
}
|
||||
|
||||
private String fileToLine(IModFile mf) {
|
||||
private static String fileToLine(IModFile mf) {
|
||||
var mainMod = mf.getModInfos().getFirst();
|
||||
return String.format(Locale.ENGLISH, "%-50.50s|%-30.30s|%-30.30s|%-20.20s|%-10.10s|Manifest: %s", mf.getFileName(),
|
||||
mainMod.getDisplayName(),
|
||||
@@ -66,92 +69,92 @@ public class ModList {
|
||||
((ModFileInfo)mf.getModFileInfo()).getCodeSigningFingerprint().orElse("NOSIGNATURE"));
|
||||
}
|
||||
|
||||
private String crashReport() {
|
||||
return "\n" + applyForEachModFile(this::fileToLine).collect(Collectors.joining("\n\t\t", "\t\t", ""));
|
||||
private static String crashReport() {
|
||||
return "\n" + applyForEachModFile(ModList::fileToLine).collect(Collectors.joining("\n\t\t", "\t\t", ""));
|
||||
}
|
||||
|
||||
public static ModList of(List<ModFile> modFiles, List<ModInfo> sortedList) {
|
||||
INSTANCE = new ModList(modFiles, sortedList);
|
||||
return INSTANCE;
|
||||
public static void init() {}
|
||||
|
||||
public static List<IModFileInfo> getModFiles() {
|
||||
return MOD_FILES;
|
||||
}
|
||||
|
||||
public static ModList get() {
|
||||
return INSTANCE;
|
||||
public static IModFileInfo getModFileById(String modid) {
|
||||
return FILE_BY_ID.get(modid);
|
||||
}
|
||||
|
||||
public List<IModFileInfo> getModFiles() {
|
||||
return modFiles;
|
||||
static void setLoadedMods(final List<ModContainer> modContainers) {
|
||||
mods = modContainers;
|
||||
sortedContainers = modContainers.stream().sorted(Comparator.comparingInt(c -> SORTED_LIST.indexOf(c.getModInfo()))).toList();
|
||||
indexedMods = modContainers.stream().collect(Collectors.toUnmodifiableMap(ModContainer::getModId, Function.identity()));
|
||||
}
|
||||
|
||||
public IModFileInfo getModFileById(String modid) {
|
||||
return this.fileById.get(modid);
|
||||
}
|
||||
|
||||
void setLoadedMods(final List<ModContainer> modContainers) {
|
||||
this.mods = modContainers;
|
||||
this.sortedContainers = modContainers.stream().sorted(Comparator.comparingInt(c -> sortedList.indexOf(c.getModInfo()))).toList();
|
||||
this.indexedMods = modContainers.stream().collect(Collectors.toMap(ModContainer::getModId, Function.identity()));
|
||||
static void clearLoadedMods() {
|
||||
mods = List.of();
|
||||
indexedMods = Map.of();
|
||||
sortedContainers = List.of();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> Optional<T> getModObjectById(String modId) {
|
||||
public static <T> Optional<T> getModObjectById(String modId) {
|
||||
return getModContainerById(modId).map(ModContainer::getMod).map(o -> (T) o);
|
||||
}
|
||||
|
||||
public Optional<? extends ModContainer> getModContainerById(String modId) {
|
||||
return Optional.ofNullable(this.indexedMods.get(modId));
|
||||
public static Optional<? extends ModContainer> getModContainerById(String modId) {
|
||||
return Optional.ofNullable(indexedMods.get(modId));
|
||||
}
|
||||
|
||||
public Optional<? extends ModContainer> getModContainerByObject(Object obj) {
|
||||
public static Optional<? extends ModContainer> getModContainerByObject(Object obj) {
|
||||
return mods.stream().filter(mc -> mc.getMod() == obj).findFirst();
|
||||
}
|
||||
|
||||
public List<IModInfo> getMods() {
|
||||
return this.sortedList;
|
||||
public static List<IModInfo> getMods() {
|
||||
return SORTED_LIST;
|
||||
}
|
||||
|
||||
public boolean isLoaded(String modTarget) {
|
||||
return this.indexedMods.containsKey(modTarget);
|
||||
public static boolean isLoaded(String modTarget) {
|
||||
return indexedMods.containsKey(modTarget);
|
||||
}
|
||||
|
||||
public int size() {
|
||||
public static int size() {
|
||||
return mods.size();
|
||||
}
|
||||
|
||||
public List<ModFileScanData> getAllScanData() {
|
||||
if (modFileScanData == null) {
|
||||
modFileScanData = this.sortedList.stream().
|
||||
map(IModInfo::getOwningFile).
|
||||
filter(Objects::nonNull).
|
||||
map(IModFileInfo::getFile).
|
||||
distinct().
|
||||
map(IModFile::getScanResult).
|
||||
toList();
|
||||
public static List<ModFileScanData> getAllScanData() {
|
||||
final class LazyInit {
|
||||
private LazyInit() {}
|
||||
private static final List<ModFileScanData> MOD_FILE_SCAN_DATA = SORTED_LIST.stream()
|
||||
.map(IModInfo::getOwningFile)
|
||||
.filter(Objects::nonNull)
|
||||
.map(IModFileInfo::getFile)
|
||||
.distinct()
|
||||
.map(IModFile::getScanResult)
|
||||
.toList();
|
||||
}
|
||||
return modFileScanData;
|
||||
return LazyInit.MOD_FILE_SCAN_DATA;
|
||||
}
|
||||
|
||||
public void forEachModFile(Consumer<IModFile> fileConsumer) {
|
||||
modFiles.stream().map(IModFileInfo::getFile).forEach(fileConsumer);
|
||||
public static void forEachModFile(Consumer<IModFile> fileConsumer) {
|
||||
MOD_FILES.stream().map(IModFileInfo::getFile).forEach(fileConsumer);
|
||||
}
|
||||
|
||||
public <T> Stream<T> applyForEachModFile(Function<IModFile, T> function) {
|
||||
return modFiles.stream().map(IModFileInfo::getFile).map(function);
|
||||
public static <T> Stream<T> applyForEachModFile(Function<IModFile, T> function) {
|
||||
return MOD_FILES.stream().map(IModFileInfo::getFile).map(function);
|
||||
}
|
||||
|
||||
public void forEachModContainer(BiConsumer<String, ModContainer> modContainerConsumer) {
|
||||
public static void forEachModContainer(BiConsumer<String, ModContainer> modContainerConsumer) {
|
||||
indexedMods.forEach(modContainerConsumer);
|
||||
}
|
||||
|
||||
public void forEachModInOrder(Consumer<ModContainer> containerConsumer) {
|
||||
this.sortedContainers.forEach(containerConsumer);
|
||||
public static void forEachModInOrder(Consumer<ModContainer> containerConsumer) {
|
||||
sortedContainers.forEach(containerConsumer);
|
||||
}
|
||||
|
||||
public List<ModContainer> getLoadedMods() {
|
||||
return this.sortedContainers;
|
||||
public static List<ModContainer> getLoadedMods() {
|
||||
return sortedContainers;
|
||||
}
|
||||
|
||||
public <T> Stream<T> applyForEachModContainer(Function<ModContainer, T> function) {
|
||||
public static <T> Stream<T> applyForEachModContainer(Function<ModContainer, T> function) {
|
||||
return indexedMods.values().stream().map(function);
|
||||
}
|
||||
}
|
||||
@@ -5,16 +5,11 @@
|
||||
|
||||
package net.minecraftforge.fml;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import net.minecraftforge.eventbus.api.bus.BusGroup;
|
||||
import net.minecraftforge.fml.event.IModBusEvent;
|
||||
import net.minecraftforge.fml.loading.FMLEnvironment;
|
||||
import net.minecraftforge.fml.loading.FMLLoader;
|
||||
import net.minecraftforge.fml.loading.ImmediateWindowHandler;
|
||||
import net.minecraftforge.fml.loading.LoadingModList;
|
||||
import net.minecraftforge.fml.loading.*;
|
||||
import net.minecraftforge.fml.loading.moddiscovery.InvalidModIdentifier;
|
||||
import net.minecraftforge.fml.loading.moddiscovery.ModFileInfo;
|
||||
import net.minecraftforge.fml.loading.moddiscovery.ModInfo;
|
||||
import net.minecraftforge.fml.loading.progress.ProgressMeter;
|
||||
import net.minecraftforge.fml.loading.progress.StartupNotificationManager;
|
||||
import net.minecraftforge.forgespi.language.IModInfo;
|
||||
@@ -71,48 +66,18 @@ import static net.minecraftforge.fml.Logging.LOADING;
|
||||
* and completes the mod loading sequence.</dd>
|
||||
* </dl>
|
||||
*/
|
||||
public class ModLoader {
|
||||
public final class ModLoader {
|
||||
private ModLoader() {}
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
private final LoadingModList loadingModList;
|
||||
|
||||
private final List<ModLoadingException> loadingExceptions;
|
||||
private final Set<IModInfo> erroredModInfos;
|
||||
private final List<ModLoadingWarning> loadingWarnings;
|
||||
private final ModStateManager stateManager;
|
||||
private static final ArrayList<ModLoadingException> LOADING_EXCEPTIONS = new ArrayList<>();
|
||||
private static final ArrayList<ModLoadingWarning> LOADING_WARNINGS = new ArrayList<>();
|
||||
private static final Consumer<String> STATUS_CONSUMER = StartupNotificationManager.modLoaderConsumer().orElse(_ -> {});
|
||||
private static final HashSet<IModLoadingState> COMPLETED_STATES = new HashSet<>();
|
||||
private static boolean loadingStateValid;
|
||||
private final Consumer<String> statusConsumer = StartupNotificationManager.modLoaderConsumer().orElse(msg -> {});
|
||||
private final Set<IModLoadingState> completedStates = new HashSet<>();
|
||||
private ModList modList;
|
||||
|
||||
private ModLoader() {
|
||||
var loadingModList = this.loadingModList = FMLLoader.getLoadingModList();
|
||||
var loadingExceptions = this.loadingExceptions = loadingModList.getErrors().stream()
|
||||
.flatMap(ModLoadingException::fromEarlyException)
|
||||
.collect(Collectors.toList());
|
||||
this.loadingWarnings = loadingModList.getBrokenFiles().stream()
|
||||
.map(file -> new ModLoadingWarning(null, ModLoadingStage.VALIDATE, InvalidModIdentifier.identifyJarProblem(file.getFilePath()).orElse("fml.modloading.brokenfile"), file.getFileName()))
|
||||
.collect(Collectors.toList());
|
||||
if (loadingExceptions.isEmpty()) {
|
||||
this.erroredModInfos = Collections.emptySet();
|
||||
} else {
|
||||
this.erroredModInfos = Collections.newSetFromMap(new IdentityHashMap<>());
|
||||
this.erroredModInfos.addAll(loadingExceptions.stream().map(ModLoadingException::getModInfo).toList());
|
||||
}
|
||||
loadingModList.getModFiles().stream()
|
||||
.filter(ModFileInfo::missingLicense)
|
||||
.filter(modFileInfo -> modFileInfo.getMods().stream().noneMatch(this.erroredModInfos::contains)) //Ignore files where any other mod already encountered an error
|
||||
.map(modFileInfo -> new ModLoadingException(null, ModLoadingStage.VALIDATE, "fml.modloading.missinglicense", null, modFileInfo.getFile()))
|
||||
.forEach(this.loadingExceptions::add);
|
||||
this.stateManager = new ModStateManager();
|
||||
CrashReportCallables.registerCrashCallable("ModLauncher", FMLLoader::getLauncherInfo);
|
||||
CrashReportCallables.registerCrashCallable("ModLauncher launch target", FMLLoader::launcherHandlerName);
|
||||
CrashReportCallables.registerCrashCallable("ModLauncher naming", FMLLoader::getNaming);
|
||||
CrashReportCallables.registerCrashCallable("ModLauncher services", ModLoader::computeModLauncherServiceList);
|
||||
CrashReportCallables.registerCrashCallable("FML Language Providers", ModLoader::computeLanguageList);
|
||||
}
|
||||
|
||||
private static String computeLanguageList() {
|
||||
return "\n" + FMLLoader.getLanguageLoadingProvider()
|
||||
return "\n" + LanguageLoadingProvider
|
||||
.applyForEach(lp -> lp.name() + '@' + lp.getClass().getPackage().getImplementationVersion())
|
||||
.collect(Collectors.joining("\n\t\t", "\t\t", ""));
|
||||
}
|
||||
@@ -126,37 +91,51 @@ public class ModLoader {
|
||||
collect(Collectors.joining("\n\t\t","\t\t",""));
|
||||
}
|
||||
|
||||
public static ModLoader get() {
|
||||
return LazyInit.INSTANCE;
|
||||
}
|
||||
|
||||
private static final class LazyInit {
|
||||
private static final ModLoader INSTANCE = new ModLoader();
|
||||
private LazyInit() {}
|
||||
}
|
||||
|
||||
/**
|
||||
* Run on the primary starting thread by ClientModLoader and ServerModLoader
|
||||
* @param syncExecutor An executor to run tasks on the main thread
|
||||
* @param parallelExecutor An executor to run tasks on a parallel loading thread pool
|
||||
* @param periodicTask Optional periodic task to perform on the main thread while other activities run
|
||||
*/
|
||||
public void gatherAndInitializeMods(final ModWorkManager.DrivenExecutor syncExecutor, final Executor parallelExecutor, final Runnable periodicTask) {
|
||||
public static void gatherAndInitializeMods(final ModWorkManager.DrivenExecutor syncExecutor, final Executor parallelExecutor, final Runnable periodicTask) {
|
||||
var loadingExceptions = LoadingModList.getErrors().stream()
|
||||
.flatMap(ModLoadingException::fromEarlyException)
|
||||
.toList();
|
||||
ModLoader.LOADING_EXCEPTIONS.addAll(loadingExceptions);
|
||||
LOADING_WARNINGS.addAll(LoadingModList.getBrokenFiles().stream()
|
||||
.map(file -> new ModLoadingWarning(null, ModLoadingStage.VALIDATE, InvalidModIdentifier.identifyJarProblem(file.getFilePath()).orElse("fml.modloading.brokenfile"), file.getFileName()))
|
||||
.toList());
|
||||
Set<IModInfo> erroredModInfos;
|
||||
if (loadingExceptions.isEmpty()) {
|
||||
erroredModInfos = Collections.emptySet();
|
||||
} else {
|
||||
erroredModInfos = Collections.newSetFromMap(new IdentityHashMap<>());
|
||||
erroredModInfos.addAll(loadingExceptions.stream().map(ModLoadingException::getModInfo).toList());
|
||||
}
|
||||
LoadingModList.getModFiles().stream()
|
||||
.filter(ModFileInfo::missingLicense)
|
||||
.filter(modFileInfo -> modFileInfo.getMods().stream().noneMatch(erroredModInfos::contains)) //Ignore files where any other mod already encountered an error
|
||||
.map(modFileInfo -> new ModLoadingException(null, ModLoadingStage.VALIDATE, "fml.modloading.missinglicense", null, modFileInfo.getFile()))
|
||||
.forEach(LOADING_EXCEPTIONS::add);
|
||||
CrashReportCallables.registerCrashCallable("ModLauncher", FMLLoader::getLauncherInfo);
|
||||
CrashReportCallables.registerCrashCallable("ModLauncher launch target", FMLLoader::launcherHandlerName);
|
||||
CrashReportCallables.registerCrashCallable("ModLauncher naming", FMLLoader::getNaming);
|
||||
CrashReportCallables.registerCrashCallable("ModLauncher services", ModLoader::computeModLauncherServiceList);
|
||||
CrashReportCallables.registerCrashCallable("FML Language Providers", ModLoader::computeLanguageList);
|
||||
|
||||
ForgeFeature.registerFeature("javaVersion", ForgeFeature.VersionFeatureTest.forVersionString(IModInfo.DependencySide.BOTH, System.getProperty("java.version")));
|
||||
ForgeFeature.registerFeature("openGLVersion", ForgeFeature.VersionFeatureTest.forVersionString(IModInfo.DependencySide.CLIENT, ImmediateWindowHandler.getGLVersion()));
|
||||
loadingStateValid = true;
|
||||
FMLLoader.backgroundScanHandler.waitForScanToComplete(periodicTask);
|
||||
final ModList modList = ModList.of(loadingModList.getModFiles().stream().map(ModFileInfo::getFile).toList(),
|
||||
loadingModList.getMods());
|
||||
if (!this.loadingExceptions.isEmpty()) {
|
||||
LOGGER.fatal(CORE, "Error during pre-loading phase", loadingExceptions.getFirst());
|
||||
statusConsumer.accept("ERROR DURING MOD LOADING");
|
||||
modList.setLoadedMods(Collections.emptyList());
|
||||
if (!LOADING_EXCEPTIONS.isEmpty()) {
|
||||
LOGGER.fatal(CORE, "Error during pre-loading phase", LOADING_EXCEPTIONS.getFirst());
|
||||
STATUS_CONSUMER.accept("ERROR DURING MOD LOADING");
|
||||
ModList.clearLoadedMods();
|
||||
loadingStateValid = false;
|
||||
throw new LoadingFailedException(loadingExceptions);
|
||||
throw new LoadingFailedException(LOADING_EXCEPTIONS);
|
||||
}
|
||||
var failedBounds = new ArrayList<ForgeFeature.Bound>();
|
||||
for (var mod : loadingModList.getMods()) {
|
||||
for (var mod : LoadingModList.getMods()) {
|
||||
for (var feature : mod.getForgeFeatures()) {
|
||||
if (!ForgeFeature.testFeature(FMLEnvironment.dist, feature))
|
||||
failedBounds.add(feature);
|
||||
@@ -165,8 +144,8 @@ public class ModLoader {
|
||||
|
||||
if (!failedBounds.isEmpty()) {
|
||||
LOGGER.fatal(CORE, "Failed to validate feature bounds for mods: {}", failedBounds);
|
||||
statusConsumer.accept("ERROR DURING MOD LOADING");
|
||||
modList.setLoadedMods(Collections.emptyList());
|
||||
STATUS_CONSUMER.accept("ERROR DURING MOD LOADING");
|
||||
ModList.clearLoadedMods();
|
||||
loadingStateValid = false;
|
||||
throw new LoadingFailedException(failedBounds.stream()
|
||||
.map(fb -> new ModLoadingException(fb.modInfo(), ModLoadingStage.CONSTRUCT, "fml.modloading.feature.missing", null, fb, ForgeFeature.featureValue(fb)))
|
||||
@@ -174,18 +153,18 @@ public class ModLoader {
|
||||
}
|
||||
|
||||
final var modContainers = new HashMap<String, ModContainer>();
|
||||
for (var file : loadingModList.getModFiles()) {
|
||||
var containers = this.buildMods(file.getFile());
|
||||
for (var file : LoadingModList.getModFiles()) {
|
||||
var containers = buildMods(file.getFile());
|
||||
for (var container : containers)
|
||||
modContainers.put(container.getModId(), container);
|
||||
}
|
||||
|
||||
if (!loadingExceptions.isEmpty()) {
|
||||
LOGGER.fatal(CORE, "Failed to initialize mod containers", loadingExceptions.getFirst());
|
||||
statusConsumer.accept("ERROR DURING MOD LOADING");
|
||||
modList.setLoadedMods(Collections.emptyList());
|
||||
if (!LOADING_EXCEPTIONS.isEmpty()) {
|
||||
LOGGER.fatal(CORE, "Failed to initialize mod containers", LOADING_EXCEPTIONS.getFirst());
|
||||
STATUS_CONSUMER.accept("ERROR DURING MOD LOADING");
|
||||
ModList.clearLoadedMods();
|
||||
loadingStateValid = false;
|
||||
throw new LoadingFailedException(loadingExceptions);
|
||||
throw new LoadingFailedException(LOADING_EXCEPTIONS);
|
||||
}
|
||||
|
||||
// Gather all dependencies, so we can make sure they have finished their transition events before we fire ours
|
||||
@@ -208,34 +187,33 @@ public class ModLoader {
|
||||
}
|
||||
}
|
||||
|
||||
modList.setLoadedMods(modContainers.values().stream().toList());
|
||||
this.modList = modList;
|
||||
var stateList = stateManager.getStates(ModLoadingPhase.GATHER);
|
||||
var progress = StartupMessageManager.addProgressBar("Mod Gather", stateList.stream().mapToInt(mls -> mls.size().applyAsInt(this.modList)).sum());
|
||||
ModList.setLoadedMods(modContainers.values().stream().toList());
|
||||
var stateList = ModStateManager.getStates(ModLoadingPhase.GATHER);
|
||||
var progress = StartupMessageManager.addProgressBar("Mod Gather", stateList.stream().mapToInt(mls -> mls.size().getAsInt()).sum());
|
||||
for (IModLoadingState mls : stateList) {
|
||||
dispatchAndHandleError(mls, syncExecutor, parallelExecutor, periodicTask, progress);
|
||||
}
|
||||
progress.complete();
|
||||
}
|
||||
|
||||
public void loadMods(final ModWorkManager.DrivenExecutor syncExecutor, final Executor parallelExecutor, final Runnable periodicTask) {
|
||||
var stateList = stateManager.getStates(ModLoadingPhase.LOAD);
|
||||
var progress = StartupMessageManager.addProgressBar("Mod Loading", stateList.stream().mapToInt(mls -> mls.size().applyAsInt(modList)).sum());
|
||||
public static void loadMods(final ModWorkManager.DrivenExecutor syncExecutor, final Executor parallelExecutor, final Runnable periodicTask) {
|
||||
var stateList = ModStateManager.getStates(ModLoadingPhase.LOAD);
|
||||
var progress = StartupMessageManager.addProgressBar("Mod Loading", stateList.stream().mapToInt(mls -> mls.size().getAsInt()).sum());
|
||||
for (IModLoadingState mls : stateList) {
|
||||
dispatchAndHandleError(mls, syncExecutor, parallelExecutor, periodicTask, progress);
|
||||
}
|
||||
progress.complete();
|
||||
}
|
||||
|
||||
public void finishMods(final ModWorkManager.DrivenExecutor syncExecutor, final Executor parallelExecutor, final Runnable periodicTask) {
|
||||
var stateList = stateManager.getStates(ModLoadingPhase.COMPLETE);
|
||||
var progress = StartupMessageManager.addProgressBar("Mod Complete", stateList.stream().mapToInt(mls -> mls.size().applyAsInt(modList)).sum());
|
||||
public static void finishMods(final ModWorkManager.DrivenExecutor syncExecutor, final Executor parallelExecutor, final Runnable periodicTask) {
|
||||
var stateList = ModStateManager.getStates(ModLoadingPhase.COMPLETE);
|
||||
var progress = StartupMessageManager.addProgressBar("Mod Complete", stateList.stream().mapToInt(mls -> mls.size().getAsInt()).sum());
|
||||
for (IModLoadingState mls : stateList) {
|
||||
dispatchAndHandleError(mls, syncExecutor, parallelExecutor, periodicTask, progress);
|
||||
}
|
||||
|
||||
var modBusGroups = Set.of(
|
||||
modList.getLoadedMods().stream()
|
||||
ModList.getLoadedMods().stream()
|
||||
.map(ModContainer::getModBusGroup)
|
||||
.filter(Objects::nonNull)
|
||||
.toArray(BusGroup[]::new)
|
||||
@@ -245,11 +223,11 @@ public class ModLoader {
|
||||
}
|
||||
parallelExecutor.execute(BusGroup.DEFAULT::trim);
|
||||
|
||||
statusConsumer.accept("Mod loading complete - %d mods loaded".formatted(this.modList.size()));
|
||||
STATUS_CONSUMER.accept("Mod loading complete - %d mods loaded".formatted(ModList.size()));
|
||||
progress.complete();
|
||||
}
|
||||
|
||||
private void dispatchAndHandleError(IModLoadingState state, ModWorkManager.DrivenExecutor syncExecutor, Executor parallelExecutor, final Runnable ticker, final ProgressMeter progressBar) {
|
||||
private static void dispatchAndHandleError(IModLoadingState state, ModWorkManager.DrivenExecutor syncExecutor, Executor parallelExecutor, final Runnable ticker, final ProgressMeter progressBar) {
|
||||
if (!isLoadingStateValid()) {
|
||||
LOGGER.error("Cowardly refusing to process mod state change request from {}", state);
|
||||
return;
|
||||
@@ -257,25 +235,25 @@ public class ModLoader {
|
||||
progressBar.label(progressBar.name() + " working");
|
||||
syncExecutor.drive(ticker);
|
||||
|
||||
var inlineRunnable = state.inlineRunnable().orElse(null);
|
||||
var inlineRunnable = state.inlineRunnable();
|
||||
if (inlineRunnable != null) handleInlineTransition(inlineRunnable, state, syncExecutor, ticker);
|
||||
|
||||
var transition = state.buildTransition(syncExecutor, parallelExecutor, progressBar).orElse(null);
|
||||
var transition = state.buildTransition(syncExecutor, parallelExecutor, progressBar);
|
||||
if (transition != null) waitForTransition(state, syncExecutor, ticker, transition);
|
||||
|
||||
completedStates.add(state);
|
||||
COMPLETED_STATES.add(state);
|
||||
}
|
||||
|
||||
private void handleInlineTransition(final Consumer<ModList> transition, final IModLoadingState state, final ModWorkManager.DrivenExecutor syncExecutor, final Runnable ticker) {
|
||||
private static void handleInlineTransition(final Runnable transition, final IModLoadingState state, final ModWorkManager.DrivenExecutor syncExecutor, final Runnable ticker) {
|
||||
var pb = StartupMessageManager.addProgressBar("State transition " + state.name() + " running", 0);
|
||||
syncExecutor.drive(ticker);
|
||||
transition.accept(this.modList);
|
||||
transition.run();
|
||||
syncExecutor.drive(ticker);
|
||||
pb.complete();
|
||||
syncExecutor.drive(ticker);
|
||||
}
|
||||
|
||||
private void waitForTransition(final IModLoadingState state, final ModWorkManager.DrivenExecutor syncExecutor, final Runnable ticker, final CompletableFuture<Void> transition) {
|
||||
private static void waitForTransition(final IModLoadingState state, final ModWorkManager.DrivenExecutor syncExecutor, final Runnable ticker, final CompletableFuture<Void> transition) {
|
||||
while (!transition.isDone()) {
|
||||
syncExecutor.drive(ticker);
|
||||
}
|
||||
@@ -289,7 +267,7 @@ public class ModLoader {
|
||||
.anyMatch(obj -> !(obj instanceof ModLoadingException));
|
||||
if (hasNotModLoadingEx) {
|
||||
LOGGER.fatal("Encountered non-modloading exceptions!", e);
|
||||
statusConsumer.accept("ERROR DURING MOD LOADING");
|
||||
STATUS_CONSUMER.accept("ERROR DURING MOD LOADING");
|
||||
throw e;
|
||||
}
|
||||
|
||||
@@ -298,12 +276,12 @@ public class ModLoader {
|
||||
.map(ModLoadingException.class::cast)
|
||||
.toList();
|
||||
LOGGER.fatal(LOADING,"Failed to complete lifecycle event {}, {} errors found", state.name(), modLoadingExceptions.size());
|
||||
statusConsumer.accept("ERROR DURING MOD LOADING");
|
||||
STATUS_CONSUMER.accept("ERROR DURING MOD LOADING");
|
||||
throw new LoadingFailedException(modLoadingExceptions);
|
||||
}
|
||||
}
|
||||
|
||||
private List<ModContainer> buildMods(final IModFile modFile) {
|
||||
private static List<ModContainer> buildMods(final IModFile modFile) {
|
||||
final Map<String, IModInfo> modInfoMap = new HashMap<>();
|
||||
for (var mod : modFile.getModFileInfo().getMods())
|
||||
modInfoMap.put(mod.getModId(), mod);
|
||||
@@ -333,14 +311,14 @@ public class ModLoader {
|
||||
missingMods.removeAll(modIds);
|
||||
LOGGER.fatal(LOADING, "The following mods are missing, but have classes in the jar: {}", missingMods);
|
||||
|
||||
loadingExceptions.add(new ModLoadingException(null, ModLoadingStage.CONSTRUCT, "fml.modloading.missingclasses", null, modFile.getFilePath()));
|
||||
LOADING_EXCEPTIONS.add(new ModLoadingException(null, ModLoadingStage.CONSTRUCT, "fml.modloading.missingclasses", null, modFile.getFilePath()));
|
||||
}
|
||||
|
||||
// remove errored mod containers
|
||||
return containers.stream().filter(mc -> mc.modLoadingStage != ModLoadingStage.ERROR).toList();
|
||||
}
|
||||
|
||||
private ModContainer buildModContainerFromTOML(final IModFile modFile, final Map<String, IModInfo> modInfoMap,
|
||||
private static ModContainer buildModContainerFromTOML(final IModFile modFile, final Map<String, IModInfo> modInfoMap,
|
||||
final String modId, final IModLanguageProvider.IModLanguageLoader languageLoader
|
||||
) {
|
||||
try {
|
||||
@@ -352,7 +330,7 @@ public class ModLoader {
|
||||
return languageLoader.loadMod(info, modFile.getScanResult(), FMLLoader.getGameLayer());
|
||||
} catch (ModLoadingException mle) {
|
||||
// exceptions are caught and added to the error list for later handling
|
||||
loadingExceptions.add(mle);
|
||||
LOADING_EXCEPTIONS.add(mle);
|
||||
// return an errored container instance here, because we tried and failed building a container.
|
||||
return new ErroredModContainer();
|
||||
}
|
||||
@@ -366,15 +344,8 @@ public class ModLoader {
|
||||
return loadingStateValid;
|
||||
}
|
||||
|
||||
/** @deprecated Use {@link #hasCompletedState(IModLoadingState)} instead */
|
||||
@Deprecated(forRemoval = true)
|
||||
public boolean hasCompletedState(final String stateName) {
|
||||
IModLoadingState state = stateManager.findState(stateName);
|
||||
return completedStates.contains(state);
|
||||
}
|
||||
|
||||
public boolean hasCompletedState(IModLoadingState state) {
|
||||
return completedStates.contains(state);
|
||||
public static boolean hasCompletedState(IModLoadingState state) {
|
||||
return COMPLETED_STATES.contains(state);
|
||||
}
|
||||
|
||||
public static <T extends IModBusEvent> void runEventGenerator(Function<ModContainer, T> generator) {
|
||||
@@ -382,7 +353,7 @@ public class ModLoader {
|
||||
LOGGER.error("Cowardly refusing to send event generator to a broken mod state");
|
||||
return;
|
||||
}
|
||||
for (var mod : ModList.get().getLoadedMods())
|
||||
for (var mod : ModList.getLoadedMods())
|
||||
mod.acceptEvent(generator.apply(mod));
|
||||
}
|
||||
|
||||
@@ -391,7 +362,7 @@ public class ModLoader {
|
||||
LOGGER.error("Cowardly refusing to send event {} to a broken mod state", e.getClass().getName());
|
||||
return;
|
||||
}
|
||||
for (var mod : ModList.get().getLoadedMods())
|
||||
for (var mod : ModList.getLoadedMods())
|
||||
mod.acceptEvent(e);
|
||||
}
|
||||
|
||||
@@ -400,7 +371,7 @@ public class ModLoader {
|
||||
LOGGER.error("Cowardly refusing to send event {} to a broken mod state", e.getClass().getName());
|
||||
return e;
|
||||
}
|
||||
for (var mod : ModList.get().getLoadedMods())
|
||||
for (var mod : ModList.getLoadedMods())
|
||||
mod.acceptEvent(e);
|
||||
return e;
|
||||
}
|
||||
@@ -418,19 +389,19 @@ public class ModLoader {
|
||||
LOGGER.error("Cowardly refusing to send event {} to a broken mod state", e.getClass().getName());
|
||||
return;
|
||||
}
|
||||
for (var mod : ModList.get().getLoadedMods()) {
|
||||
for (var mod : ModList.getLoadedMods()) {
|
||||
pre.accept(mod, e);
|
||||
mod.acceptEvent(e);
|
||||
post.accept(mod, e);
|
||||
}
|
||||
}
|
||||
|
||||
public List<ModLoadingWarning> getWarnings() {
|
||||
return ImmutableList.copyOf(this.loadingWarnings);
|
||||
public static List<ModLoadingWarning> getWarnings() {
|
||||
return List.copyOf(LOADING_WARNINGS);
|
||||
}
|
||||
|
||||
public void addWarning(ModLoadingWarning warning) {
|
||||
this.loadingWarnings.add(warning);
|
||||
public static void addWarning(ModLoadingWarning warning) {
|
||||
LOADING_WARNINGS.add(warning);
|
||||
}
|
||||
|
||||
private static boolean runningDataGen = false;
|
||||
|
||||
@@ -32,24 +32,11 @@ public class ModLoadingContext {
|
||||
return context.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Going to be moved to ForgeHooks for Internal use.
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since="1.21.1")
|
||||
public void setActiveContainer(final ModContainer container) {
|
||||
void setActiveContainer(final ModContainer container) {
|
||||
this.activeContainer = container;
|
||||
this.languageExtension = container == null ? null : container.contextExtension.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Going to be moved to ForgeHooks for Internal use.
|
||||
* @deprecated Override/Use {@link ModLoadingContext#getContainer()}
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since="1.21.1")
|
||||
public ModContainer getActiveContainer() {
|
||||
return activeContainer == null ? ModList.get().getModContainerById("minecraft").orElseThrow(()->new RuntimeException("Where is minecraft???!")) : activeContainer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Going to be moved to ForgeHooks for Internal use.
|
||||
*/
|
||||
@@ -58,11 +45,10 @@ public class ModLoadingContext {
|
||||
return activeContainer == null ? "minecraft" : activeContainer.getNamespace();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@link ModLoadingContext#getActiveContainer()} by default.
|
||||
*/
|
||||
public ModContainer getContainer() {
|
||||
return getActiveContainer();
|
||||
return activeContainer == null
|
||||
? ModList.getModContainerById("minecraft").orElseThrow(()->new RuntimeException("Where is minecraft???!"))
|
||||
: activeContainer;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -114,8 +100,7 @@ public class ModLoadingContext {
|
||||
}
|
||||
|
||||
public void registerConfig(ModConfig.Type type, IConfigSpec<?> spec) {
|
||||
if (spec.isEmpty())
|
||||
{
|
||||
if (spec.isEmpty()) {
|
||||
// This handles the case where a mod tries to register a config, without any options configured inside it.
|
||||
LOGGER.debug("Attempted to register an empty config for type {} on mod {}", type, getContainer().getModId());
|
||||
return;
|
||||
@@ -125,8 +110,7 @@ public class ModLoadingContext {
|
||||
}
|
||||
|
||||
public void registerConfig(ModConfig.Type type, IConfigSpec<?> spec, String fileName) {
|
||||
if (spec.isEmpty())
|
||||
{
|
||||
if (spec.isEmpty()) {
|
||||
// This handles the case where a mod tries to register a config, without any options configured inside it.
|
||||
LOGGER.debug("Attempted to register an empty config for type {} on mod {} using file name {}", type, getContainer().getModId(), fileName);
|
||||
return;
|
||||
@@ -135,7 +119,6 @@ public class ModLoadingContext {
|
||||
getContainer().addConfig(new ModConfig(type, spec, getContainer(), fileName));
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T extension() {
|
||||
return (T)languageExtension;
|
||||
|
||||
@@ -6,14 +6,15 @@
|
||||
package net.minecraftforge.fml;
|
||||
|
||||
import net.minecraftforge.fml.loading.progress.ProgressMeter;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.ToIntFunction;
|
||||
import java.util.function.IntSupplier;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Implementation of the {@link IModLoadingState} interface.
|
||||
@@ -25,27 +26,26 @@ import java.util.function.ToIntFunction;
|
||||
* @param inlineRunnable an optional runnable, which runs before starting the transition from this state to the next
|
||||
* @param transition optional state transition information
|
||||
*/
|
||||
@NullMarked
|
||||
public record ModLoadingState(
|
||||
String name,
|
||||
String previous,
|
||||
Function<ModList, String> message,
|
||||
ToIntFunction<ModList> size,
|
||||
Supplier<String> message,
|
||||
IntSupplier size,
|
||||
ModLoadingPhase phase,
|
||||
Optional<Consumer<ModList>> inlineRunnable,
|
||||
Optional<IModStateTransition> transition
|
||||
@Nullable Runnable inlineRunnable,
|
||||
@Nullable IModStateTransition transition
|
||||
) implements IModLoadingState {
|
||||
@Override
|
||||
public Optional<CompletableFuture<Void>> buildTransition(
|
||||
public @Nullable CompletableFuture<Void> buildTransition(
|
||||
final Executor syncExecutor,
|
||||
final Executor parallelExecutor,
|
||||
final ProgressMeter progressBar,
|
||||
final Function<Executor, CompletableFuture<Void>> preSyncTask,
|
||||
final Function<Executor, CompletableFuture<Void>> postSyncTask
|
||||
) {
|
||||
var transition = this.transition.orElse(null);
|
||||
return transition == null
|
||||
? Optional.empty()
|
||||
: Optional.ofNullable(transition.build(name, syncExecutor, parallelExecutor, progressBar, preSyncTask, postSyncTask));
|
||||
if (transition == null) return null;
|
||||
return transition.build(name, syncExecutor, parallelExecutor, progressBar, preSyncTask, postSyncTask);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -60,7 +60,7 @@ public record ModLoadingState(
|
||||
*/
|
||||
@Deprecated(since = "1.21.3", forRemoval = true)
|
||||
public static ModLoadingState empty(final String name, final String previous, final ModLoadingPhase phase) {
|
||||
return new ModLoadingState(name, previous, ml -> "", ml -> 0, phase, Optional.empty(), Optional.empty());
|
||||
return new ModLoadingState(name, previous, () -> "", () -> 0, phase, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -94,7 +94,7 @@ public record ModLoadingState(
|
||||
*/
|
||||
@Deprecated(since = "1.21.3", forRemoval = true)
|
||||
public static ModLoadingState withTransition(final String name, final String previous,
|
||||
final Function<ModList, String> message, final ModLoadingPhase phase,
|
||||
final Supplier<String> message, final ModLoadingPhase phase,
|
||||
final IModStateTransition transition) {
|
||||
return of(name, phase).after(previous).message(message).withTransition(transition);
|
||||
}
|
||||
@@ -113,7 +113,7 @@ public record ModLoadingState(
|
||||
*/
|
||||
@Deprecated(since = "1.21.3", forRemoval = true)
|
||||
public static ModLoadingState withInline(final String name, final String previous, final ModLoadingPhase phase,
|
||||
final Consumer<ModList> inline) {
|
||||
final Runnable inline) {
|
||||
return of(name, phase).after(previous).withInline(inline);
|
||||
}
|
||||
|
||||
@@ -126,23 +126,23 @@ public record ModLoadingState(
|
||||
return o instanceof ModLoadingState that
|
||||
&& this.phase == that.phase
|
||||
&& this.name.equals(that.name)
|
||||
&& Objects.equals(this.previous, that.previous);
|
||||
&& this.previous.equals(that.previous);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = phase.hashCode();
|
||||
result = 31 * result + name.hashCode();
|
||||
result = 31 * result + Objects.hashCode(previous);
|
||||
result = 31 * result + previous.hashCode();
|
||||
return result;
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
public static final class Builder {
|
||||
private final String name;
|
||||
private final ModLoadingPhase phase;
|
||||
private String after;
|
||||
private Function<ModList, String> message = null;
|
||||
private ToIntFunction<ModList> size = null;
|
||||
private String after = "";
|
||||
private @Nullable Supplier<String> message = null;
|
||||
private @Nullable IntSupplier size = null;
|
||||
|
||||
private Builder(final String name, final ModLoadingPhase phase) {
|
||||
this.name = name;
|
||||
@@ -155,28 +155,28 @@ public record ModLoadingState(
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder message(final String value) { return message(ml -> value); }
|
||||
public Builder message(final Function<ModList, String> value) {
|
||||
public Builder message(final String value) { return message(() -> value); }
|
||||
public Builder message(final Supplier<String> value) {
|
||||
this.message = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder size(final int value) { return size(ml -> value); }
|
||||
public Builder size(final ToIntFunction<ModList> value) {
|
||||
public Builder size(final int value) { return size(() -> value); }
|
||||
public Builder size(final IntSupplier value) {
|
||||
this.size = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ModLoadingState empty() {
|
||||
return new ModLoadingState(name, after, message != null ? message : ml -> "", size != null ? size : ml -> 0, phase, Optional.empty(), Optional.empty());
|
||||
return new ModLoadingState(name, after, message != null ? message : () -> "", size != null ? size : () -> 0, phase, null, null);
|
||||
}
|
||||
|
||||
public ModLoadingState withTransition(final IModStateTransition transition) {
|
||||
return new ModLoadingState(name, after, message != null ? message : ml -> "Processing transition " + name, size != null ? size : ModList::size, phase, Optional.empty(), Optional.of(transition));
|
||||
return new ModLoadingState(name, after, message != null ? message : () -> "Processing transition " + name, size != null ? size : ModList::size, phase, null, transition);
|
||||
}
|
||||
|
||||
public ModLoadingState withInline(final Consumer<ModList> inline) {
|
||||
return new ModLoadingState(name, after, message != null ? message : ml -> "Processing work " + name, size != null ? size : ml -> 0, phase, Optional.of(inline), Optional.empty());
|
||||
public ModLoadingState withInline(final Runnable inline) {
|
||||
return new ModLoadingState(name, after, message != null ? message : () -> "Processing work " + name, size != null ? size : () -> 0, phase, inline, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,41 +5,27 @@
|
||||
|
||||
package net.minecraftforge.fml;
|
||||
|
||||
import com.google.common.collect.Streams;
|
||||
import net.minecraftforge.forgespi.language.IModInfo;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class ModLoadingWarning {
|
||||
/**
|
||||
* Mod Info for mod with warning
|
||||
*/
|
||||
private final IModInfo modInfo;
|
||||
/**
|
||||
* The stage where this warning was encountered
|
||||
*/
|
||||
private final ModLoadingStage warningStage;
|
||||
|
||||
/**
|
||||
* I18N message to use for display
|
||||
*/
|
||||
private final String i18nMessage;
|
||||
|
||||
/**
|
||||
* Context for message display
|
||||
*/
|
||||
private final List<Object> context;
|
||||
|
||||
/**
|
||||
* @param modInfo Mod info for mod with warning
|
||||
* @param warningStage The stage where this warning was encountered
|
||||
* @param i18nMessage I18N message to use for display
|
||||
* @param context Context for message display
|
||||
*/
|
||||
public record ModLoadingWarning(IModInfo modInfo, ModLoadingStage warningStage, String i18nMessage, List<Object> context) {
|
||||
public ModLoadingWarning(final IModInfo modInfo, final ModLoadingStage warningStage, final String i18nMessage, Object... context) {
|
||||
this.modInfo = modInfo;
|
||||
this.warningStage = warningStage;
|
||||
this.i18nMessage = i18nMessage;
|
||||
this.context = Arrays.asList(context);
|
||||
this(modInfo, warningStage, i18nMessage, List.of(context));
|
||||
}
|
||||
|
||||
public ModLoadingWarning {
|
||||
context = List.copyOf(context);
|
||||
}
|
||||
|
||||
public String formatToString() {
|
||||
return Bindings.getMessageParser().get().parseMessage(i18nMessage, Streams.concat(Stream.of(modInfo, warningStage), context.stream()).toArray());
|
||||
return Bindings.getMessageParser().get().parseMessage(i18nMessage, Stream.concat(Stream.of(modInfo, warningStage), context.stream()).toArray());
|
||||
}
|
||||
}
|
||||
@@ -15,18 +15,19 @@ import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@SuppressWarnings("UnstableApiUsage")
|
||||
public class ModStateManager {
|
||||
private final EnumMap<ModLoadingPhase, List<IModLoadingState>> stateMap;
|
||||
public final class ModStateManager {
|
||||
private ModStateManager() {}
|
||||
private static final EnumMap<ModLoadingPhase, List<IModLoadingState>> stateMap;
|
||||
|
||||
public ModStateManager() {
|
||||
static {
|
||||
final var sp = ServiceLoader.load(FMLLoader.getGameLayer(), IModStateProvider.class);
|
||||
this.stateMap = ServiceLoaderUtils.streamWithErrorHandling(sp, sce->{})
|
||||
stateMap = ServiceLoaderUtils.streamWithErrorHandling(sp, _ -> {})
|
||||
.map(IModStateProvider::getAllStates)
|
||||
.flatMap(List::stream)
|
||||
.collect(Collectors.groupingBy(IModLoadingState::phase, ()->new EnumMap<>(ModLoadingPhase.class), Collectors.toUnmodifiableList()));
|
||||
.collect(Collectors.groupingBy(IModLoadingState::phase, () -> new EnumMap<>(ModLoadingPhase.class), Collectors.toUnmodifiableList()));
|
||||
}
|
||||
|
||||
public List<IModLoadingState> getStates(final ModLoadingPhase phase) {
|
||||
public static List<IModLoadingState> getStates(final ModLoadingPhase phase) {
|
||||
var nodes = stateMap.get(phase);
|
||||
var lookup = nodes.stream().collect(Collectors.toMap(IModLoadingState::name, Function.identity()));
|
||||
|
||||
@@ -40,7 +41,7 @@ public class ModStateManager {
|
||||
return TopologicalSort.topologicalSort(graph, Comparator.comparingInt(nodes::indexOf)).stream().filter(st->st!=dummy).toList();
|
||||
}
|
||||
|
||||
public IModLoadingState findState(final String stateName) {
|
||||
public static IModLoadingState findState(final String stateName) {
|
||||
var result = stateMap.values()
|
||||
.stream()
|
||||
.flatMap(List::stream)
|
||||
|
||||
@@ -24,7 +24,7 @@ import net.minecraftforge.fml.event.IModBusEvent;
|
||||
import net.minecraftforge.fml.loading.progress.ProgressMeter;
|
||||
|
||||
@ApiStatus.Internal
|
||||
class ModStateTransitionHelper {
|
||||
final class ModStateTransitionHelper {
|
||||
static final IModStateTransition NOOP = new NoopTransition();
|
||||
record NoopTransition() implements IModStateTransition {
|
||||
@Override
|
||||
@@ -62,7 +62,30 @@ class ModStateTransitionHelper {
|
||||
}
|
||||
}
|
||||
|
||||
record FutureResult<V>(V value, Throwable exception){}
|
||||
/// Same as [#completableFutureFromExceptionList(List)] but specialised for a single future
|
||||
static <V> CompletionStage<Void> completableFutureFromException(FutureResult<V> t) {
|
||||
if (t.exception() == null) {
|
||||
return CompletableFuture.completedFuture(null);
|
||||
} else {
|
||||
var exception = t.exception();
|
||||
CompletableFuture<Void> cf = new CompletableFuture<>();
|
||||
RuntimeException accumulator = new RuntimeException();
|
||||
cf.completeExceptionally(accumulator);
|
||||
if (exception instanceof CompletionException) {
|
||||
exception = exception.getCause();
|
||||
}
|
||||
if (exception.getSuppressed().length != 0) {
|
||||
for (Throwable throwable : exception.getSuppressed()) {
|
||||
accumulator.addSuppressed(throwable);
|
||||
}
|
||||
} else {
|
||||
accumulator.addSuppressed(exception);
|
||||
}
|
||||
return cf;
|
||||
}
|
||||
}
|
||||
|
||||
record FutureResult<V>(V value, Throwable exception) {}
|
||||
|
||||
static <V> CompletableFuture<List<FutureResult<V>>> gather(Collection<? extends CompletableFuture<? extends V>> futures) {
|
||||
var list = new ArrayList<FutureResult<V>>(futures.size());
|
||||
@@ -79,22 +102,14 @@ class ModStateTransitionHelper {
|
||||
return CompletableFuture.allOf(results).handle((r, th)->null).thenApply(res -> list);
|
||||
}
|
||||
|
||||
private static <T extends IModBusEvent> void addCompletableFutureTaskForModDispatch(
|
||||
final IModStateTransition transition,
|
||||
private static <T extends IModBusEvent> CompletableFuture<Void> addCompletableFutureTaskForModDispatch(
|
||||
final Executor executor,
|
||||
final List<CompletableFuture<Void>> completableFutures,
|
||||
final ProgressMeter progressBar,
|
||||
final EventGenerator<T> eventGenerator,
|
||||
final BiFunction<ModLoadingStage, Throwable, ModLoadingStage> nextState
|
||||
) {
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
var preDispatchHook = getHook(transition.preDispatchHook(), executor, eventGenerator);
|
||||
if (preDispatchHook != null)
|
||||
completableFutures.add(preDispatchHook);
|
||||
|
||||
var modFutures = new LinkedHashMap<String, CompletableFuture<Void>>();
|
||||
for (var mod : ModList.get().getLoadedMods()) {
|
||||
for (var mod : ModList.getLoadedMods()) {
|
||||
|
||||
CompletableFuture<Void> parent = null;
|
||||
if (mod.dependencies.isEmpty()) {
|
||||
@@ -129,20 +144,7 @@ class ModStateTransitionHelper {
|
||||
modFutures.put(mod.getModId(), dispatch);
|
||||
}
|
||||
|
||||
var dispatch = gather(modFutures.values()).thenComposeAsync(ModStateTransitionHelper::completableFutureFromExceptionList, executor);
|
||||
completableFutures.add(dispatch);
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
var postDispatchHook = getHook(transition.preDispatchHook(), executor, eventGenerator);
|
||||
if (postDispatchHook != null)
|
||||
completableFutures.add(postDispatchHook);
|
||||
}
|
||||
|
||||
private static <T extends IModBusEvent> CompletableFuture<Void> getHook(BiFunction<Executor, ? extends EventGenerator<?>, CompletableFuture<Void>> hook, Executor executor, EventGenerator<T> eventGenerator) {
|
||||
if (hook == null || hook == IModStateTransition.NULL_HOOK) return null;
|
||||
@SuppressWarnings("unchecked")
|
||||
var hookTyped = (BiFunction<Executor, EventGenerator<T>, CompletableFuture<Void>>)hook;
|
||||
return hookTyped.apply(executor, eventGenerator);
|
||||
return gather(modFutures.values()).thenComposeAsync(ModStateTransitionHelper::completableFutureFromExceptionList, executor);
|
||||
}
|
||||
|
||||
static <T extends IModBusEvent> CompletableFuture<Void> build(
|
||||
@@ -154,31 +156,25 @@ class ModStateTransitionHelper {
|
||||
final Function<Executor, CompletableFuture<Void>> preSyncTask,
|
||||
final Function<Executor, CompletableFuture<Void>> postSyncTask
|
||||
) {
|
||||
List<CompletableFuture<Void>> futures = new ArrayList<>();
|
||||
CompletableFuture<Void> future;
|
||||
final var executor = transition.threadSelector().apply(syncExecutor, parallelExecutor);
|
||||
|
||||
@SuppressWarnings({ "removal", "unchecked" })
|
||||
var events = transition.eventFunctionStream().get().map(f -> (EventGenerator<T>)f).toList();
|
||||
for (int x = 0; x < events.size(); x++) {
|
||||
var gen = events.get(x);
|
||||
BiFunction<ModLoadingStage, Throwable, ModLoadingStage> state = x == events.size() - 1
|
||||
? transition.nextModLoadingStage()
|
||||
: ModLoadingStage::currentState;
|
||||
addCompletableFutureTaskForModDispatch(transition, executor, futures, progressBar, gen, state);
|
||||
final CompletableFuture<Void> preSyncTaskCF = preSyncTask.apply(syncExecutor);
|
||||
CompletableFuture<Void> postEventDispatchCF = preSyncTaskCF
|
||||
.thenRunAsync(() -> progressBar.label(progressBar.name() + ": dispatching " + name), parallelExecutor);
|
||||
|
||||
var eventGenerator = transition.eventFunction();
|
||||
if (eventGenerator != null) {
|
||||
BiFunction<ModLoadingStage, Throwable, ModLoadingStage> state = transition.nextModLoadingStage();
|
||||
future = addCompletableFutureTaskForModDispatch(executor, progressBar, eventGenerator, state);
|
||||
|
||||
final CompletableFuture<Void> eventDispatchCF = future.handle(FutureResult::new)
|
||||
.thenCompose(ModStateTransitionHelper::completableFutureFromException);
|
||||
postEventDispatchCF = postEventDispatchCF.thenComposeAsync(_ -> eventDispatchCF, parallelExecutor);
|
||||
}
|
||||
|
||||
final CompletableFuture<Void> preSyncTaskCF = preSyncTask.apply(syncExecutor);
|
||||
final CompletableFuture<Void> eventDispatchCF = gather(futures).thenCompose(ModStateTransitionHelper::completableFutureFromExceptionList);
|
||||
final CompletableFuture<Void> postEventDispatchCF = preSyncTaskCF
|
||||
.thenApplyAsync(n -> {
|
||||
progressBar.label(progressBar.name() + ": dispatching " + name);
|
||||
return null;
|
||||
}, parallelExecutor)
|
||||
.thenComposeAsync(n -> eventDispatchCF, parallelExecutor)
|
||||
.thenApply(r -> {
|
||||
postSyncTask.apply(syncExecutor);
|
||||
return null;
|
||||
});
|
||||
postEventDispatchCF = postEventDispatchCF.thenRun(() -> postSyncTask.apply(syncExecutor));
|
||||
|
||||
return transition.finalActivityGenerator().apply(syncExecutor, postEventDispatchCF);
|
||||
}
|
||||
}
|
||||
@@ -14,25 +14,12 @@ import java.util.concurrent.locks.LockSupport;
|
||||
|
||||
import static net.minecraftforge.fml.Logging.LOADING;
|
||||
|
||||
public class ModWorkManager {
|
||||
public final class ModWorkManager {
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
private static final long PARK_TIME = TimeUnit.MILLISECONDS.toNanos(1);
|
||||
|
||||
public interface DrivenExecutor extends Executor {
|
||||
boolean selfDriven();
|
||||
boolean driveOne();
|
||||
|
||||
default void drive(Runnable ticker) {
|
||||
if (!selfDriven()) {
|
||||
ticker.run();
|
||||
while (true) {
|
||||
if (!driveOne()) break;
|
||||
}
|
||||
} else {
|
||||
// park for a bit so other threads can schedule
|
||||
LockSupport.parkNanos(PARK_TIME);
|
||||
}
|
||||
}
|
||||
public sealed interface DrivenExecutor extends Executor {
|
||||
void drive(Runnable ticker);
|
||||
}
|
||||
|
||||
private record SyncExecutor(ConcurrentLinkedDeque<Runnable> tasks) implements DrivenExecutor {
|
||||
@@ -40,8 +27,7 @@ public class ModWorkManager {
|
||||
this(new ConcurrentLinkedDeque<>());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean driveOne() {
|
||||
private boolean driveOne() {
|
||||
final Runnable task = tasks.pollFirst();
|
||||
if (task != null) {
|
||||
task.run();
|
||||
@@ -50,31 +36,30 @@ public class ModWorkManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean selfDriven() {
|
||||
return false;
|
||||
public void execute(final Runnable command) {
|
||||
tasks.addLast(command);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final Runnable command) {
|
||||
tasks.addLast(command);
|
||||
public void drive(Runnable ticker) {
|
||||
ticker.run();
|
||||
while (true) {
|
||||
if (!driveOne()) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private record WrappingExecutor(Executor wrapped) implements DrivenExecutor {
|
||||
@Override
|
||||
public boolean selfDriven() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean driveOne() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final Runnable command) {
|
||||
wrapped.execute(command);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drive(Runnable ticker) {
|
||||
// Park for a bit so other threads can schedule
|
||||
LockSupport.parkNanos(PARK_TIME);
|
||||
}
|
||||
}
|
||||
|
||||
private static final SyncExecutor syncExecutor = new SyncExecutor();
|
||||
|
||||
@@ -43,7 +43,7 @@ public final class OptionalMod<T>
|
||||
private T getValue()
|
||||
{
|
||||
if (!searched) {
|
||||
this.value = ModList.get().<T>getModObjectById(this.modId).orElse(null);
|
||||
this.value = ModList.<T>getModObjectById(this.modId).orElse(null);
|
||||
searched = true;
|
||||
}
|
||||
return this.value;
|
||||
|
||||
@@ -93,8 +93,8 @@ public class VersionChecker {
|
||||
return;
|
||||
}
|
||||
|
||||
var mc = ModList.get().getModContainerById("minecraft");
|
||||
var forge = ModList.get().getModContainerById("forge");
|
||||
var mc = ModList.getModContainerById("minecraft");
|
||||
var forge = ModList.getModContainerById("forge");
|
||||
this.mcVersion = mc.get().getModInfo().getVersion().toString();
|
||||
|
||||
this.agent = "Java-http-client/" + System.getProperty("java.version")
|
||||
@@ -223,7 +223,7 @@ public class VersionChecker {
|
||||
// Gather a list of mods that have opted in to this update system by providing a URL.
|
||||
private static List<IModInfo> gatherMods() {
|
||||
List<IModInfo> ret = new LinkedList<>();
|
||||
for (IModInfo info : ModList.get().getMods()) {
|
||||
for (IModInfo info : ModList.getMods()) {
|
||||
if (info.getUpdateURL().isPresent())
|
||||
ret.add(info);
|
||||
}
|
||||
|
||||
@@ -8,8 +8,7 @@ package net.minecraftforge.fml.config;
|
||||
import com.electronwill.nightconfig.core.CommentedConfig;
|
||||
import com.electronwill.nightconfig.core.file.CommentedFileConfig;
|
||||
import com.mojang.logging.LogUtils;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
import net.minecraftforge.fml.loading.FMLEnvironment;
|
||||
import net.minecraftforge.fml.loading.FMLPaths;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.Marker;
|
||||
@@ -19,57 +18,54 @@ import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class ConfigTracker {
|
||||
public final class ConfigTracker {
|
||||
private ConfigTracker() {}
|
||||
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
static final Marker CONFIG = MarkerFactory.getMarker("CONFIG");
|
||||
public static final ConfigTracker INSTANCE = new ConfigTracker();
|
||||
private final ConcurrentHashMap<String, ModConfig> fileMap;
|
||||
private final EnumMap<ModConfig.Type, Set<ModConfig>> configSets;
|
||||
private final ConcurrentHashMap<String, Map<ModConfig.Type, ModConfig>> configsByMod;
|
||||
private static final ConcurrentHashMap<String, ModConfig> FILE_MAP = new ConcurrentHashMap<>();
|
||||
private static final Map<ModConfig.Type, Set<ModConfig>> CONFIG_SETS = Map.of(
|
||||
ModConfig.Type.CLIENT, Collections.synchronizedSet(new LinkedHashSet<>()),
|
||||
ModConfig.Type.COMMON, Collections.synchronizedSet(new LinkedHashSet<>()),
|
||||
ModConfig.Type.SERVER, Collections.synchronizedSet(new LinkedHashSet<>())
|
||||
);
|
||||
private static final ConcurrentHashMap<String, Map<ModConfig.Type, ModConfig>> CONFIGS_BY_MOD = new ConcurrentHashMap<>();
|
||||
|
||||
private ConfigTracker() {
|
||||
this.fileMap = new ConcurrentHashMap<>();
|
||||
this.configSets = new EnumMap<>(ModConfig.Type.class);
|
||||
this.configsByMod = new ConcurrentHashMap<>();
|
||||
this.configSets.put(ModConfig.Type.CLIENT, Collections.synchronizedSet(new LinkedHashSet<>()));
|
||||
this.configSets.put(ModConfig.Type.COMMON, Collections.synchronizedSet(new LinkedHashSet<>()));
|
||||
// this.configSets.put(ModConfig.Type.PLAYER, new ConcurrentSkipListSet<>());
|
||||
this.configSets.put(ModConfig.Type.SERVER, Collections.synchronizedSet(new LinkedHashSet<>()));
|
||||
}
|
||||
|
||||
void trackConfig(final ModConfig config) {
|
||||
if (this.fileMap.containsKey(config.getFileName())) {
|
||||
LOGGER.error(CONFIG,"Detected config file conflict {} between {} and {}", config.getFileName(), this.fileMap.get(config.getFileName()).getModId(), config.getModId());
|
||||
static void trackConfig(final ModConfig config) {
|
||||
if (FILE_MAP.containsKey(config.getFileName())) {
|
||||
LOGGER.error(CONFIG,"Detected config file conflict {} between {} and {}", config.getFileName(), FILE_MAP.get(config.getFileName()).getModId(), config.getModId());
|
||||
throw new RuntimeException("Config conflict detected!");
|
||||
}
|
||||
this.fileMap.put(config.getFileName(), config);
|
||||
this.configSets.get(config.getType()).add(config);
|
||||
this.configsByMod.computeIfAbsent(config.getModId(), (k)->new EnumMap<>(ModConfig.Type.class)).put(config.getType(), config);
|
||||
FILE_MAP.put(config.getFileName(), config);
|
||||
CONFIG_SETS.get(config.getType()).add(config);
|
||||
CONFIGS_BY_MOD.computeIfAbsent(config.getModId(), _ -> new EnumMap<>(ModConfig.Type.class)).put(config.getType(), config);
|
||||
LOGGER.debug(CONFIG, "Config file {} for {} tracking", config.getFileName(), config.getModId());
|
||||
}
|
||||
|
||||
public void loadConfigs(ModConfig.Type type, Path configBasePath) {
|
||||
public static void loadConfigs(ModConfig.Type type, Path configBasePath) {
|
||||
LOGGER.debug(CONFIG, "Loading configs type {}", type);
|
||||
for (ModConfig config : this.configSets.get(type)) {
|
||||
for (ModConfig config : CONFIG_SETS.get(type)) {
|
||||
openConfig(config, configBasePath);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: [FML] This is only called for the server (outside of forceUnload)
|
||||
// rethink config implementation for eventual FML rewrite
|
||||
public void unloadConfigs(ModConfig.Type type, Path configBasePath) {
|
||||
public static void unloadConfigs(ModConfig.Type type, Path configBasePath) {
|
||||
LOGGER.debug(CONFIG, "Unloading configs type {}", type);
|
||||
for (ModConfig config : this.configSets.get(type)) {
|
||||
for (ModConfig config : CONFIG_SETS.get(type)) {
|
||||
closeConfig(config, configBasePath);
|
||||
}
|
||||
ConfigFileTypeHandler.get(type).stopWatcher();
|
||||
}
|
||||
|
||||
// If there is a better way to do this, please tell me. Because this is FUCKED
|
||||
public void forceUnload() {
|
||||
public static void forceUnload() {
|
||||
// This is how ModStateProvider handles loading configs. So we're doing the same but with unloadConfigs instead
|
||||
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> this.unloadConfigs(ModConfig.Type.CLIENT, FMLPaths.CONFIGDIR.get()));
|
||||
this.unloadConfigs(ModConfig.Type.COMMON, FMLPaths.CONFIGDIR.get());
|
||||
if (FMLEnvironment.dist.isClient())
|
||||
unloadConfigs(ModConfig.Type.CLIENT, FMLPaths.CONFIGDIR.get());
|
||||
|
||||
unloadConfigs(ModConfig.Type.COMMON, FMLPaths.CONFIGDIR.get());
|
||||
|
||||
// just in case server watcher is still alive somehow...
|
||||
ConfigFileTypeHandler.get(ModConfig.Type.SERVER).stopWatcher();
|
||||
@@ -96,8 +92,8 @@ public class ConfigTracker {
|
||||
}
|
||||
}
|
||||
|
||||
public void loadDefaultServerConfigs() {
|
||||
configSets.get(ModConfig.Type.SERVER).forEach(modConfig -> {
|
||||
public static void loadDefaultServerConfigs() {
|
||||
CONFIG_SETS.get(ModConfig.Type.SERVER).forEach(modConfig -> {
|
||||
final CommentedConfig commentedConfig = CommentedConfig.inMemory();
|
||||
modConfig.getSpec().correct(commentedConfig);
|
||||
modConfig.setConfigData(commentedConfig);
|
||||
@@ -105,16 +101,16 @@ public class ConfigTracker {
|
||||
});
|
||||
}
|
||||
|
||||
public String getConfigFileName(String modId, ModConfig.Type type) {
|
||||
return Optional.ofNullable(configsByMod.getOrDefault(modId, Collections.emptyMap()).getOrDefault(type, null)).
|
||||
public static String getConfigFileName(String modId, ModConfig.Type type) {
|
||||
return Optional.ofNullable(CONFIGS_BY_MOD.getOrDefault(modId, Collections.emptyMap()).getOrDefault(type, null)).
|
||||
map(ModConfig::getFullPath).map(Object::toString).orElse(null);
|
||||
}
|
||||
|
||||
public Map<ModConfig.Type, Set<ModConfig>> configSets() {
|
||||
return configSets;
|
||||
public static Map<ModConfig.Type, Set<ModConfig>> configSets() {
|
||||
return CONFIG_SETS;
|
||||
}
|
||||
|
||||
public ConcurrentHashMap<String, ModConfig> fileMap() {
|
||||
return fileMap;
|
||||
public static ConcurrentHashMap<String, ModConfig> fileMap() {
|
||||
return FILE_MAP;
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import java.util.function.Function;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public interface IConfigEvent {
|
||||
// TODO: [FML] Get rid of this indirection somehow
|
||||
record ConfigConfig(Function<ModConfig, IConfigEvent> loading, Function<ModConfig, IConfigEvent> reloading, @Nullable Function<ModConfig, IConfigEvent> unloading) {}
|
||||
|
||||
ConfigConfig CONFIGCONFIG = Bindings.getConfigConfiguration().get();
|
||||
|
||||
@@ -31,7 +31,7 @@ public class ModConfig
|
||||
this.fileName = fileName;
|
||||
this.container = container;
|
||||
this.configHandler = ConfigFileTypeHandler.get(type);
|
||||
ConfigTracker.INSTANCE.trackConfig(this);
|
||||
ConfigTracker.trackConfig(this);
|
||||
}
|
||||
|
||||
public ModConfig(final Type type, final IConfigSpec<?> spec, final ModContainer activeContainer) {
|
||||
@@ -40,8 +40,9 @@ public class ModConfig
|
||||
|
||||
private static String defaultConfigName(Type type, String modId) {
|
||||
// config file name would be "forge-client.toml" and "forge-server.toml"
|
||||
return String.format(Locale.ROOT, "%s-%s.toml", modId, type.extension());
|
||||
return modId + '-' + type.extension() + ".toml";
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
+12
-13
@@ -46,8 +46,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.IntConsumer;
|
||||
import java.util.function.IntSupplier;
|
||||
import java.util.function.LongSupplier;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collector;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -70,7 +68,7 @@ import static org.lwjgl.opengl.GL32C.*;
|
||||
* Based on the prior ClientVisualization, with some personal touches.
|
||||
*/
|
||||
public class DisplayWindow implements ImmediateWindowProvider {
|
||||
private static final int[][] GL_VERSIONS = new int[][] {{4,6}, {4,5}, {4,4}, {4,3}, {4,2}, {4,1}, {4,0}, {3,3}, {3,2}};
|
||||
private static final int[][] GL_VERSIONS = new int[][] {{4,6}, {4,5}, {4,4}, {4,3}, {4,2}, {4,1}, {4,0}, {3,3}};
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger("EARLYDISPLAY");
|
||||
private final AtomicBoolean animationTimerTrigger = new AtomicBoolean(true);
|
||||
|
||||
@@ -314,17 +312,18 @@ public class DisplayWindow implements ImmediateWindowProvider {
|
||||
LOGGER.error("ERROR DISPLAY\n"+msgBuilder);
|
||||
// we show the display on a new dedicated thread
|
||||
Executors.newSingleThreadExecutor().submit(()-> {
|
||||
var res = TinyFileDialogs.tinyfd_messageBox("Minecraft: Forge", msgBuilder.toString(), "yesno", "error", false);
|
||||
if (res) {
|
||||
var res = TinyFileDialogs.tinyfd_messageBox("Minecraft: Forge", msgBuilder.toString(), "yesno", "error", 0);
|
||||
if (res != 0) {
|
||||
try {
|
||||
Desktop.getDesktop().browse(URI.create(ERROR_URL));
|
||||
} catch (IOException ioe) {
|
||||
TinyFileDialogs.tinyfd_messageBox("Minecraft: Forge", "Sadly, we couldn't open your browser.\nVisit " + ERROR_URL, "ok", "error", false);
|
||||
TinyFileDialogs.tinyfd_messageBox("Minecraft: Forge", "Sadly, we couldn't open your browser.\nVisit " + ERROR_URL, "ok", "error", 0);
|
||||
}
|
||||
}
|
||||
System.exit(1);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to initialize the window when preparing for the Render Thread.
|
||||
*
|
||||
@@ -529,7 +528,7 @@ public class DisplayWindow implements ImmediateWindowProvider {
|
||||
*
|
||||
* @return the Window we own.
|
||||
*/
|
||||
public long setupMinecraftWindow(final IntSupplier width, final IntSupplier height, final Supplier<String> title, final LongSupplier monitorSupplier) {
|
||||
public long setupMinecraftWindow(final int width, final int height, final String title, final long monitorSupplier, final Supplier<Object> backend) {
|
||||
// wait for the window to actually be initialized
|
||||
try {
|
||||
this.initializationFuture.get(30, TimeUnit.SECONDS);
|
||||
@@ -549,11 +548,11 @@ public class DisplayWindow implements ImmediateWindowProvider {
|
||||
var renderlockticket = false;
|
||||
do {
|
||||
try {
|
||||
renderlockticket = renderLock.tryAcquire(100, TimeUnit.MILLISECONDS);
|
||||
if (++tries > 9) {
|
||||
Thread.dumpStack();
|
||||
crashElegantly("We seem to be having trouble handing off the window, tried for 1 second");
|
||||
}
|
||||
renderlockticket = renderLock.tryAcquire(100, TimeUnit.MILLISECONDS);
|
||||
if (++tries > 9) {
|
||||
Thread.dumpStack();
|
||||
crashElegantly("We seem to be having trouble handing off the window, tried for 1 second");
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
Thread.interrupted();
|
||||
}
|
||||
@@ -563,7 +562,7 @@ public class DisplayWindow implements ImmediateWindowProvider {
|
||||
|
||||
glfwMakeContextCurrent(window);
|
||||
// Set the title to what the game wants
|
||||
glfwSetWindowTitle(window, title.get());
|
||||
glfwSetWindowTitle(window, title);
|
||||
glfwSwapInterval(0);
|
||||
// Clean up our hooks
|
||||
glfwSetFramebufferSizeCallback(window, null).free();
|
||||
|
||||
@@ -49,7 +49,7 @@ public class RuntimeEnumExtender implements ILaunchPluginService {
|
||||
|
||||
private static final class LazyInit {
|
||||
private LazyInit() {}
|
||||
private static final boolean ANY_MODS = LoadingModList.get().getMods().size() > 2; // 2: forge, minecraft
|
||||
private static final boolean ANY_MODS = LoadingModList.getMods().size() > 2; // 2: forge, minecraft
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -30,13 +30,11 @@ import java.util.function.BiFunction;
|
||||
import static net.minecraftforge.fml.loading.LogMarkers.CORE;
|
||||
import static net.minecraftforge.fml.loading.LogMarkers.SCAN;
|
||||
|
||||
public class FMLLoader {
|
||||
public final class FMLLoader {
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
private static AccessTransformerService accessTransformer;
|
||||
private static LanguageLoadingProvider languageLoadingProvider;
|
||||
private static Dist dist;
|
||||
private static String naming;
|
||||
private static LoadingModList loadingModList;
|
||||
private static RuntimeDistCleaner runtimeDistCleaner;
|
||||
private static Path gamePath;
|
||||
private static final VersionInfo versionInfo = VersionInfo.detect();
|
||||
@@ -151,16 +149,11 @@ public class FMLLoader {
|
||||
|
||||
public static List<ITransformationService.Resource> completeScan(IModuleLayerManager layerManager) {
|
||||
moduleLayerManager = layerManager;
|
||||
languageLoadingProvider = new LanguageLoadingProvider();
|
||||
LanguageLoadingProvider.reload();
|
||||
backgroundScanHandler = modValidator.stage2Validation();
|
||||
loadingModList = backgroundScanHandler.getLoadingModList();
|
||||
return List.of(modValidator.getModResources());
|
||||
}
|
||||
|
||||
public static LanguageLoadingProvider getLanguageLoadingProvider() {
|
||||
return languageLoadingProvider;
|
||||
}
|
||||
|
||||
public static CommonLaunchHandler getLaunchHandler() {
|
||||
return commonLaunchHandler;
|
||||
}
|
||||
@@ -180,10 +173,6 @@ public class FMLLoader {
|
||||
progressWindowTick.run();
|
||||
}
|
||||
|
||||
public static LoadingModList getLoadingModList() {
|
||||
return loadingModList;
|
||||
}
|
||||
|
||||
public static Path getGamePath() {
|
||||
return gamePath;
|
||||
}
|
||||
|
||||
@@ -51,8 +51,8 @@ public class ImmediateWindowHandler {
|
||||
earlyProgress.label("Bootstrapping Minecraft");
|
||||
}
|
||||
|
||||
public static long setupMinecraftWindow(final IntSupplier width, final IntSupplier height, final Supplier<String> title, final LongSupplier monitor) {
|
||||
return provider.setupMinecraftWindow(width, height, title, monitor);
|
||||
public static long setupMinecraftWindow(final int width, final int height, final String title, final long monitor, final Supplier<Object> backend) {
|
||||
return provider.setupMinecraftWindow(width, height, title, monitor, backend);
|
||||
}
|
||||
|
||||
public static boolean positionWindow(Optional<Object> monitor,IntConsumer widthSetter, IntConsumer heightSetter, IntConsumer xSetter, IntConsumer ySetter) {
|
||||
@@ -104,9 +104,9 @@ public class ImmediateWindowHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public long setupMinecraftWindow(final IntSupplier width, final IntSupplier height, final Supplier<String> title, final LongSupplier monitor) {
|
||||
public long setupMinecraftWindow(final int width, final int height, final String title, final long monitor, final Supplier<Object> backend) {
|
||||
try {
|
||||
var longsupplier = (LongSupplier)NV_HANDOFF.invoke(null, width, height, title, monitor);
|
||||
var longsupplier = (LongSupplier)NV_HANDOFF.invoke(null, width, height, title, monitor, backend);
|
||||
return longsupplier.getAsLong();
|
||||
} catch (Throwable e) {
|
||||
throw new IllegalStateException("How did you get here?", e);
|
||||
|
||||
@@ -8,8 +8,6 @@ package net.minecraftforge.fml.loading;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.IntConsumer;
|
||||
import java.util.function.IntSupplier;
|
||||
import java.util.function.LongSupplier;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
@@ -66,7 +64,7 @@ public interface ImmediateWindowProvider {
|
||||
* @param monitor This is the monitor it should appear on.
|
||||
* @return The window id
|
||||
*/
|
||||
long setupMinecraftWindow(final IntSupplier width, final IntSupplier height, final Supplier<String> title, final LongSupplier monitor);
|
||||
long setupMinecraftWindow(final int width, final int height, final String title, final long monitor, final Supplier<Object> backend);
|
||||
|
||||
/**
|
||||
* This is called after window handoff to allow us to tell Mojang about our window's position. This might give a
|
||||
|
||||
+11
-19
@@ -18,7 +18,6 @@ import org.slf4j.Logger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.ServiceConfigurationError;
|
||||
import java.util.ServiceLoader;
|
||||
import java.util.function.Consumer;
|
||||
@@ -28,43 +27,36 @@ import java.util.stream.Stream;
|
||||
import static net.minecraftforge.fml.loading.LogMarkers.CORE;
|
||||
import static net.minecraftforge.fml.loading.LogMarkers.LOADING;
|
||||
|
||||
public class LanguageLoadingProvider {
|
||||
public void forEach(Consumer<IModLanguageProvider> consumer) {
|
||||
public final class LanguageLoadingProvider {
|
||||
public static void forEach(Consumer<IModLanguageProvider> consumer) {
|
||||
providers.forEach(consumer);
|
||||
}
|
||||
|
||||
public <T> Stream<T> applyForEach(Function<IModLanguageProvider, T> function) {
|
||||
public static <T> Stream<T> applyForEach(Function<IModLanguageProvider, T> function) {
|
||||
return providers.stream().map(function);
|
||||
}
|
||||
|
||||
public void reload() {
|
||||
public static void reload() {
|
||||
loadLanguageProviders();
|
||||
}
|
||||
|
||||
/** This doesn't actually do anything with the argument, so just call reload(). Not sure when cpw broke that. */
|
||||
@Deprecated(forRemoval = true, since = "1.20.2")
|
||||
public void addAdditionalLanguages(List<ModFile> modFiles) {
|
||||
reload();
|
||||
}
|
||||
|
||||
/*==========================================================================*
|
||||
* INTERNAL SHIT *
|
||||
* INTERNAL *
|
||||
*==========================================================================*/
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
private final ServiceLoader<IModLanguageProvider> serviceLoader;
|
||||
private final List<IModLanguageProvider> providers = new ArrayList<>();
|
||||
private final Map<String, Wrapper> providersByName = new HashMap<>();
|
||||
private static final ServiceLoader<IModLanguageProvider> serviceLoader;
|
||||
private static final ArrayList<IModLanguageProvider> providers = new ArrayList<>();
|
||||
private static final HashMap<String, Wrapper> providersByName = new HashMap<>();
|
||||
private static final DefaultArtifactVersion IN_DEV = new DefaultArtifactVersion("0.0-dev");
|
||||
|
||||
private record Wrapper(ArtifactVersion version, IModLanguageProvider service) {}
|
||||
|
||||
LanguageLoadingProvider() {
|
||||
static {
|
||||
var sl = Launcher.INSTANCE.environment().findModuleLayerManager().flatMap(lm -> lm.getLayer(Layer.PLUGIN)).orElseThrow();
|
||||
serviceLoader = ServiceLoader.load(sl, IModLanguageProvider.class);
|
||||
loadLanguageProviders();
|
||||
}
|
||||
|
||||
private void loadLanguageProviders() {
|
||||
private static void loadLanguageProviders() {
|
||||
providers.clear();
|
||||
providersByName.clear();
|
||||
|
||||
@@ -97,7 +89,7 @@ public class LanguageLoadingProvider {
|
||||
}
|
||||
}
|
||||
|
||||
public IModLanguageProvider findLanguage(ModFile mod, String language, VersionRange versionRange) {
|
||||
public static IModLanguageProvider findLanguage(ModFile mod, String language, VersionRange versionRange) {
|
||||
var consumer = mod.getFileName();
|
||||
var wrapper = providersByName.get(language);
|
||||
|
||||
|
||||
@@ -5,118 +5,46 @@
|
||||
|
||||
package net.minecraftforge.fml.loading;
|
||||
|
||||
import net.minecraftforge.fml.loading.EarlyLoadingException.ExceptionData;
|
||||
import net.minecraftforge.fml.loading.moddiscovery.BackgroundScanHandler;
|
||||
import net.minecraftforge.fml.loading.moddiscovery.ModFile;
|
||||
import net.minecraftforge.fml.loading.moddiscovery.ModFileInfo;
|
||||
import net.minecraftforge.fml.loading.moddiscovery.ModInfo;
|
||||
import net.minecraftforge.forgespi.locating.IModFile;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import com.mojang.logging.LogUtils;
|
||||
|
||||
/**
|
||||
* Master list of all mods <em>in the loading context. This class cannot refer outside the
|
||||
* loading package</em>
|
||||
*/
|
||||
public class LoadingModList {
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
private static LoadingModList INSTANCE;
|
||||
private final List<ModFileInfo> modFiles;
|
||||
private final List<ModInfo> sortedList;
|
||||
private final Map<String, ModFileInfo> fileById;
|
||||
private final List<EarlyLoadingException> preLoadErrors;
|
||||
private List<IModFile> brokenFiles;
|
||||
|
||||
private LoadingModList(final List<ModFile> modFiles, final List<ModInfo> sortedList) {
|
||||
this.modFiles = modFiles.stream()
|
||||
.map(ModFile::getModFileInfo)
|
||||
.map(ModFileInfo.class::cast)
|
||||
.toList();
|
||||
this.sortedList = sortedList.stream().toList();
|
||||
this.fileById = this.modFiles.stream()
|
||||
.map(ModFileInfo::getMods)
|
||||
.flatMap(Collection::stream)
|
||||
.map(ModInfo.class::cast)
|
||||
.collect(Collectors.toMap(ModInfo::getModId, ModInfo::getOwningFile));
|
||||
this.preLoadErrors = new ArrayList<>();
|
||||
/// Master list of all mods in the loading context
|
||||
public sealed interface LoadingModList permits LoadingModListImpl {
|
||||
static ModFileInfo getModFileById(String modId) {
|
||||
return get().fileById().get(modId);
|
||||
}
|
||||
|
||||
public static LoadingModList of(List<ModFile> modFiles, List<ModInfo> sortedList, final EarlyLoadingException earlyLoadingException) {
|
||||
INSTANCE = new LoadingModList(modFiles, sortedList);
|
||||
if (earlyLoadingException != null)
|
||||
INSTANCE.preLoadErrors.add(earlyLoadingException);
|
||||
return INSTANCE;
|
||||
static List<ModFileInfo> getModFiles() {
|
||||
return get().getModFiles();
|
||||
}
|
||||
|
||||
public static LoadingModList get() {
|
||||
return INSTANCE;
|
||||
static List<ModInfo> getMods() {
|
||||
return get().getMods();
|
||||
}
|
||||
|
||||
public void addAccessTransformers() {
|
||||
var errors = new ArrayList<ExceptionData>();
|
||||
|
||||
for (ModFileInfo modFile : modFiles) {
|
||||
ModFile mod = modFile.getFile();
|
||||
for (var at : mod.getAccessTransformers()) {
|
||||
if (!Files.exists(at)) {
|
||||
var message = "Invalid mod file: " + modFile.getFile().getFileName() + ". Missing Access Transformer: " + at;
|
||||
errors.add(new ExceptionData(message));
|
||||
LOGGER.error(message);
|
||||
} else
|
||||
FMLLoader.addAccessTransformer(at, mod);
|
||||
}
|
||||
}
|
||||
|
||||
if (!errors.isEmpty())
|
||||
preLoadErrors.add(new EarlyLoadingException("Invalid Access Transformers", null, errors));
|
||||
}
|
||||
|
||||
public void addForScanning(BackgroundScanHandler backgroundScanHandler) {
|
||||
backgroundScanHandler.setLoadingModList(this);
|
||||
modFiles.stream()
|
||||
.map(ModFileInfo::getFile)
|
||||
.forEach(backgroundScanHandler::submitForScanning);
|
||||
}
|
||||
|
||||
public List<ModFileInfo> getModFiles() {
|
||||
return modFiles;
|
||||
}
|
||||
|
||||
public Path findResource(final String className) {
|
||||
for (ModFileInfo mf : modFiles) {
|
||||
final Path resource = mf.getFile().findResource(className);
|
||||
static @Nullable Path findResource(String className) {
|
||||
for (ModFileInfo modFileInfo : get().getModFiles()) {
|
||||
Path resource = modFileInfo.getFile().findResource(className);
|
||||
if (Files.exists(resource)) return resource;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ModFileInfo getModFileById(String modid) {
|
||||
return this.fileById.get(modid);
|
||||
static List<EarlyLoadingException> getErrors() {
|
||||
return get().getErrors();
|
||||
}
|
||||
|
||||
public List<ModInfo> getMods() {
|
||||
return this.sortedList;
|
||||
static List<IModFile> getBrokenFiles() {
|
||||
return get().getBrokenFiles();
|
||||
}
|
||||
|
||||
public List<EarlyLoadingException> getErrors() {
|
||||
return preLoadErrors;
|
||||
}
|
||||
|
||||
public void setBrokenFiles(final List<IModFile> brokenFiles) {
|
||||
this.brokenFiles = brokenFiles;
|
||||
}
|
||||
|
||||
public List<IModFile> getBrokenFiles() {
|
||||
return this.brokenFiles;
|
||||
private static LoadingModListImpl get() {
|
||||
return LoadingModListImpl.get();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.fml.loading;
|
||||
|
||||
import net.minecraftforge.fml.loading.EarlyLoadingException.ExceptionData;
|
||||
import net.minecraftforge.fml.loading.moddiscovery.ModFile;
|
||||
import net.minecraftforge.fml.loading.moddiscovery.ModFileInfo;
|
||||
import net.minecraftforge.fml.loading.moddiscovery.ModInfo;
|
||||
import net.minecraftforge.forgespi.locating.IModFile;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import com.mojang.logging.LogUtils;
|
||||
|
||||
/**
|
||||
* Master list of all mods <em>in the loading context. This class cannot refer outside the
|
||||
* loading package</em>
|
||||
*/
|
||||
record LoadingModListImpl(
|
||||
List<ModFileInfo> getModFiles,
|
||||
List<ModInfo> getMods,
|
||||
Map<String, ModFileInfo> fileById,
|
||||
ArrayList<EarlyLoadingException> getErrors,
|
||||
ArrayList<IModFile> getBrokenFiles
|
||||
) implements LoadingModList {
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
private static ModSorter.State temp;
|
||||
|
||||
LoadingModListImpl(List<ModFile> modFiles, List<ModInfo> sortedList) {
|
||||
var modFileInfos = modFiles.stream()
|
||||
.map(ModFile::getModFileInfo)
|
||||
.map(ModFileInfo.class::cast)
|
||||
.toList();
|
||||
sortedList = sortedList.stream().toList();
|
||||
var fileById = modFileInfos.stream()
|
||||
.map(ModFileInfo::getMods)
|
||||
.flatMap(Collection::stream)
|
||||
.map(ModInfo.class::cast)
|
||||
.collect(Collectors.toUnmodifiableMap(ModInfo::getModId, ModInfo::getOwningFile));
|
||||
this(modFileInfos, sortedList, fileById, new ArrayList<>(), new ArrayList<>());
|
||||
}
|
||||
|
||||
static LoadingModListImpl init(ModSorter.State modSorterState, EarlyLoadingException earlyLoadingException) {
|
||||
temp = modSorterState;
|
||||
var instance = get();
|
||||
if (earlyLoadingException != null)
|
||||
instance.getErrors.add(earlyLoadingException);
|
||||
temp = null;
|
||||
instance.addAccessTransformers();
|
||||
return instance;
|
||||
}
|
||||
|
||||
static LoadingModListImpl get() {
|
||||
final class LazyInit {
|
||||
private LazyInit() {}
|
||||
private static final LoadingModListImpl INSTANCE
|
||||
= new LoadingModListImpl(LoadingModListImpl.temp.files(), LoadingModListImpl.temp.mods());
|
||||
}
|
||||
return LazyInit.INSTANCE;
|
||||
}
|
||||
|
||||
private void addAccessTransformers() {
|
||||
var errors = new ArrayList<ExceptionData>();
|
||||
|
||||
for (ModFileInfo modFile : getModFiles) {
|
||||
ModFile mod = modFile.getFile();
|
||||
for (var at : mod.getAccessTransformers()) {
|
||||
if (!Files.exists(at)) {
|
||||
var message = "Invalid mod file: " + modFile.getFile().getFileName() + ". Missing Access Transformer: " + at;
|
||||
errors.add(new ExceptionData(message));
|
||||
LOGGER.error(message);
|
||||
} else
|
||||
FMLLoader.addAccessTransformer(at, mod);
|
||||
}
|
||||
}
|
||||
|
||||
if (!errors.isEmpty())
|
||||
getErrors.add(new EarlyLoadingException("Invalid Access Transformers", null, errors));
|
||||
}
|
||||
}
|
||||
@@ -33,10 +33,10 @@ import java.util.stream.Stream;
|
||||
|
||||
import static net.minecraftforge.fml.loading.LogMarkers.LOADING;
|
||||
|
||||
public class ModSorter {
|
||||
public final class ModSorter {
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
|
||||
private record State(List<ModFile> files, List<ModInfo> mods) {}
|
||||
record State(List<ModFile> files, List<ModInfo> mods) {}
|
||||
|
||||
private ModSorter() {}
|
||||
|
||||
@@ -52,7 +52,7 @@ public class ModSorter {
|
||||
// Note this will never actually throw an error because the duplicate checks are done in ModDiscovererer before we get to this phase
|
||||
// So all this is really doing is wasting time.
|
||||
// But i'm leaving it here until I rewrite all of cpw's mod loading code because its such a clusterfuck.
|
||||
return LoadingModList.of(systemMods.files(), systemMods.mods(), e);
|
||||
return LoadingModListImpl.init(systemMods, e);
|
||||
}
|
||||
|
||||
var named = new HashMap<String, ModInfo>();
|
||||
@@ -66,15 +66,15 @@ public class ModSorter {
|
||||
|
||||
// if we miss one or the other, we abort now
|
||||
if (!failedList.isEmpty()) {
|
||||
return LoadingModList.of(systemMods.files(), systemMods.mods(), new EarlyLoadingException("failure to validate mod list", null, failedList));
|
||||
return LoadingModListImpl.init(systemMods, new EarlyLoadingException("failure to validate mod list", null, failedList));
|
||||
} else {
|
||||
// Otherwise, lets try and sort the modlist and proceed
|
||||
try {
|
||||
var sorted = sort(modFiles, named);
|
||||
return LoadingModList.of(sorted.files(), sorted.mods(), null);
|
||||
return LoadingModListImpl.init(sorted, null);
|
||||
} catch (EarlyLoadingException e) {
|
||||
// The only exception that can happen here is a cyclic exception, but fall back to system mods so we can display the nice screen.
|
||||
return LoadingModList.of(systemMods.files(), systemMods.mods(), e);
|
||||
return LoadingModListImpl.init(systemMods, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,6 @@ public final class RuntimeDistCleaner implements ILaunchPluginService {
|
||||
private static String DIST;
|
||||
private static final String ONLYIN = Type.getDescriptor(OnlyIn.class);
|
||||
private static final String ONLYINS = Type.getDescriptor(OnlyIns.class);
|
||||
private static final String MOD = "Lnet/minecraftforge/fml/common/Mod;";
|
||||
|
||||
@Override
|
||||
public String name() {
|
||||
@@ -45,11 +44,17 @@ public final class RuntimeDistCleaner implements ILaunchPluginService {
|
||||
|
||||
@Override
|
||||
public EnumSet<Phase> handlesClass(Type classType, boolean isEmpty) {
|
||||
// TODO: [FML][RuntimeDistCleaner] In 26.1, only return YAY for MC classes on mod dev server
|
||||
if (isEmpty)
|
||||
return NAY;
|
||||
|
||||
String internalName = classType.getInternalName();
|
||||
|
||||
// Only apply to MC classes when on a dedicated server in a production environment
|
||||
if (FMLEnvironment.production)
|
||||
return FMLEnvironment.dist.isDedicatedServer() && isMinecraftClass(internalName) ? YAY : NAY;
|
||||
|
||||
// For dev time it's a bit trickier so that we can throw exceptions when someone uses @OnlyIn in their mod code,
|
||||
// so that it's more obvious that the behaviour they're expecting won't work in production anymore
|
||||
if (internalName.startsWith("net/minecraftforge/"))
|
||||
return NAY;
|
||||
|
||||
@@ -57,7 +62,7 @@ public final class RuntimeDistCleaner implements ILaunchPluginService {
|
||||
if (FMLEnvironment.dist.isClient() && isMinecraftClass(internalName))
|
||||
return NAY;
|
||||
|
||||
return YAY;
|
||||
return YAY; // mod classes might have @OnlyIn, so parse them in dev to find out and throw if they do
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -66,29 +71,14 @@ public final class RuntimeDistCleaner implements ILaunchPluginService {
|
||||
|
||||
var annotations = unpack(classNode.visibleAnnotations);
|
||||
var isNonMinecraftClass = !isMinecraftClass(classNode.name);
|
||||
final class LazyInit {
|
||||
private LazyInit() {}
|
||||
private static final boolean CAN_EXPLODE = !FMLEnvironment.production && "21.6".equals(FMLLoader.versionInfo().mcVersion());
|
||||
}
|
||||
|
||||
if (remove(annotations, DIST)) {
|
||||
LOGGER.error(DISTXFORM, "Attempted to load class {} for invalid dist {}", classNode.name, DIST);
|
||||
throw new RuntimeException("Attempted to load class " + classNode.name + " for invalid dist " + DIST);
|
||||
}
|
||||
|
||||
if (!annotations.isEmpty()) {
|
||||
if (isNonMinecraftClass) {
|
||||
if (LazyInit.CAN_EXPLODE)
|
||||
throw new UnsupportedOperationException("Mod class " + classNode.name + " is annotated with @OnlyIn, this is no longer supported as it slowed down startup times");
|
||||
else
|
||||
LOGGER.warn(DISTXFORM, "Class {} is annotated with @OnlyIn, this is deprecated and won't work in a future MC release.", classNode.name);
|
||||
}
|
||||
|
||||
if (!FMLEnvironment.production && hasModAnnotation(classNode.visibleAnnotations)) {
|
||||
LOGGER.error(DISTXFORM, "Attempted to load class {} with @Mod and @OnlyIn/@OnlyIns annotations", classNode.name);
|
||||
throw new RuntimeException("Found @OnlyIn on @Mod class " + classNode.name + " - this is not allowed as it causes crashes. Remove the OnlyIn and consider setting clientSideOnly=true in the root of your mods.toml instead");
|
||||
}
|
||||
}
|
||||
if (isNonMinecraftClass && !annotations.isEmpty())
|
||||
throw new UnsupportedOperationException("Mod class " + classNode.name + " is annotated with @OnlyIn, this is no longer supported as it slowed down startup times");
|
||||
|
||||
if (classNode.interfaces != null && !classNode.interfaces.isEmpty()) {
|
||||
for (var ann : annotations) {
|
||||
@@ -121,12 +111,8 @@ public final class RuntimeDistCleaner implements ILaunchPluginService {
|
||||
itr.remove();
|
||||
changed = true;
|
||||
|
||||
if (isNonMinecraftClass) {
|
||||
if (LazyInit.CAN_EXPLODE)
|
||||
throw new UnsupportedOperationException("Field " + field.name + " in mod class " + classNode.name + " is annotated with @OnlyIn, this is no longer supported as it slowed down startup times");
|
||||
else
|
||||
LOGGER.warn(DISTXFORM, "Field {} in class {} is annotated with @OnlyIn, this is deprecated and won't work in a future MC release.", field.name, classNode.name);
|
||||
}
|
||||
if (isNonMinecraftClass)
|
||||
throw new UnsupportedOperationException("Field " + field.name + " in mod class " + classNode.name + " is annotated with @OnlyIn, this is no longer supported as it slowed down startup times");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,12 +125,8 @@ public final class RuntimeDistCleaner implements ILaunchPluginService {
|
||||
lambdaGatherer.accept(method);
|
||||
changed = true;
|
||||
|
||||
if (isNonMinecraftClass) {
|
||||
if (LazyInit.CAN_EXPLODE)
|
||||
throw new UnsupportedOperationException("Method " + method.name + " in mod class " + classNode.name + " is annotated with @OnlyIn, this is no longer supported as it slowed down startup times");
|
||||
else
|
||||
LOGGER.warn(DISTXFORM, "Method {} in class {} is annotated with @OnlyIn, this is deprecated and won't work in a future MC release.", method.name, classNode.name);
|
||||
}
|
||||
if (isNonMinecraftClass)
|
||||
throw new UnsupportedOperationException("Method " + method.name + " in mod class " + classNode.name + " is annotated with @OnlyIn, this is no longer supported as it slowed down startup times");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -225,18 +207,6 @@ public final class RuntimeDistCleaner implements ILaunchPluginService {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean hasModAnnotation(final List<AnnotationNode> anns) {
|
||||
if (anns == null || anns.isEmpty())
|
||||
return false;
|
||||
|
||||
for (var ann : anns) {
|
||||
if (ann.desc.equals(MOD))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean isMinecraftClass(final String internalName) {
|
||||
return internalName.startsWith("net/minecraft/") || internalName.startsWith("com/mojang/");
|
||||
}
|
||||
@@ -250,7 +220,7 @@ public final class RuntimeDistCleaner implements ILaunchPluginService {
|
||||
};
|
||||
}
|
||||
|
||||
private static class LambdaGatherer extends MethodVisitor {
|
||||
private static final class LambdaGatherer extends MethodVisitor {
|
||||
private static final Handle META_FACTORY = new Handle(Opcodes.H_INVOKESTATIC,
|
||||
"java/lang/invoke/LambdaMetafactory", "metafactory",
|
||||
"(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;",
|
||||
|
||||
@@ -12,6 +12,7 @@ import java.util.Map;
|
||||
import org.apache.commons.lang3.text.StrLookup;
|
||||
import org.apache.commons.lang3.text.StrSubstitutor;
|
||||
|
||||
// TODO: [FML] Remove this
|
||||
@SuppressWarnings("deprecation")
|
||||
public class StringSubstitutor {
|
||||
private static final Map<String, String> GLOBALS = Map.of(
|
||||
|
||||
@@ -115,19 +115,22 @@ public final class UniqueModListBuilder {
|
||||
}
|
||||
|
||||
private static ArtifactVersion getVersion(final ModFile mf) {
|
||||
if (mf.getModFileInfo() == null || mf.getModInfos() == null || mf.getModInfos().isEmpty()) {
|
||||
List<IModInfo> modInfos;
|
||||
if (mf.getModFileInfo() == null || (modInfos = mf.getModInfos()) == null || modInfos.isEmpty()) {
|
||||
return mf.getJarVersion();
|
||||
}
|
||||
|
||||
return mf.getModInfos().getFirst().getVersion();
|
||||
return modInfos.getFirst().getVersion();
|
||||
}
|
||||
|
||||
private static String getModId(ModFile modFile) {
|
||||
if (modFile.getModFileInfo() == null || modFile.getModFileInfo().getMods().isEmpty()) {
|
||||
var modFileInfo = modFile.getModFileInfo();
|
||||
List<IModInfo> mods;
|
||||
if (modFileInfo == null || (mods = modFileInfo.getMods()).isEmpty()) {
|
||||
return modFile.getSecureJar().name();
|
||||
}
|
||||
|
||||
return modFile.getModFileInfo().getMods().getFirst().getModId();
|
||||
return mods.getFirst().getModId();
|
||||
}
|
||||
|
||||
public record UniqueModListData(List<ModFile> modFiles, Map<String, List<ModFile>> modFilesByFirstId) {}
|
||||
|
||||
@@ -32,15 +32,6 @@ public class VersionSupportMatrix {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #testVersionSupportMatrix(VersionRange, String, String)} instead, unwrapping your BiPredicate.
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "1.21.1")
|
||||
public static boolean testVersionSupportMatrix(VersionRange declaredRange, String lookupId, String type, BiPredicate<String, VersionRange> standardLookup) {
|
||||
if (standardLookup.test(lookupId, declaredRange)) return true;
|
||||
return testVersionSupportMatrix(declaredRange, lookupId, type);
|
||||
}
|
||||
|
||||
public static boolean testVersionSupportMatrix(VersionRange declaredRange, String lookupId, String type) {
|
||||
if (OVERRIDE_VERSIONS.isEmpty()) return false;
|
||||
List<ArtifactVersion> custom = OVERRIDE_VERSIONS.get(type + "." + lookupId);
|
||||
|
||||
+1
-13
@@ -17,8 +17,7 @@ import java.time.Instant;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.*;
|
||||
|
||||
public class BackgroundScanHandler
|
||||
{
|
||||
public final class BackgroundScanHandler {
|
||||
private enum ScanStatus {
|
||||
NOT_STARTED,
|
||||
RUNNING,
|
||||
@@ -33,7 +32,6 @@ public class BackgroundScanHandler
|
||||
private final ExecutorService modContentScanner;
|
||||
private final List<ModFile> modFiles;
|
||||
private ScanStatus status;
|
||||
private LoadingModList loadingModList;
|
||||
|
||||
public BackgroundScanHandler(final List<ModFile> modFiles) {
|
||||
this.modFiles = modFiles;
|
||||
@@ -69,16 +67,6 @@ public class BackgroundScanHandler
|
||||
}
|
||||
}
|
||||
|
||||
public void setLoadingModList(LoadingModList loadingModList)
|
||||
{
|
||||
this.loadingModList = loadingModList;
|
||||
}
|
||||
|
||||
public LoadingModList getLoadingModList()
|
||||
{
|
||||
return loadingModList;
|
||||
}
|
||||
|
||||
public void waitForScanToComplete(final Runnable ticker) {
|
||||
boolean timeoutActive = System.getProperty("fml.disableScanTimeout") == null;
|
||||
Instant deadline = Instant.now().plus(Duration.ofMinutes(10));
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@ public final class ClasspathLocator extends AbstractModProvider implements IModL
|
||||
// Find 'minecraft' during dev time this is also Forge. So skip it.
|
||||
// Can return null for dedicated server as Minecraft isn't on the classpath
|
||||
// On the client it doesn't matter as it's the vanilla jar so wouldnt have mods.toml in it.
|
||||
var minecraft = getPathFromResource(cl, "net/minecraft/obfuscate/DontObfuscate.class");
|
||||
var minecraft = getPathFromResource(cl, "net/minecraft/world/item/Item.class");
|
||||
|
||||
var claimed = new HashSet<Path>();
|
||||
var tomls = getUrls(cl, MODS_TOML);
|
||||
|
||||
+4
-3
@@ -41,9 +41,10 @@ public final class ModDiscoverer {
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
public static ModValidator discoverMods(Map<String, ?> arguments) {
|
||||
Launcher.INSTANCE.environment().computePropertyIfAbsent(Environment.Keys.MODDIRECTORYFACTORY.get(), v->ModsFolderLocator::new);
|
||||
Launcher.INSTANCE.environment().computePropertyIfAbsent(Environment.Keys.PROGRESSMESSAGE.get(), v-> StartupNotificationManager.locatorConsumer().orElseGet(()-> s->{}));
|
||||
final var moduleLayerManager = Launcher.INSTANCE.environment().findModuleLayerManager().orElseThrow();
|
||||
var env = Launcher.INSTANCE.environment();
|
||||
env.computePropertyIfAbsent(Environment.Keys.MODDIRECTORYFACTORY.get(), _ -> ModsFolderLocator::new);
|
||||
env.computePropertyIfAbsent(Environment.Keys.PROGRESSMESSAGE.get(), _ -> StartupNotificationManager.locatorConsumer().orElse(_ -> {}));
|
||||
final var moduleLayerManager = env.findModuleLayerManager().orElseThrow();
|
||||
ServiceLoader<IModLocator> modLocators = ServiceLoader.load(moduleLayerManager.getLayer(IModuleLayerManager.Layer.SERVICE).orElseThrow(), IModLocator.class);
|
||||
ServiceLoader<IDependencyLocator> dependencyLocators = ServiceLoader.load(moduleLayerManager.getLayer(IModuleLayerManager.Layer.SERVICE).orElseThrow(), IDependencyLocator.class);
|
||||
List<IModLocator> modLocatorList = ServiceLoaderUtils.streamWithErrorHandling(modLocators, sce -> LOGGER.error("Failed to load mod locator list", sce)).toList();
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.google.common.collect.ImmutableMap;
|
||||
import com.mojang.logging.LogUtils;
|
||||
import cpw.mods.jarhandling.SecureJar;
|
||||
import net.minecraftforge.fml.loading.FMLLoader;
|
||||
import net.minecraftforge.fml.loading.LanguageLoadingProvider;
|
||||
import net.minecraftforge.fml.loading.LogMarkers;
|
||||
import net.minecraftforge.forgespi.language.IModFileInfo;
|
||||
import net.minecraftforge.forgespi.language.IModInfo;
|
||||
@@ -48,8 +49,7 @@ public class ModFile implements IModFile {
|
||||
private final IModFileInfo modFileInfo;
|
||||
private ModFileScanData fileModFileScanData;
|
||||
private CompletableFuture<ModFileScanData> futureScanResult;
|
||||
private Path accessTransformer;
|
||||
private List<Path> accessTransformers = Collections.emptyList();
|
||||
private List<Path> accessTransformers = List.of();
|
||||
|
||||
static final Attributes.Name TYPE = new Attributes.Name("FMLModType");
|
||||
private SecureJar.Status securityStatus;
|
||||
@@ -92,11 +92,6 @@ public class ModFile implements IModFile {
|
||||
return modFileInfo.getMods();
|
||||
}
|
||||
|
||||
@Deprecated(forRemoval = true, since = "1.21.11")
|
||||
public Optional<Path> getAccessTransformer() {
|
||||
return Optional.ofNullable(accessTransformer);
|
||||
}
|
||||
|
||||
public List<Path> getAccessTransformers() {
|
||||
return this.accessTransformers;
|
||||
}
|
||||
@@ -111,7 +106,6 @@ public class ModFile implements IModFile {
|
||||
if (cfg == null) {
|
||||
var path = findResource("META-INF", "accesstransformer.cfg");
|
||||
if (Files.exists(path)) {
|
||||
this.accessTransformer = path;
|
||||
this.accessTransformers = List.of(path);
|
||||
}
|
||||
} else if (!cfg.isEmpty()) {
|
||||
@@ -181,9 +175,8 @@ public class ModFile implements IModFile {
|
||||
|
||||
public void identifyLanguage() {
|
||||
var lst = new ArrayList<IModLanguageProvider>(this.modFileInfo.requiredLanguageLoaders().size());
|
||||
var services = FMLLoader.getLanguageLoadingProvider();
|
||||
for (var spec : this.modFileInfo.requiredLanguageLoaders()) {
|
||||
var service = services.findLanguage(this, spec.languageName(), spec.acceptedVersions());
|
||||
var service = LanguageLoadingProvider.findLanguage(this, spec.languageName(), spec.acceptedVersions());
|
||||
lst.add(service);
|
||||
}
|
||||
this.loaders = List.copyOf(lst);
|
||||
|
||||
+7
-7
@@ -31,7 +31,6 @@ public class ModValidator {
|
||||
private final List<ModFile> candidatePlugins;
|
||||
private final List<ModFile> candidateMods;
|
||||
private final List<ModFile> gameLibraries;
|
||||
private LoadingModList loadingModList;
|
||||
private final List<IModFile> brokenFiles = new ArrayList<>();
|
||||
private final List<EarlyLoadingException.ExceptionData> discoveryErrorData;
|
||||
|
||||
@@ -87,7 +86,7 @@ public class ModValidator {
|
||||
// If any detectable error happens during the sorting process {missing deps, duplicates,
|
||||
// This helps prevent coremods/mixins from screwing up us displaying the error screens that the sorting/validation is trying to display.
|
||||
// This won't fix them all as they are still loaded and will still apply but it might help
|
||||
for (var info : this.loadingModList.getModFiles())
|
||||
for (var info : LoadingModList.getModFiles())
|
||||
mods.add(info.getFile().getSecureJar());
|
||||
|
||||
// Add any game libraries, this *may* be duplicates, depending on the state of the sorting. But until I get around to re-writing
|
||||
@@ -124,11 +123,12 @@ public class ModValidator {
|
||||
var allErrors = new ArrayList<>(errors);
|
||||
allErrors.addAll(this.discoveryErrorData);
|
||||
|
||||
loadingModList = ModSorter.sort(candidateMods, allErrors);
|
||||
loadingModList.addAccessTransformers();
|
||||
loadingModList.setBrokenFiles(brokenFiles);
|
||||
BackgroundScanHandler backgroundScanHandler = new BackgroundScanHandler(candidateMods);
|
||||
loadingModList.addForScanning(backgroundScanHandler);
|
||||
ModSorter.sort(candidateMods, allErrors);
|
||||
LoadingModList.getBrokenFiles().addAll(brokenFiles);
|
||||
var backgroundScanHandler = new BackgroundScanHandler(candidateMods);
|
||||
LoadingModList.getModFiles().stream()
|
||||
.map(ModFileInfo::getFile)
|
||||
.forEach(backgroundScanHandler::submitForScanning);
|
||||
return backgroundScanHandler;
|
||||
}
|
||||
}
|
||||
@@ -100,7 +100,7 @@
|
||||
{
|
||||
"class": "net/minecraft/world/entity/npc/villager/Villager",
|
||||
"methods": [
|
||||
"getBreedOffspring(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/entity/AgeableMob;)Lnet/minecraft/world/entity/npc/villager/Villager;"
|
||||
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
+5
-5
@@ -4,12 +4,12 @@ org.gradle.jvmargs=-Xmx6G
|
||||
org.gradle.daemon=false
|
||||
org.gradle.parallel=true
|
||||
|
||||
JAVA_VERSION=21
|
||||
MC_VERSION=1.21.11
|
||||
MC_NEXT_VERSION=1.22
|
||||
MCP_VERSION=20251223.124241
|
||||
JAVA_VERSION=25
|
||||
MC_VERSION=26.1
|
||||
MC_NEXT_VERSION=26.2
|
||||
MCP_VERSION=20260324.123823
|
||||
MAPPING_CHANNEL=official
|
||||
MAPPING_VERSION=1.21.11
|
||||
MAPPING_VERSION=26.1
|
||||
|
||||
# Set to true before the first build of a new MC version, so we don't do compatibility checks
|
||||
CHECK_COMPATIBILITY=false
|
||||
|
||||
-11
@@ -6,7 +6,6 @@
|
||||
package net.minecraftforge.fml.javafmlmod;
|
||||
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.eventbus.api.bus.BusGroup;
|
||||
import net.minecraftforge.eventbus.api.bus.CancellableEventBus;
|
||||
import net.minecraftforge.eventbus.api.bus.EventBus;
|
||||
@@ -52,7 +51,6 @@ public final class AutomaticEventSubscriber {
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
private static final Type AUTO_SUBSCRIBER = Type.getType(EventBusSubscriber.class);
|
||||
private static final Type MOD_TYPE = Type.getType(Mod.class);
|
||||
private static final Type ONLY_IN_TYPE = Type.getType(OnlyIn.class);
|
||||
private static final List<EnumData> DEFAULT_SIDES = List.of(new EnumData(null, "CLIENT"), new EnumData(null, "DEDICATED_SERVER"));
|
||||
private static final EnumData DEFAULT_BUS = new EnumData(null, "BOTH");
|
||||
|
||||
@@ -64,20 +62,11 @@ public final class AutomaticEventSubscriber {
|
||||
.filter(data -> AUTO_SUBSCRIBER.equals(data.annotationType()))
|
||||
.toList();
|
||||
|
||||
var onlyIns = FMLEnvironment.production ? Collections.emptySet() : scanData.getAnnotations().stream()
|
||||
.filter(data -> ONLY_IN_TYPE.equals(data.annotationType()))
|
||||
.map(data -> data.clazz().getClassName())
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
var modids = scanData.getAnnotations().stream()
|
||||
.filter(data -> MOD_TYPE.equals(data.annotationType()))
|
||||
.collect(Collectors.toMap(a -> a.clazz().getClassName(), a -> (String)a.annotationData().get("value")));
|
||||
|
||||
for (var data : targets) {
|
||||
if (!FMLEnvironment.production && onlyIns.contains(data.clazz().getClassName())) {
|
||||
throw new RuntimeException("Found @OnlyIn on @EventBusSubscriber class " + data.clazz().getClassName() + " - this is not allowed as it causes crashes. Remove the OnlyIn and set value=Dist.CLIENT in the EventBusSubscriber annotation instead");
|
||||
}
|
||||
|
||||
var modId = modids.getOrDefault(data.clazz().getClassName(), mod.getModId());
|
||||
modId = value(data, "modid", modId);
|
||||
|
||||
|
||||
+2
-2
@@ -12,8 +12,8 @@ plugins {
|
||||
version = '1.0.0'
|
||||
group = 'com.example.examplemod'
|
||||
|
||||
// Mojang ships Java 21 to end users in 1.20.5+, so your mod should target Java 21.
|
||||
java.toolchain.languageVersion = JavaLanguageVersion.of(21)
|
||||
// Mojang ships Java 25 to end users in 26.1+, so your mod should target Java 25.
|
||||
java.toolchain.languageVersion = JavaLanguageVersion.of(25)
|
||||
|
||||
// Include generated resources
|
||||
sourceSets.main.resources { srcDir 'src/generated/resources' }
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
--- a/com/mojang/blaze3d/opengl/GlCommandEncoder.java
|
||||
+++ b/com/mojang/blaze3d/opengl/GlCommandEncoder.java
|
||||
@@ -133,6 +_,9 @@
|
||||
GlStateManager._colorMask(true, true, true, true);
|
||||
GlStateManager._clear(16384);
|
||||
GlStateManager._glFramebufferTexture2D(36160, 36064, 3553, 0, 0);
|
||||
+ // Forge: if using stencil, clear it as well (3553 = GlConst.GL_TEXTURE_2D)
|
||||
+ if (p_394273_.isStencilEnabled())
|
||||
+ GlStateManager._glFramebufferTexture2D(GlConst.GL_FRAMEBUFFER, org.lwjgl.opengl.GL30.GL_STENCIL_ATTACHMENT, GlConst.GL_TEXTURE_2D, 0, 0);
|
||||
GlStateManager._glBindFramebuffer(36160, 0);
|
||||
}
|
||||
@@ -111,6 +_,9 @@
|
||||
GlStateManager._colorMask(15);
|
||||
GlStateManager._clear(16384);
|
||||
GlStateManager._glFramebufferTexture2D(36160, 36064, 3553, 0, 0);
|
||||
+ // Forge: if using stencil, clear it as well (3553 = GlConst.GL_TEXTURE_2D)
|
||||
+ if (colorTexture.isStencilEnabled())
|
||||
+ GlStateManager._glFramebufferTexture2D(GlConst.GL_FRAMEBUFFER, org.lwjgl.opengl.GL30.GL_STENCIL_ATTACHMENT, GlConst.GL_TEXTURE_2D, 0, 0);
|
||||
GlStateManager._glBindFramebuffer(36160, 0);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
--- a/com/mojang/blaze3d/opengl/GlConst.java
|
||||
+++ b/com/mojang/blaze3d/opengl/GlConst.java
|
||||
@@ -249,6 +_,10 @@
|
||||
}
|
||||
|
||||
public static int toGlInternalId(final TextureFormat textureFormat) {
|
||||
+ return toGlInternalId(textureFormat, false);
|
||||
+ }
|
||||
+ public static int toGlInternalId(final TextureFormat textureFormat, final boolean stencil) {
|
||||
+ if (stencil && textureFormat.hasDepthAspect()) return org.lwjgl.opengl.GL30.GL_DEPTH32F_STENCIL8;
|
||||
return switch (textureFormat) {
|
||||
case RGBA8 -> 32856;
|
||||
case RED8 -> 33321;
|
||||
@@ -258,6 +_,10 @@
|
||||
}
|
||||
|
||||
public static int toGlExternalId(final TextureFormat textureFormat) {
|
||||
+ return toGlExternalId(textureFormat, false);
|
||||
+ }
|
||||
+ public static int toGlExternalId(final TextureFormat textureFormat, final boolean stencil) {
|
||||
+ if (stencil && textureFormat.hasDepthAspect()) return org.lwjgl.opengl.GL30.GL_DEPTH_STENCIL;
|
||||
return switch (textureFormat) {
|
||||
case RGBA8 -> 6408;
|
||||
case RED8 -> 6403;
|
||||
@@ -267,6 +_,10 @@
|
||||
}
|
||||
|
||||
public static int toGlType(final TextureFormat textureFormat) {
|
||||
+ return toGlType(textureFormat, false);
|
||||
+ }
|
||||
+ public static int toGlType(final TextureFormat textureFormat, boolean stencil) {
|
||||
+ if (stencil && textureFormat.hasDepthAspect()) return org.lwjgl.opengl.GL30.GL_FLOAT_32_UNSIGNED_INT_24_8_REV;
|
||||
return switch (textureFormat) {
|
||||
case RGBA8 -> 5121;
|
||||
case RED8 -> 5121;
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/com/mojang/blaze3d/opengl/GlDebug.java
|
||||
+++ b/com/mojang/blaze3d/opengl/GlDebug.java
|
||||
@@ -24,6 +_,14 @@
|
||||
@@ -22,6 +_,14 @@
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class GlDebug {
|
||||
@@ -15,7 +15,7 @@
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
private static final int CIRCULAR_LOG_SIZE = 10;
|
||||
private final Queue<GlDebug.LogEntry> MESSAGE_BUFFER = EvictingQueue.create(10);
|
||||
@@ -105,6 +_,8 @@
|
||||
@@ -103,6 +_,8 @@
|
||||
}
|
||||
|
||||
LOGGER.info("OpenGL debug message: {}", gldebug$logentry);
|
||||
@@ -24,11 +24,21 @@
|
||||
}
|
||||
|
||||
public List<String> getLastOpenGlDebugMessages() {
|
||||
@@ -120,6 +_,7 @@
|
||||
}
|
||||
@@ -126,7 +_,7 @@
|
||||
GlDebug gldebug1 = new GlDebug();
|
||||
enabledExtensions.add("GL_KHR_debug");
|
||||
GL11.glEnable(37600);
|
||||
- if (debugSynchronousGlLogs) {
|
||||
+ if (debugSynchronousGlLogs | PRINT_STACKTRACE_ON_ERROR) {
|
||||
GL11.glEnable(33346);
|
||||
}
|
||||
|
||||
@@ -140,7 +_,7 @@
|
||||
} else if (glcapabilities.GL_ARB_debug_output && GlDevice.USE_GL_ARB_debug_output) {
|
||||
GlDebug gldebug = new GlDebug();
|
||||
enabledExtensions.add("GL_ARB_debug_output");
|
||||
- if (debugSynchronousGlLogs) {
|
||||
+ if (debugSynchronousGlLogs | PRINT_STACKTRACE_ON_ERROR) {
|
||||
GL11.glEnable(33346);
|
||||
}
|
||||
|
||||
public static @Nullable GlDebug enableDebugCallback(int p_394351_, boolean p_393026_, Set<String> p_393339_) {
|
||||
+ p_393026_ |= PRINT_STACKTRACE_ON_ERROR;
|
||||
if (p_394351_ <= 0) {
|
||||
return null;
|
||||
} else {
|
||||
@@ -1,74 +1,54 @@
|
||||
--- a/com/mojang/blaze3d/opengl/GlDevice.java
|
||||
+++ b/com/mojang/blaze3d/opengl/GlDevice.java
|
||||
@@ -124,8 +_,15 @@
|
||||
int p_407582_,
|
||||
int p_408928_
|
||||
@@ -129,7 +_,12 @@
|
||||
final int depthOrLayers,
|
||||
final int mipLevels
|
||||
) {
|
||||
+ return createTexture(p_397830_, p_394481_, p_394839_, p_391831_, p_395609_, p_407582_, p_408928_, false);
|
||||
- return this.createTexture(this.debugLabels.exists() && label != null ? label.get() : null, usage, format, width, height, depthOrLayers, mipLevels);
|
||||
+ return this.createTexture(label, usage, format, width, height, depthOrLayers, mipLevels, false);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public GpuTexture createTexture(
|
||||
+ @Nullable Supplier<String> p_397830_, int p_394481_, TextureFormat p_394839_, int p_391831_, int p_395609_, int p_407582_, int p_408928_, boolean stencil
|
||||
+ ) {
|
||||
return this.createTexture(
|
||||
- this.debugLabels.exists() && p_397830_ != null ? p_397830_.get() : null, p_394481_, p_394839_, p_391831_, p_395609_, p_407582_, p_408928_
|
||||
+ this.debugLabels.exists() && p_397830_ != null ? p_397830_.get() : null, p_394481_, p_394839_, p_391831_, p_395609_, p_407582_, p_408928_, stencil
|
||||
);
|
||||
+ public GpuTexture createTexture(final @Nullable Supplier<String> label, @GpuTexture.Usage final int usage, final TextureFormat format, final int width, final int height, final int depthOrLayers, final int mipLevels, final boolean stencil ) {
|
||||
+ return this.createTexture(this.debugLabels.exists() && label != null ? label.get() : null, usage, format, width, height, depthOrLayers, mipLevels, stencil);
|
||||
}
|
||||
|
||||
@@ -133,6 +_,15 @@
|
||||
public GpuTexture createTexture(
|
||||
@Nullable String p_394142_, @GpuTexture.Usage int p_395535_, TextureFormat p_394951_, int p_393944_, int p_392329_, int p_408015_, int p_406483_
|
||||
@Override
|
||||
@@ -142,6 +_,11 @@
|
||||
final int depthOrLayers,
|
||||
final int mipLevels
|
||||
) {
|
||||
+ return createTexture(p_394142_, p_395535_, p_394951_, p_393944_, p_392329_, p_408015_, p_406483_, false);
|
||||
+ return this.createTexture(label, usage, format, width, height, depthOrLayers, mipLevels, false);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public GpuTexture createTexture(
|
||||
+ @Nullable String p_394142_, @GpuTexture.Usage int p_395535_, TextureFormat p_394951_, int p_393944_, int p_392329_, int p_408015_, int p_406483_, boolean stencil
|
||||
+ ) {
|
||||
+ // Forge: stencil rendering is only for depth
|
||||
+ stencil &= p_394951_.hasDepthAspect();
|
||||
if (p_406483_ < 1) {
|
||||
throw new IllegalArgumentException("mipLevels must be at least 1");
|
||||
} else if (p_408015_ < 1) {
|
||||
@@ -183,11 +_,14 @@
|
||||
GlStateManager._texImage2D(
|
||||
k,
|
||||
l,
|
||||
+ stencil ? org.lwjgl.opengl.GL30.GL_DEPTH32F_STENCIL8 :
|
||||
GlConst.toGlInternalId(p_394951_),
|
||||
p_393944_ >> l,
|
||||
p_392329_ >> l,
|
||||
0,
|
||||
+ stencil ? org.lwjgl.opengl.GL30.GL_DEPTH_STENCIL :
|
||||
GlConst.toGlExternalId(p_394951_),
|
||||
+ stencil ? org.lwjgl.opengl.GL30.GL_FLOAT_32_UNSIGNED_INT_24_8_REV :
|
||||
GlConst.toGlType(p_394951_),
|
||||
null
|
||||
);
|
||||
@@ -198,11 +_,14 @@
|
||||
+ public GpuTexture createTexture(@Nullable String label, @GpuTexture.Usage final int usage, final TextureFormat format, final int width, final int height, final int depthOrLayers, final int mipLevels, boolean stencil) {
|
||||
GlStateManager.clearGlErrors();
|
||||
int i = GlStateManager._genTexture();
|
||||
if (label == null) {
|
||||
@@ -169,14 +_,14 @@
|
||||
for (int k : GlConst.CUBEMAP_TARGETS) {
|
||||
for (int l = 0; l < mipLevels; l++) {
|
||||
GlStateManager._texImage2D(
|
||||
j,
|
||||
i1,
|
||||
+ stencil ? org.lwjgl.opengl.GL30.GL_DEPTH32F_STENCIL8 :
|
||||
GlConst.toGlInternalId(p_394951_),
|
||||
p_393944_ >> i1,
|
||||
p_392329_ >> i1,
|
||||
0,
|
||||
+ stencil ? org.lwjgl.opengl.GL30.GL_DEPTH_STENCIL :
|
||||
GlConst.toGlExternalId(p_394951_),
|
||||
+ stencil ? org.lwjgl.opengl.GL30.GL_FLOAT_32_UNSIGNED_INT_24_8_REV :
|
||||
GlConst.toGlType(p_394951_),
|
||||
null
|
||||
- k, l, GlConst.toGlInternalId(format), width >> l, height >> l, 0, GlConst.toGlExternalId(format), GlConst.toGlType(format), null
|
||||
+ k, l, GlConst.toGlInternalId(format, stencil), width >> l, height >> l, 0, GlConst.toGlExternalId(format, stencil), GlConst.toGlType(format, stencil), null
|
||||
);
|
||||
@@ -215,7 +_,7 @@
|
||||
} else if (j1 != 0) {
|
||||
throw new IllegalStateException("OpenGL error " + j1);
|
||||
} else {
|
||||
- GlTexture gltexture = new GlTexture(p_395535_, p_394142_, p_394951_, p_393944_, p_392329_, p_408015_, p_406483_, i);
|
||||
+ GlTexture gltexture = new GlTexture(p_395535_, p_394142_, p_394951_, p_393944_, p_392329_, p_408015_, p_406483_, i, stencil);
|
||||
this.debugLabels.applyLabel(gltexture);
|
||||
return gltexture;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (int i1 = 0; i1 < mipLevels; i1++) {
|
||||
GlStateManager._texImage2D(
|
||||
- j, i1, GlConst.toGlInternalId(format), width >> i1, height >> i1, 0, GlConst.toGlExternalId(format), GlConst.toGlType(format), null
|
||||
+ j, i1, GlConst.toGlInternalId(format, stencil), width >> i1, height >> i1, 0, GlConst.toGlExternalId(format, stencil), GlConst.toGlType(format, stencil), null
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -187,7 +_,7 @@
|
||||
} else if (j1 != 0) {
|
||||
throw new IllegalStateException("OpenGL error " + j1);
|
||||
} else {
|
||||
- GlTexture gltexture = new GlTexture(usage, label, format, width, height, depthOrLayers, mipLevels, i);
|
||||
+ GlTexture gltexture = new GlTexture(usage, label, format, width, height, depthOrLayers, mipLevels, i, stencil);
|
||||
this.debugLabels.applyLabel(gltexture);
|
||||
return gltexture;
|
||||
}
|
||||
@@ -12,7 +12,7 @@
|
||||
public static void _disableBlend() {
|
||||
RenderSystem.assertOnRenderThread();
|
||||
BLEND.mode.disable();
|
||||
@@ -371,9 +_,17 @@
|
||||
@@ -380,9 +_,17 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,13 +20,13 @@
|
||||
+ public static float lastBrightnessX = 0.0f;
|
||||
+ public static float lastBrightnessY = 0.0f;
|
||||
+
|
||||
public static void _texParameter(int p_393876_, int p_397998_, int p_396741_) {
|
||||
public static void _texParameter(final int target, final int name, final int value) {
|
||||
RenderSystem.assertOnRenderThread();
|
||||
GL11.glTexParameteri(p_393876_, p_397998_, p_396741_);
|
||||
+ if (p_393876_ == GL13.GL_TEXTURE1) {
|
||||
+ lastBrightnessX = p_397998_;
|
||||
+ lastBrightnessY = p_396741_;
|
||||
GL11.glTexParameteri(target, name, value);
|
||||
+ if (target == GL13.GL_TEXTURE1) {
|
||||
+ lastBrightnessX = name;
|
||||
+ lastBrightnessY = value;
|
||||
+ }
|
||||
}
|
||||
|
||||
public static int _getTexLevelParameter(int p_393352_, int p_397204_, int p_396319_) {
|
||||
public static int _getTexLevelParameter(final int target, final int level, final int name) {
|
||||
@@ -1,20 +1,20 @@
|
||||
--- a/com/mojang/blaze3d/opengl/GlTexture.java
|
||||
+++ b/com/mojang/blaze3d/opengl/GlTexture.java
|
||||
@@ -21,8 +_,13 @@
|
||||
protected GlTexture(
|
||||
@GpuTexture.Usage int p_394590_, String p_393950_, TextureFormat p_392837_, int p_391379_, int p_391947_, int p_396659_, int p_408255_, int p_408889_
|
||||
@@ -28,8 +_,13 @@
|
||||
final int mipLevels,
|
||||
final int id
|
||||
) {
|
||||
+ this(p_394590_, p_393950_, p_392837_, p_391379_, p_391947_, p_396659_, p_408255_, p_408889_, false);
|
||||
+ this(usage, label, format, width, height, depthOrLayers, mipLevels, id, false);
|
||||
+ }
|
||||
+
|
||||
+ protected GlTexture(int p_394590_, String p_393950_, TextureFormat p_392837_, int p_391379_, int p_391947_, int p_396659_, int p_408255_, int p_408889_, boolean stencil) {
|
||||
super(p_394590_, p_393950_, p_392837_, p_391379_, p_391947_, p_396659_, p_408255_);
|
||||
this.id = p_408889_;
|
||||
+ protected GlTexture(int usage, String label, TextureFormat format, int width, int height, int depthOrLayers, int mipLevels, int id, boolean stencil) {
|
||||
super(usage, label, format, width, height, depthOrLayers, mipLevels);
|
||||
this.id = id;
|
||||
+ this.stencilEnabled = stencil;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -89,5 +_,12 @@
|
||||
@@ -96,5 +_,12 @@
|
||||
if (this.closed && this.views == 0) {
|
||||
this.destroyImmediately();
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
--- a/com/mojang/blaze3d/pipeline/RenderTarget.java
|
||||
+++ b/com/mojang/blaze3d/pipeline/RenderTarget.java
|
||||
@@ -80,7 +_,7 @@
|
||||
this.width = p_83951_;
|
||||
this.height = p_83952_;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
if (this.useDepth) {
|
||||
- this.depthTexture = gpudevice.createTexture(() -> this.label + " / Depth", 15, TextureFormat.DEPTH32, p_83951_, p_83952_, 1, 1);
|
||||
+ this.depthTexture = gpudevice.createTexture(() -> this.label + " / Depth", 15, TextureFormat.DEPTH32, p_83951_, p_83952_, 1, 1, this.stencilEnabled);
|
||||
- this.depthTexture = gpudevice.createTexture(() -> this.label + " / Depth", 15, TextureFormat.DEPTH32, width, height, 1, 1);
|
||||
+ this.depthTexture = gpudevice.createTexture(() -> this.label + " / Depth", 15, TextureFormat.DEPTH32, width, height, 1, 1, this.stencilEnabled);
|
||||
this.depthTextureView = gpudevice.createTextureView(this.depthTexture);
|
||||
}
|
||||
|
||||
@@ -126,5 +_,26 @@
|
||||
@@ -124,5 +_,26 @@
|
||||
|
||||
public @Nullable GpuTextureView getDepthTextureView() {
|
||||
return this.depthTextureView;
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
--- a/com/mojang/blaze3d/platform/Window.java
|
||||
+++ b/com/mojang/blaze3d/platform/Window.java
|
||||
@@ -91,7 +_,8 @@
|
||||
GLFW.glfwWindowHint(139267, 3);
|
||||
GLFW.glfwWindowHint(139272, 204801);
|
||||
GLFW.glfwWindowHint(139270, 1);
|
||||
- this.handle = GLFW.glfwCreateWindow(this.width, this.height, p_85376_, this.fullscreen && monitor != null ? monitor.getMonitor() : 0L, 0L);
|
||||
+ this.handle = net.minecraftforge.fml.loading.ImmediateWindowHandler.setupMinecraftWindow(()->this.width, ()->this.height, ()->p_85376_, ()->this.fullscreen && monitor != null ? monitor.getMonitor() : 0L);
|
||||
@@ -97,8 +_,9 @@
|
||||
Monitor monitor = this.screenManager.getMonitor(GLFW.glfwGetPrimaryMonitor());
|
||||
this.windowedWidth = this.width = allowedWindowMinSize(displayData.width());
|
||||
this.windowedHeight = this.height = allowedWindowMinSize(displayData.height());
|
||||
- this.handle = this.createWindow(backend, this.width, this.height, title, this.fullscreen && monitor != null ? monitor.getMonitor() : 0L);
|
||||
+ this.handle = net.minecraftforge.fml.loading.ImmediateWindowHandler.setupMinecraftWindow(this.width, this.height, title, this.fullscreen && monitor != null ? monitor.getMonitor() : 0L, () -> backend);
|
||||
this.backend = backend;
|
||||
+ if (!net.minecraftforge.fml.loading.ImmediateWindowHandler.positionWindow(Optional.ofNullable(monitor), w->this.width = this.windowedWidth = w, h->this.height = this.windowedHeight = h, x->this.x = this.windowedX = x, y->this.y = this.windowedY = y)) {
|
||||
if (monitor != null) {
|
||||
VideoMode videomode = monitor.getPreferredVidMode(this.fullscreen ? this.preferredFullscreenVideoMode : Optional.empty());
|
||||
this.windowedX = this.x = monitor.getX() + videomode.getWidth() / 2 - this.width / 2;
|
||||
@@ -103,6 +_,7 @@
|
||||
@@ -110,6 +_,7 @@
|
||||
this.windowedX = this.x = aint1[0];
|
||||
this.windowedY = this.y = aint[0];
|
||||
}
|
||||
@@ -18,7 +19,7 @@
|
||||
|
||||
this.setMode();
|
||||
this.refreshFramebufferSize();
|
||||
@@ -269,6 +_,9 @@
|
||||
@@ -300,6 +_,9 @@
|
||||
GLFW.glfwGetFramebufferSize(this.handle, aint, aint1);
|
||||
this.framebufferWidth = aint[0] > 0 ? aint[0] : 1;
|
||||
this.framebufferHeight = aint1[0] > 0 ? aint1[0] : 1;
|
||||
@@ -27,4 +28,4 @@
|
||||
+ }
|
||||
}
|
||||
|
||||
private void onResize(long p_85428_, int p_85429_, int p_85430_) {
|
||||
private void onResize(final long handle, final int newWidth, final int newHeight) {
|
||||
@@ -1,22 +1,46 @@
|
||||
--- a/com/mojang/blaze3d/systems/GpuDevice.java
|
||||
+++ b/com/mojang/blaze3d/systems/GpuDevice.java
|
||||
@@ -36,9 +_,19 @@
|
||||
int p_407070_
|
||||
);
|
||||
@@ -61,6 +_,21 @@
|
||||
return this.backend.createTexture(label, usage, format, width, height, depthOrLayers, mipLevels);
|
||||
}
|
||||
|
||||
+ /** Forge: same as {@link #createTexture(Supplier, int, TextureFormat, int, int, int)} but with stencil support */
|
||||
+ default GpuTexture createTexture(@Nullable Supplier<String> p_394357_, int p_395623_, TextureFormat p_395807_, int p_395802_, int p_396157_, int p_408810_, int p_407070_, boolean stencil) {
|
||||
+ return this.createTexture(p_394357_, p_395623_, p_395807_, p_395802_, p_396157_, p_408810_, p_407070_);
|
||||
+ public GpuTexture createTexture(
|
||||
+ final @Nullable Supplier<String> label,
|
||||
+ @GpuTexture.Usage final int usage,
|
||||
+ final TextureFormat format,
|
||||
+ final int width,
|
||||
+ final int height,
|
||||
+ final int depthOrLayers,
|
||||
+ final int mipLevels,
|
||||
+ final boolean stencil
|
||||
+ ) {
|
||||
+ this.verifyTextureCreationArgs(usage, width, height, depthOrLayers, mipLevels);
|
||||
+ return this.backend.createTexture(label, usage, format, width, height, depthOrLayers, mipLevels, stencil);
|
||||
+ }
|
||||
+
|
||||
GpuTexture createTexture(
|
||||
@Nullable String p_391798_, @GpuTexture.Usage int p_391800_, TextureFormat p_393333_, int p_395600_, int p_394065_, int p_408732_, int p_407125_
|
||||
);
|
||||
+
|
||||
+ /** Forge: same as {@link #createTexture(String, int, TextureFormat, int, int, int)} but with stencil support */
|
||||
+ default GpuTexture createTexture(@Nullable String p_391798_, int p_391800_, TextureFormat p_393333_, int p_395600_, int p_394065_, int p_408732_, int p_407125_, boolean stencil) {
|
||||
+ return this.createTexture(p_391798_, p_391800_, p_393333_, p_395600_, p_394065_, p_408732_, p_407125_);
|
||||
public GpuTexture createTexture(
|
||||
final @Nullable String label,
|
||||
@GpuTexture.Usage final int usage,
|
||||
@@ -72,6 +_,21 @@
|
||||
) {
|
||||
this.verifyTextureCreationArgs(usage, width, height, depthOrLayers, mipLevels);
|
||||
return this.backend.createTexture(label, usage, format, width, height, depthOrLayers, mipLevels);
|
||||
+ }
|
||||
+
|
||||
+ /** Forge: same as {@link #createTexture(Supplier, int, TextureFormat, int, int, int)} but with stencil support */
|
||||
+ public GpuTexture createTexture(
|
||||
+ final @Nullable String label,
|
||||
+ @GpuTexture.Usage final int usage,
|
||||
+ final TextureFormat format,
|
||||
+ final int width,
|
||||
+ final int height,
|
||||
+ final int depthOrLayers,
|
||||
+ final int mipLevels,
|
||||
+ final boolean stencil
|
||||
+ ) {
|
||||
+ this.verifyTextureCreationArgs(usage, width, height, depthOrLayers, mipLevels);
|
||||
+ return this.backend.createTexture(label, usage, format, width, height, depthOrLayers, mipLevels, stencil);
|
||||
}
|
||||
|
||||
GpuTextureView createTextureView(GpuTexture p_409045_);
|
||||
|
||||
private void verifyTextureCreationArgs(@GpuTexture.Usage final int usage, final int width, final int height, final int depthOrLayers, final int mipLevels) {
|
||||
@@ -0,0 +1,22 @@
|
||||
--- a/com/mojang/blaze3d/systems/GpuDeviceBackend.java
|
||||
+++ b/com/mojang/blaze3d/systems/GpuDeviceBackend.java
|
||||
@@ -30,9 +_,19 @@
|
||||
@Nullable Supplier<String> label, @GpuTexture.Usage final int usage, TextureFormat format, int width, int height, int depthOrLayers, int mipLevels
|
||||
);
|
||||
|
||||
+ /** Forge: same as {@link #createTexture(Supplier<String>, int, TextureFormat, int, int, int)} but with stencil support */
|
||||
+ default GpuTexture createTexture(@Nullable Supplier<String> label, @GpuTexture.Usage final int usage, TextureFormat format, int width, int height, int depthOrLayers, int mipLevels, boolean stencil) {
|
||||
+ return createTexture(label, usage, format, width, height, depthOrLayers, mipLevels);
|
||||
+ }
|
||||
+
|
||||
GpuTexture createTexture(
|
||||
@Nullable String label, @GpuTexture.Usage final int usage, TextureFormat format, int width, int height, int depthOrLayers, int mipLevels
|
||||
);
|
||||
+
|
||||
+ /** Forge: same as {@link #createTexture(String, int, TextureFormat, int, int, int)} but with stencil support */
|
||||
+ default GpuTexture createTexture(@Nullable String label, @GpuTexture.Usage final int usage, TextureFormat format, int width, int height, int depthOrLayers, int mipLevels, boolean stencil) {
|
||||
+ return createTexture(label, usage, format, width, height, depthOrLayers, mipLevels);
|
||||
+ }
|
||||
|
||||
GpuTextureView createTextureView(GpuTexture texture);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
--- a/com/mojang/blaze3d/textures/GpuTexture.java
|
||||
+++ b/com/mojang/blaze3d/textures/GpuTexture.java
|
||||
@@ -10,7 +_,7 @@
|
||||
@@ -8,7 +_,7 @@
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@DontObfuscate
|
||||
-public abstract class GpuTexture implements AutoCloseable {
|
||||
+public abstract class GpuTexture implements AutoCloseable, net.minecraftforge.client.extensions.IForgeGpuTexture {
|
||||
public static final int USAGE_COPY_DST = 1;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/com/mojang/blaze3d/vertex/PoseStack.java
|
||||
+++ b/com/mojang/blaze3d/vertex/PoseStack.java
|
||||
@@ -15,7 +_,7 @@
|
||||
@@ -16,7 +_,7 @@
|
||||
import org.joml.Vector3fc;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
--- a/com/mojang/blaze3d/vertex/VertexConsumer.java
|
||||
+++ b/com/mojang/blaze3d/vertex/VertexConsumer.java
|
||||
@@ -14,7 +_,7 @@
|
||||
import org.joml.Vector3fc;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
-public interface VertexConsumer {
|
||||
+public interface VertexConsumer extends net.minecraftforge.client.extensions.IForgeVertexConsumer {
|
||||
VertexConsumer addVertex(float p_344294_, float p_342213_, float p_344859_);
|
||||
|
||||
VertexConsumer setColor(int p_342749_, int p_344324_, int p_343336_, int p_342831_);
|
||||
@@ -1,36 +1,27 @@
|
||||
--- a/com/mojang/blaze3d/vertex/VertexFormat.java
|
||||
+++ b/com/mojang/blaze3d/vertex/VertexFormat.java
|
||||
@@ -20,7 +_,7 @@
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@DontObfuscate
|
||||
-public class VertexFormat {
|
||||
+public class VertexFormat implements net.minecraftforge.client.extensions.IForgeVertexFormat {
|
||||
public static final int UNKNOWN_ELEMENT = -1;
|
||||
private final List<VertexFormatElement> elements;
|
||||
private final List<String> names;
|
||||
@@ -29,6 +_,7 @@
|
||||
private final int[] offsetsByElement = new int[32];
|
||||
private @Nullable GpuBuffer immediateDrawVertexBuffer;
|
||||
private @Nullable GpuBuffer immediateDrawIndexBuffer;
|
||||
+ private final com.google.common.collect.ImmutableMap<String, VertexFormatElement> elementMapping;
|
||||
|
||||
VertexFormat(List<VertexFormatElement> p_343616_, List<String> p_345241_, IntList p_345522_, int p_344162_) {
|
||||
this.elements = p_343616_;
|
||||
private VertexFormat(final List<VertexFormatElement> elements, final List<String> names, final IntList offsets, final int vertexSize) {
|
||||
this.elements = elements;
|
||||
@@ -41,6 +_,11 @@
|
||||
int j = vertexformatelement != null ? p_343616_.indexOf(vertexformatelement) : -1;
|
||||
this.offsetsByElement[i] = j != -1 ? p_345522_.getInt(j) : -1;
|
||||
int j = vertexformatelement != null ? elements.indexOf(vertexformatelement) : -1;
|
||||
this.offsetsByElement[i] = j != -1 ? offsets.getInt(j) : -1;
|
||||
}
|
||||
+
|
||||
+ ImmutableMap.Builder<String, VertexFormatElement> elements = ImmutableMap.builder();
|
||||
+ for (int i = 0; i < p_343616_.size(); i++)
|
||||
+ elements.put(p_345241_.get(i), p_343616_.get(i));
|
||||
+ this.elementMapping = elements.buildOrThrow();
|
||||
+ ImmutableMap.Builder<String, VertexFormatElement> elementMapping = ImmutableMap.builder();
|
||||
+ for (int i = 0; i < elements.size(); i++)
|
||||
+ elementMapping.put(names.get(i), elements.get(i));
|
||||
+ this.elementMapping = elementMapping.buildOrThrow();
|
||||
}
|
||||
|
||||
public static VertexFormat.Builder builder() {
|
||||
@@ -139,6 +_,9 @@
|
||||
this.immediateDrawIndexBuffer = uploadToBuffer(this.immediateDrawIndexBuffer, p_391835_, 72, () -> "Immediate index buffer for " + this);
|
||||
this.immediateDrawIndexBuffer = uploadToBuffer(this.immediateDrawIndexBuffer, buffer, 72, () -> "Immediate index buffer for " + this);
|
||||
return this.immediateDrawIndexBuffer;
|
||||
}
|
||||
+
|
||||
@@ -38,4 +29,4 @@
|
||||
+ public int getOffset(int index) { return offsetsByElement[index]; }
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@DontObfuscate
|
||||
public static class Builder {
|
||||
@@ -1,17 +1,17 @@
|
||||
--- a/com/mojang/math/Transformation.java
|
||||
+++ b/com/mojang/math/Transformation.java
|
||||
@@ -16,7 +_,7 @@
|
||||
@@ -17,7 +_,7 @@
|
||||
import org.joml.Vector3fc;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
-public final class Transformation {
|
||||
+public final class Transformation implements net.minecraftforge.common.extensions.IForgeTransformation {
|
||||
private final Matrix4fc matrix;
|
||||
public static final Codec<Transformation> CODEC = RecordCodecBuilder.create(
|
||||
p_269604_ -> p_269604_.group(
|
||||
@@ -168,5 +_,19 @@
|
||||
this.getScale().lerp(p_175938_.getScale(), p_175939_, new Vector3f()),
|
||||
this.getRightRotation().slerp(p_175938_.getRightRotation(), p_175939_, new Quaternionf())
|
||||
private static final Vector3fc ZERO_TRANSLATION = new Vector3f();
|
||||
private static final Vector3fc UNIT_SCALE = new Vector3f(1.0F, 1.0F, 1.0F);
|
||||
private static final Quaternionfc ZERO_ROTATION = new Quaternionf();
|
||||
@@ -172,6 +_,20 @@
|
||||
this.scale().lerp(that.scale(), progress, new Vector3f()),
|
||||
this.rightRotation().slerp(that.rightRotation(), progress, new Quaternionf())
|
||||
);
|
||||
+ }
|
||||
+
|
||||
@@ -28,4 +28,5 @@
|
||||
+ normalTransform.transpose();
|
||||
+ }
|
||||
}
|
||||
}
|
||||
|
||||
public static Matrix4fc compose(final Matrix4fc parent, final Optional<Transformation> transform) {
|
||||
+4
-4
@@ -1,6 +1,6 @@
|
||||
--- a/com/mojang/realmsclient/gui/screens/RealmsGenericErrorScreen.java
|
||||
+++ b/com/mojang/realmsclient/gui/screens/RealmsGenericErrorScreen.java
|
||||
@@ -62,6 +_,15 @@
|
||||
@@ -60,6 +_,15 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -13,6 +13,6 @@
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
public void render(GuiGraphics p_283497_, int p_88680_, int p_88681_, float p_88682_) {
|
||||
super.render(p_283497_, p_88680_, p_88681_, p_88682_);
|
||||
p_283497_.drawCenteredString(this.font, this.title, this.width / 2, 80, -1);
|
||||
public void extractRenderState(final GuiGraphicsExtractor graphics, final int xm, final int ym, final float a) {
|
||||
super.extractRenderState(graphics, xm, ym, a);
|
||||
graphics.centeredText(this.font, this.title, this.width / 2, 80, -1);
|
||||
+4
-4
@@ -1,11 +1,11 @@
|
||||
--- a/com/mojang/realmsclient/gui/screens/RealmsResetWorldScreen.java
|
||||
+++ b/com/mojang/realmsclient/gui/screens/RealmsResetWorldScreen.java
|
||||
@@ -263,7 +_,7 @@
|
||||
@@ -303,7 +_,7 @@
|
||||
int k = this.getY();
|
||||
p_282595_.blit(RenderPipelines.GUI_TEXTURED, this.image, j + 2, k + 2, 0.0F, 0.0F, 56, 56, 56, 56, 56, 56, i);
|
||||
p_282595_.blitSprite(RenderPipelines.GUI_TEXTURED, SLOT_FRAME_SPRITE, j, k, 60, 60, i);
|
||||
graphics.blit(RenderPipelines.GUI_TEXTURED, this.image, j + 2, k + 2, 0.0F, 0.0F, 56, 56, 56, 56, 56, 56, i);
|
||||
graphics.blitSprite(RenderPipelines.GUI_TEXTURED, SLOT_FRAME_SPRITE, j, k, 60, 60, i);
|
||||
- int l = flag ? -6250336 : -1;
|
||||
+ int l = getFGColor();
|
||||
p_282595_.drawCenteredString(RealmsResetWorldScreen.this.font, this.getMessage(), j + 28, k - 14, l);
|
||||
graphics.centeredText(RealmsResetWorldScreen.this.font, this.getMessage(), j + 28, k - 14, l);
|
||||
}
|
||||
}
|
||||
@@ -2,28 +2,28 @@
|
||||
+++ b/net/minecraft/CrashReport.java
|
||||
@@ -58,14 +_,9 @@
|
||||
if (this.uncategorizedStackTrace != null && this.uncategorizedStackTrace.length > 0) {
|
||||
p_127520_.append("-- Head --\n");
|
||||
p_127520_.append("Thread: ").append(Thread.currentThread().getName()).append("\n");
|
||||
- p_127520_.append("Stacktrace:\n");
|
||||
builder.append("-- Head --\n");
|
||||
builder.append("Thread: ").append(Thread.currentThread().getName()).append("\n");
|
||||
- builder.append("Stacktrace:\n");
|
||||
-
|
||||
- for (StackTraceElement stacktraceelement : this.uncategorizedStackTrace) {
|
||||
- p_127520_.append("\t").append("at ").append(stacktraceelement);
|
||||
- p_127520_.append("\n");
|
||||
- builder.append("\t").append("at ").append(stacktraceelement);
|
||||
- builder.append("\n");
|
||||
- }
|
||||
-
|
||||
- p_127520_.append("\n");
|
||||
+ p_127520_.append(net.minecraftforge.logging.CrashReportAnalyser.appendSuspectedMods(this.exception, this.uncategorizedStackTrace));
|
||||
+ p_127520_.append("Stacktrace:");
|
||||
+ p_127520_.append(net.minecraftforge.logging.CrashReportExtender.generateEnhancedStackTrace(this.uncategorizedStackTrace));
|
||||
- builder.append("\n");
|
||||
+ builder.append(net.minecraftforge.logging.CrashReportAnalyser.appendSuspectedMods(this.exception, this.uncategorizedStackTrace));
|
||||
+ builder.append("Stacktrace:");
|
||||
+ builder.append(net.minecraftforge.logging.CrashReportExtender.generateEnhancedStackTrace(this.uncategorizedStackTrace));
|
||||
}
|
||||
|
||||
for (CrashReportCategory crashreportcategory : this.details) {
|
||||
@@ -73,6 +_,7 @@
|
||||
p_127520_.append("\n\n");
|
||||
builder.append("\n\n");
|
||||
}
|
||||
|
||||
+ net.minecraftforge.logging.CrashReportExtender.extendSystemReport(systemReport);
|
||||
this.systemReport.appendToCrashReportString(p_127520_);
|
||||
this.systemReport.appendToCrashReportString(builder);
|
||||
}
|
||||
|
||||
@@ -92,18 +_,7 @@
|
||||
@@ -45,4 +45,4 @@
|
||||
+ return net.minecraftforge.logging.CrashReportExtender.generateEnhancedStackTrace(throwable);
|
||||
}
|
||||
|
||||
public String getFriendlyReport(ReportType p_343869_, List<String> p_342487_) {
|
||||
public String getFriendlyReport(final ReportType reportType, final List<String> extraComments) {
|
||||
@@ -1,28 +1,28 @@
|
||||
--- a/net/minecraft/CrashReportCategory.java
|
||||
+++ b/net/minecraft/CrashReportCategory.java
|
||||
@@ -116,8 +_,10 @@
|
||||
@@ -114,8 +_,10 @@
|
||||
if (astacktraceelement.length <= 0) {
|
||||
return 0;
|
||||
} else {
|
||||
- this.stackTrace = new StackTraceElement[astacktraceelement.length - 3 - p_128149_];
|
||||
- System.arraycopy(astacktraceelement, 3 + p_128149_, this.stackTrace, 0, this.stackTrace.length);
|
||||
+ int len = astacktraceelement.length - 3 - p_128149_;
|
||||
- this.stackTrace = new StackTraceElement[astacktraceelement.length - 3 - nestedOffset];
|
||||
- System.arraycopy(astacktraceelement, 3 + nestedOffset, this.stackTrace, 0, this.stackTrace.length);
|
||||
+ int len = astacktraceelement.length - 3 - nestedOffset;
|
||||
+ if (len <= 0) len = astacktraceelement.length;
|
||||
+ this.stackTrace = new StackTraceElement[len];
|
||||
+ System.arraycopy(astacktraceelement, astacktraceelement.length - len, this.stackTrace, 0, this.stackTrace.length);
|
||||
return this.stackTrace.length;
|
||||
}
|
||||
}
|
||||
@@ -164,16 +_,16 @@
|
||||
@@ -162,16 +_,16 @@
|
||||
|
||||
if (this.stackTrace != null && this.stackTrace.length > 0) {
|
||||
p_128169_.append("\nStacktrace:");
|
||||
builder.append("\nStacktrace:");
|
||||
-
|
||||
- for (StackTraceElement stacktraceelement : this.stackTrace) {
|
||||
- p_128169_.append("\n\tat ");
|
||||
- p_128169_.append(stacktraceelement);
|
||||
- builder.append("\n\tat ");
|
||||
- builder.append(stacktraceelement);
|
||||
- }
|
||||
+ p_128169_.append(net.minecraftforge.logging.CrashReportExtender.generateEnhancedStackTrace(this.stackTrace));
|
||||
+ builder.append(net.minecraftforge.logging.CrashReportExtender.generateEnhancedStackTrace(this.stackTrace));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,4 +34,4 @@
|
||||
+ this.stackTrace = t.getStackTrace();
|
||||
}
|
||||
|
||||
public static void populateBlockDetails(CrashReportCategory p_178951_, LevelHeightAccessor p_178952_, BlockPos p_178953_, BlockState p_178954_) {
|
||||
public static void populateBlockDetails(
|
||||
@@ -1,15 +1,15 @@
|
||||
--- a/net/minecraft/advancements/Advancement.java
|
||||
+++ b/net/minecraft/advancements/Advancement.java
|
||||
@@ -231,7 +_,11 @@
|
||||
@@ -227,7 +_,11 @@
|
||||
}
|
||||
|
||||
public AdvancementHolder save(Consumer<AdvancementHolder> p_138390_, String p_138391_) {
|
||||
- AdvancementHolder advancementholder = this.build(Identifier.parse(p_138391_));
|
||||
+ return save(p_138390_, Identifier.parse(p_138391_));
|
||||
public AdvancementHolder save(final Consumer<AdvancementHolder> output, final String name) {
|
||||
- AdvancementHolder advancementholder = this.build(Identifier.parse(name));
|
||||
+ return save(output, Identifier.parse(name));
|
||||
+ }
|
||||
+
|
||||
+ public AdvancementHolder save(Consumer<AdvancementHolder> p_138390_, Identifier id) {
|
||||
+ public AdvancementHolder save(Consumer<AdvancementHolder> output, Identifier id) {
|
||||
+ AdvancementHolder advancementholder = this.build(id);
|
||||
p_138390_.accept(advancementholder);
|
||||
output.accept(advancementholder);
|
||||
return advancementholder;
|
||||
}
|
||||
@@ -2,9 +2,9 @@
|
||||
+++ b/net/minecraft/advancements/AdvancementRewards.java
|
||||
@@ -44,6 +_,7 @@
|
||||
LootParams lootparams = new LootParams.Builder(serverlevel)
|
||||
.withParameter(LootContextParams.THIS_ENTITY, p_9990_)
|
||||
.withParameter(LootContextParams.ORIGIN, p_9990_.position())
|
||||
+ .withLuck(p_9990_.getLuck())
|
||||
.withParameter(LootContextParams.THIS_ENTITY, player)
|
||||
.withParameter(LootContextParams.ORIGIN, player.position())
|
||||
+ .withLuck(player.getLuck())
|
||||
.create(LootContextParamSets.ADVANCEMENT_REWARD);
|
||||
boolean flag = false;
|
||||
|
||||
@@ -1,21 +1,38 @@
|
||||
--- a/net/minecraft/client/Camera.java
|
||||
+++ b/net/minecraft/client/Camera.java
|
||||
@@ -136,9 +_,13 @@
|
||||
@@ -217,12 +_,14 @@
|
||||
return 90.0F;
|
||||
} else {
|
||||
float f = this.minecraft.options.fov().get().intValue() * Mth.lerp(partialTicks, this.oldFovModifier, this.fovModifier);
|
||||
- return this.modifyFovBasedOnDeathOrFluid(partialTicks, f);
|
||||
+ var ret = this.modifyFovBasedOnDeathOrFluid(partialTicks, f);
|
||||
+ return net.minecraftforge.client.event.ForgeEventFactoryClient.fireComputeFov(this.minecraft.gameRenderer, this, partialTicks, ret, true).getFOV();
|
||||
}
|
||||
}
|
||||
|
||||
protected void setRotation(float p_90573_, float p_90574_) {
|
||||
+ setRotation(p_90573_, p_90574_, 0.0f);
|
||||
private float calculateHudFov(final float partialTicks) {
|
||||
- return this.modifyFovBasedOnDeathOrFluid(partialTicks, 70.0F);
|
||||
+ var ret = this.modifyFovBasedOnDeathOrFluid(partialTicks, 70.0F);
|
||||
+ return net.minecraftforge.client.event.ForgeEventFactoryClient.fireComputeFov(this.minecraft.gameRenderer, this, partialTicks, ret, false).getFOV();
|
||||
}
|
||||
|
||||
private float modifyFovBasedOnDeathOrFluid(final float partialTicks, float fov) {
|
||||
@@ -331,9 +_,13 @@
|
||||
}
|
||||
|
||||
protected void setRotation(final float yRot, final float xRot) {
|
||||
+ setRotation(yRot, xRot, 0.0f);
|
||||
+ }
|
||||
+
|
||||
+ public void setRotation(float p_90573_, float p_90574_, float z) {
|
||||
this.xRot = p_90574_;
|
||||
this.yRot = p_90573_;
|
||||
- this.rotation.rotationYXZ((float) Math.PI - p_90573_ * (float) (Math.PI / 180.0), -p_90574_ * (float) (Math.PI / 180.0), 0.0F);
|
||||
+ this.rotation.rotationYXZ((float) Math.PI - p_90573_ * (float) (Math.PI / 180.0), -p_90574_ * (float) (Math.PI / 180.0), z * (float) (Math.PI / 180.0));
|
||||
+ public void setRotation(float yRot, float xRot, float z) {
|
||||
this.xRot = xRot;
|
||||
this.yRot = yRot;
|
||||
- this.rotation.rotationYXZ((float) Math.PI - yRot * (float) (Math.PI / 180.0), -xRot * (float) (Math.PI / 180.0), 0.0F);
|
||||
+ this.rotation.rotationYXZ((float) Math.PI - yRot * (float) (Math.PI / 180.0), -xRot * (float) (Math.PI / 180.0), z * (float) (Math.PI / 180.0));
|
||||
FORWARDS.rotate(this.rotation, this.forwards);
|
||||
UP.rotate(this.rotation, this.up);
|
||||
LEFT.rotate(this.rotation, this.left);
|
||||
@@ -168,6 +_,13 @@
|
||||
@@ -364,6 +_,13 @@
|
||||
|
||||
public float yRot() {
|
||||
return this.yRot;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
--- a/net/minecraft/client/ClientBrandRetriever.java
|
||||
+++ b/net/minecraft/client/ClientBrandRetriever.java
|
||||
@@ -10,6 +_,6 @@
|
||||
@@ -8,6 +_,6 @@
|
||||
public static final String VANILLA_NAME = "vanilla";
|
||||
|
||||
@DontObfuscate
|
||||
public static String getClientModName() {
|
||||
- return "vanilla";
|
||||
+ return net.minecraftforge.internal.BrandingControl.getBranding();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/client/DeltaTracker.java
|
||||
+++ b/net/minecraft/client/DeltaTracker.java
|
||||
@@ -87,18 +_,22 @@
|
||||
@@ -82,18 +_,22 @@
|
||||
|
||||
private void pause() {
|
||||
if (!this.paused) {
|
||||
@@ -22,4 +22,4 @@
|
||||
+ net.minecraftforge.client.ForgeHooksClient.onClientPauseChangePost(false);
|
||||
}
|
||||
|
||||
public void updateFrozenState(boolean p_344005_) {
|
||||
public void updateFrozenState(final boolean frozen) {
|
||||
@@ -15,12 +15,12 @@
|
||||
@@ -39,7 +_,7 @@
|
||||
}
|
||||
|
||||
private static void forAllKeyMappings(InputConstants.Key p_424096_, Consumer<KeyMapping> p_427756_) {
|
||||
- List<KeyMapping> list = MAP.get(p_424096_);
|
||||
+ List<KeyMapping> list = MAP.getAll(p_424096_);
|
||||
private static void forAllKeyMappings(final InputConstants.Key key, final Consumer<KeyMapping> operation) {
|
||||
- List<KeyMapping> list = MAP.get(key);
|
||||
+ List<KeyMapping> list = MAP.getAll(key);
|
||||
if (list != null && !list.isEmpty()) {
|
||||
for (KeyMapping keymapping : list) {
|
||||
p_427756_.accept(keymapping);
|
||||
operation.accept(keymapping);
|
||||
@@ -106,7 +_,7 @@
|
||||
}
|
||||
|
||||
@@ -30,12 +30,12 @@
|
||||
}
|
||||
|
||||
public KeyMapping.Category getCategory() {
|
||||
@@ -149,8 +_,17 @@
|
||||
? I18n.get(this.name).compareTo(I18n.get(p_90841_.name))
|
||||
: Integer.compare(this.order, p_90841_.order);
|
||||
@@ -147,8 +_,17 @@
|
||||
if (this.category == o.category) {
|
||||
return this.order == o.order ? I18n.get(this.name).compareTo(I18n.get(o.name)) : Integer.compare(this.order, o.order);
|
||||
} else {
|
||||
- return Integer.compare(KeyMapping.Category.SORT_ORDER.indexOf(this.category), KeyMapping.Category.SORT_ORDER.indexOf(p_90841_.category));
|
||||
+ return compareSort(this.category, p_90841_.category);
|
||||
- return Integer.compare(KeyMapping.Category.SORT_ORDER.indexOf(this.category), KeyMapping.Category.SORT_ORDER.indexOf(o.category));
|
||||
+ return compareSort(this.category, o.category);
|
||||
}
|
||||
+ }
|
||||
+
|
||||
@@ -48,17 +48,17 @@
|
||||
+ return o1 - o2;
|
||||
}
|
||||
|
||||
public static Supplier<Component> createNameSupplier(String p_90843_) {
|
||||
@@ -159,6 +_,20 @@
|
||||
public static Supplier<Component> createNameSupplier(final String key) {
|
||||
@@ -157,6 +_,20 @@
|
||||
}
|
||||
|
||||
public boolean same(KeyMapping p_90851_) {
|
||||
+ if (getKeyConflictContext().conflicts(p_90851_.getKeyConflictContext()) || p_90851_.getKeyConflictContext().conflicts(getKeyConflictContext())) {
|
||||
public boolean same(final KeyMapping that) {
|
||||
+ if (getKeyConflictContext().conflicts(that.getKeyConflictContext()) || that.getKeyConflictContext().conflicts(getKeyConflictContext())) {
|
||||
+ var keyModifier = getKeyModifier();
|
||||
+ var otherKeyModifier = p_90851_.getKeyModifier();
|
||||
+ if (keyModifier.matches(p_90851_.getKey()) || otherKeyModifier.matches(getKey())) {
|
||||
+ var otherKeyModifier = that.getKeyModifier();
|
||||
+ if (keyModifier.matches(that.getKey()) || otherKeyModifier.matches(getKey())) {
|
||||
+ return true;
|
||||
+ } else if (getKey().equals(p_90851_.getKey())) {
|
||||
+ } else if (getKey().equals(that.getKey())) {
|
||||
+ // IN_GAME key contexts have a conflict when at least one modifier is NONE.
|
||||
+ // For example: If you hold shift to crouch, you can still press E to open your inventory. This means that a Shift+E hotkey is in conflict with E.
|
||||
+ // GUI and other key contexts do not have this limitation.
|
||||
@@ -67,10 +67,10 @@
|
||||
+ (keyModifier == net.minecraftforge.client.settings.KeyModifier.NONE || otherKeyModifier == net.minecraftforge.client.settings.KeyModifier.NONE));
|
||||
+ }
|
||||
+ }
|
||||
return this.key.equals(p_90851_.key);
|
||||
return this.key.equals(that.key);
|
||||
}
|
||||
|
||||
@@ -177,11 +_,13 @@
|
||||
@@ -175,11 +_,13 @@
|
||||
}
|
||||
|
||||
public Component getTranslatedKeyMessage() {
|
||||
@@ -85,16 +85,16 @@
|
||||
}
|
||||
|
||||
public String saveString() {
|
||||
@@ -193,11 +_,94 @@
|
||||
@@ -191,11 +_,94 @@
|
||||
}
|
||||
|
||||
private void registerMapping(InputConstants.Key p_423386_) {
|
||||
- MAP.computeIfAbsent(p_423386_, p_420623_ -> new ArrayList<>()).add(this);
|
||||
+ MAP.put(p_423386_, this);
|
||||
private void registerMapping(final InputConstants.Key key) {
|
||||
- MAP.computeIfAbsent(key, k -> new ArrayList<>()).add(this);
|
||||
+ MAP.put(key, this);
|
||||
}
|
||||
|
||||
public static @Nullable KeyMapping get(String p_378660_) {
|
||||
return ALL.get(p_378660_);
|
||||
public static @Nullable KeyMapping get(final String name) {
|
||||
return ALL.get(name);
|
||||
+ }
|
||||
+
|
||||
+ private net.minecraftforge.client.settings.KeyModifier keyModifierDefault = net.minecraftforge.client.settings.KeyModifier.NONE;
|
||||
|
||||
@@ -1,37 +1,37 @@
|
||||
--- a/net/minecraft/client/KeyboardHandler.java
|
||||
+++ b/net/minecraft/client/KeyboardHandler.java
|
||||
@@ -497,7 +_,7 @@
|
||||
@@ -516,7 +_,7 @@
|
||||
if (screen != null) {
|
||||
try {
|
||||
if (p_90895_ != 1 && p_90895_ != 2) {
|
||||
- if (p_90895_ == 0 && screen.keyReleased(p_423534_)) {
|
||||
+ if (p_90895_ == 0 && net.minecraftforge.client.ForgeHooksClient.onScreenKeyReleased(screen, p_423534_)) {
|
||||
if (options.keyDebugModifier.matches(p_423534_)) {
|
||||
if (action != 1 && action != 2) {
|
||||
- if (action == 0 && screen.keyReleased(event)) {
|
||||
+ if (action == 0 && net.minecraftforge.client.ForgeHooksClient.onScreenKeyReleased(screen, event)) {
|
||||
if (options.keyDebugModifier.matches(event)) {
|
||||
this.usedDebugKeyAsModifier = false;
|
||||
}
|
||||
@@ -506,7 +_,7 @@
|
||||
@@ -525,7 +_,7 @@
|
||||
}
|
||||
} else {
|
||||
screen.afterKeyboardAction();
|
||||
- if (screen.keyPressed(p_423534_)) {
|
||||
+ if (net.minecraftforge.client.ForgeHooksClient.onScreenKeyPressed(screen, p_423534_)) {
|
||||
- if (screen.keyPressed(event)) {
|
||||
+ if (net.minecraftforge.client.ForgeHooksClient.onScreenKeyPressed(screen, event)) {
|
||||
if (this.minecraft.screen == null) {
|
||||
InputConstants.Key inputconstants$key = InputConstants.getKey(p_423534_);
|
||||
InputConstants.Key inputconstants$key = InputConstants.getKey(event);
|
||||
KeyMapping.set(inputconstants$key, false);
|
||||
@@ -582,6 +_,7 @@
|
||||
@@ -597,6 +_,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
+ net.minecraftforge.client.ForgeHooksClient.onKeyInput(p_423534_, p_90895_);
|
||||
+ net.minecraftforge.client.ForgeHooksClient.onKeyInput(event, action);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -590,7 +_,7 @@
|
||||
@@ -605,7 +_,7 @@
|
||||
Screen screen = this.minecraft.screen;
|
||||
if (screen != null && this.minecraft.getOverlay() == null) {
|
||||
try {
|
||||
- screen.charTyped(p_427531_);
|
||||
+ net.minecraftforge.client.ForgeHooksClient.onScreenCharTyped(screen, p_427531_);
|
||||
- screen.charTyped(event);
|
||||
+ net.minecraftforge.client.ForgeHooksClient.onScreenCharTyped(screen, event);
|
||||
} catch (Throwable throwable) {
|
||||
CrashReport crashreport = CrashReport.forThrowable(throwable, "charTyped event handler");
|
||||
screen.fillCrashDetails(crashreport);
|
||||
@@ -1,90 +1,85 @@
|
||||
--- a/net/minecraft/client/Minecraft.java
|
||||
+++ b/net/minecraft/client/Minecraft.java
|
||||
@@ -265,7 +_,7 @@
|
||||
@@ -272,7 +_,7 @@
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
-public class Minecraft extends ReentrantBlockableEventLoop<Runnable> implements WindowEventHandler {
|
||||
+public class Minecraft extends ReentrantBlockableEventLoop<Runnable> implements WindowEventHandler, net.minecraftforge.client.extensions.IForgeMinecraft {
|
||||
static Minecraft instance;
|
||||
private static Minecraft instance;
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
private static final int MAX_TICKS_PER_UPDATE = 10;
|
||||
@@ -431,7 +_,6 @@
|
||||
@@ -436,7 +_,6 @@
|
||||
}
|
||||
}, Util.nonCriticalIoPool());
|
||||
LOGGER.info("Setting user: {}", this.user.getName());
|
||||
- LOGGER.debug("(Session ID is {})", this.user.getSessionId());
|
||||
this.demo = p_91084_.game.demo;
|
||||
this.allowsMultiplayer = !p_91084_.game.disableMultiplayer;
|
||||
this.allowsChat = !p_91084_.game.disableChat;
|
||||
@@ -483,10 +_,9 @@
|
||||
LOGGER.error("Couldn't set icon", (Throwable)ioexception);
|
||||
}
|
||||
|
||||
+ // FORGE: Move mouse and keyboard handler setup further below
|
||||
this.mouseHandler = new MouseHandler(this);
|
||||
- this.mouseHandler.setup(this.window);
|
||||
this.keyboardHandler = new KeyboardHandler(this);
|
||||
- this.keyboardHandler.setup(this.window);
|
||||
RenderSystem.initRenderer(
|
||||
this.window.handle(),
|
||||
this.options.glDebugVerbosity,
|
||||
@@ -498,6 +_,7 @@
|
||||
LOGGER.info("Using optional rendering extensions: {}", String.join(", ", RenderSystem.getDevice().getEnabledExtensions()));
|
||||
this.mainRenderTarget = new MainTarget(this.window.getWidth(), this.window.getHeight());
|
||||
this.resourceManager = new ReloadableResourceManager(PackType.CLIENT_RESOURCES);
|
||||
+ net.minecraftforge.client.loading.ClientModLoader.begin(this, this.resourcePackRepository, this.resourceManager);
|
||||
this.resourcePackRepository.reload();
|
||||
this.options.loadSelectedResourcePacks(this.resourcePackRepository);
|
||||
this.languageManager = new LanguageManager(this.options.languageCode, p_340763_ -> {
|
||||
@@ -585,6 +_,7 @@
|
||||
this.particleResources = new ParticleResources();
|
||||
this.resourceManager.registerReloadListener(this.particleResources);
|
||||
this.particleEngine = new ParticleEngine(this.level, this.particleResources);
|
||||
+ net.minecraftforge.client.ForgeHooksClient.onRegisterParticleProviders(this.particleResources);
|
||||
this.particleResources.onReload(this.particleEngine::clearParticles);
|
||||
this.waypointStyles = new WaypointStyleManager();
|
||||
this.resourceManager.registerReloadListener(this.waypointStyles);
|
||||
@@ -596,6 +_,9 @@
|
||||
this.resourceManager.registerReloadListener(this.gpuWarnlistManager);
|
||||
this.resourceManager.registerReloadListener(this.regionalCompliancies);
|
||||
this.gui = new Gui(this);
|
||||
+ // FORGE: Moved keyboard and mouse handler setup below ingame gui creation to prevent NPEs in them.
|
||||
+ this.mouseHandler.setup(this.window);
|
||||
+ this.keyboardHandler.setup(this.window);
|
||||
RealmsClient realmsclient = RealmsClient.getOrCreate(this);
|
||||
this.realmsDataFetcher = new RealmsDataFetcher(realmsclient);
|
||||
RenderSystem.setErrorCallback(this::onFullscreenError);
|
||||
@@ -628,6 +_,7 @@
|
||||
this.demo = gameConfig.game.demo;
|
||||
this.allowsMultiplayer = !gameConfig.game.disableMultiplayer;
|
||||
this.allowsChat = !gameConfig.game.disableChat;
|
||||
@@ -522,14 +_,14 @@
|
||||
LOGGER.error("Couldn't set icon", (Throwable)ioexception);
|
||||
}
|
||||
}
|
||||
|
||||
+ net.minecraftforge.client.ForgeHooksClient.initClientHooks(this, this.resourceManager);
|
||||
this.window.updateVsync(this.options.enableVsync().get());
|
||||
this.window.updateRawMouseInput(this.options.rawMouseInput().get());
|
||||
this.window.setAllowCursorChanges(this.options.allowCursorChanges().get());
|
||||
@@ -651,16 +_,17 @@
|
||||
GameLoadTimesEvent.INSTANCE.beginStep(TelemetryProperty.LOAD_TIME_LOADING_OVERLAY_MS);
|
||||
Minecraft.GameLoadCookie minecraft$gameloadcookie = new Minecraft.GameLoadCookie(realmsclient, p_91084_.quickPlay);
|
||||
this.setOverlay(
|
||||
- new LoadingOverlay(
|
||||
- this, reloadinstance, p_447796_ -> Util.ifElse(p_447796_, p_296162_ -> this.rollbackResourcePacks(p_296162_, minecraft$gameloadcookie), () -> {
|
||||
+ net.minecraftforge.fml.loading.ImmediateWindowHandler.<LoadingOverlay>loadingOverlay(
|
||||
+ () -> this, () -> reloadinstance, p_296164_ -> Util.ifElse(p_296164_, p_447796_ -> this.rollbackResourcePacks(p_447796_, minecraft$gameloadcookie), () -> {
|
||||
+ // FORGE: Move mouse and keyboard handler setup further below
|
||||
this.mouseHandler = new MouseHandler(this);
|
||||
- this.mouseHandler.setup(this.window);
|
||||
this.keyboardHandler = new KeyboardHandler(this);
|
||||
- this.keyboardHandler.setup(this.window);
|
||||
this.options.applyGraphicsPreset(this.options.graphicsPreset().get());
|
||||
LOGGER.info("Using optional rendering extensions: {}", String.join(", ", RenderSystem.getDevice().getEnabledExtensions()));
|
||||
this.mainRenderTarget = new MainTarget(this.window.getWidth(), this.window.getHeight());
|
||||
this.resourceManager = new ReloadableResourceManager(PackType.CLIENT_RESOURCES);
|
||||
+ net.minecraftforge.client.loading.ClientModLoader.begin(this, this.resourcePackRepository, this.resourceManager);
|
||||
this.resourcePackRepository.reload();
|
||||
this.options.loadSelectedResourcePacks(this.resourcePackRepository);
|
||||
this.languageManager = new LanguageManager(this.options.languageCode, languageData -> {
|
||||
@@ -617,6 +_,7 @@
|
||||
this.particleResources = new ParticleResources();
|
||||
this.resourceManager.registerReloadListener(this.particleResources);
|
||||
this.particleEngine = new ParticleEngine(this.level, this.particleResources);
|
||||
+ net.minecraftforge.client.ForgeHooksClient.onRegisterParticleProviders(this.particleResources);
|
||||
this.particleResources.onReload(this.particleEngine::clearParticles);
|
||||
this.waypointStyles = new WaypointStyleManager();
|
||||
this.resourceManager.registerReloadListener(this.waypointStyles);
|
||||
@@ -638,6 +_,9 @@
|
||||
this.resourceManager.registerReloadListener(this.gpuWarnlistManager);
|
||||
this.resourceManager.registerReloadListener(this.regionalCompliancies);
|
||||
this.gui = new Gui(this);
|
||||
+ // FORGE: Moved keyboard and mouse handler setup below ingame gui creation to prevent NPEs in them.
|
||||
+ this.mouseHandler.setup(this.window);
|
||||
+ this.keyboardHandler.setup(this.window);
|
||||
RealmsClient realmsclient = RealmsClient.getOrCreate(this);
|
||||
this.realmsDataFetcher = new RealmsDataFetcher(realmsclient);
|
||||
RenderSystem.setErrorCallback(this::onFullscreenError);
|
||||
@@ -669,6 +_,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
+ net.minecraftforge.client.ForgeHooksClient.initClientHooks(this, this.resourceManager);
|
||||
this.window.updateVsync(this.options.enableVsync().get());
|
||||
this.window.updateRawMouseInput(this.options.rawMouseInput().get());
|
||||
this.window.setAllowCursorChanges(this.options.allowCursorChanges().get());
|
||||
@@ -695,14 +_,16 @@
|
||||
GameLoadTimesEvent.INSTANCE.beginStep(TelemetryProperty.LOAD_TIME_LOADING_OVERLAY_MS);
|
||||
Minecraft.GameLoadCookie minecraft$gameloadcookie = new Minecraft.GameLoadCookie(realmsclient, gameConfig.quickPlay);
|
||||
this.setOverlay(
|
||||
- new LoadingOverlay(this, reloadinstance, maybeT -> Util.ifElse(maybeT, t -> this.rollbackResourcePacks(t, minecraft$gameloadcookie), () -> {
|
||||
+ net.minecraftforge.fml.loading.ImmediateWindowHandler.<LoadingOverlay>loadingOverlay(
|
||||
+ () -> this, () -> reloadinstance, maybeT -> Util.ifElse(maybeT, t -> this.rollbackResourcePacks(t, minecraft$gameloadcookie), () -> {
|
||||
if (SharedConstants.IS_RUNNING_IN_IDE) {
|
||||
this.selfTest();
|
||||
}
|
||||
|
||||
this.reloadStateTracker.finishReload();
|
||||
this.onResourceLoadFinished(minecraft$gameloadcookie);
|
||||
- }), false)
|
||||
+ net.minecraftforge.client.loading.ClientModLoader.completeModLoading();
|
||||
}), false
|
||||
- )
|
||||
+ ).get()
|
||||
);
|
||||
this.quickPlayLog = QuickPlayLog.of(p_91084_.quickPlay.logPath());
|
||||
this.framerateLimitTracker = new FramerateLimitTracker(this.options, this);
|
||||
@@ -779,6 +_,7 @@
|
||||
+ }), false).get()
|
||||
);
|
||||
this.quickPlayLog = QuickPlayLog.of(gameConfig.quickPlay.logPath());
|
||||
this.framerateLimitTracker = new FramerateLimitTracker(this.options, this);
|
||||
@@ -822,6 +_,7 @@
|
||||
StringBuilder stringbuilder = new StringBuilder("Minecraft");
|
||||
if (checkModStatus().shouldReportAsModified()) {
|
||||
stringbuilder.append("*");
|
||||
@@ -92,25 +87,25 @@
|
||||
}
|
||||
|
||||
stringbuilder.append(" ");
|
||||
@@ -802,6 +_,8 @@
|
||||
@@ -845,6 +_,8 @@
|
||||
}
|
||||
|
||||
private UserApiService createUserApiService(YggdrasilAuthenticationService p_193586_, GameConfig p_193587_) {
|
||||
+ if ("0".equals(p_193587_.user.user.getAccessToken())) // Forge: We use "0" in dev. Short circuit to stop exception spam.
|
||||
private UserApiService createUserApiService(final YggdrasilAuthenticationService authService, final GameConfig config) {
|
||||
+ if ("0".equals(config.user.user.getAccessToken())) // Forge: We use "0" in dev. Short circuit to stop exception spam.
|
||||
+ return UserApiService.OFFLINE;
|
||||
return p_193587_.game.offlineDeveloperMode ? UserApiService.OFFLINE : p_193586_.createUserApiService(p_193587_.user.user.getAccessToken());
|
||||
return config.game.offlineDeveloperMode ? UserApiService.OFFLINE : authService.createUserApiService(config.user.user.getAccessToken());
|
||||
}
|
||||
|
||||
@@ -814,7 +_,7 @@
|
||||
@@ -857,7 +_,7 @@
|
||||
}
|
||||
|
||||
private void rollbackResourcePacks(Throwable p_91240_, Minecraft.@Nullable GameLoadCookie p_299515_) {
|
||||
private void rollbackResourcePacks(final Throwable t, final Minecraft.@Nullable GameLoadCookie loadCookie) {
|
||||
- if (this.resourcePackRepository.getSelectedIds().size() > 1) {
|
||||
+ if (this.resourcePackRepository.getSelectedPacks().stream().anyMatch(e -> !e.isRequired())) { //Forge: This caused infinite loop if any resource packs are forced. Such as mod resources. So check if we can disable any.
|
||||
this.clearResourcePacksOnError(p_91240_, null, p_299515_);
|
||||
this.clearResourcePacksOnError(t, null, loadCookie);
|
||||
} else {
|
||||
Util.throwAsRuntime(p_91240_);
|
||||
@@ -1100,12 +_,6 @@
|
||||
Util.throwAsRuntime(t);
|
||||
@@ -1134,12 +_,6 @@
|
||||
LOGGER.error("setScreen called from non-game thread");
|
||||
}
|
||||
|
||||
@@ -120,22 +115,22 @@
|
||||
- this.setLastInputType(InputType.NONE);
|
||||
- }
|
||||
-
|
||||
if (p_91153_ == null) {
|
||||
if (screen == null) {
|
||||
if (this.clientLevelTeardownInProgress) {
|
||||
throw new IllegalStateException("Trying to return to in-game GUI during disconnection");
|
||||
@@ -1124,6 +_,23 @@
|
||||
@@ -1158,6 +_,23 @@
|
||||
}
|
||||
}
|
||||
|
||||
+ net.minecraftforge.client.ForgeHooksClient.clearGuiLayers(this);
|
||||
+ Screen old = this.screen;
|
||||
+ if (p_91153_ != null) {
|
||||
+ var event = net.minecraftforge.client.event.ForgeEventFactoryClient.onScreenOpening(old, p_91153_);
|
||||
+ if (screen != null) {
|
||||
+ var event = net.minecraftforge.client.event.ForgeEventFactoryClient.onScreenOpening(old, screen);
|
||||
+ if (event == null) return;
|
||||
+ p_91153_ = event;
|
||||
+ screen = event;
|
||||
+ }
|
||||
+
|
||||
+ if (p_91153_ != old) {
|
||||
+ if (screen != old) {
|
||||
+ if (old != null) {
|
||||
+ net.minecraftforge.client.event.ForgeEventFactoryClient.onScreenClose(old);
|
||||
+ old.removed();
|
||||
@@ -144,41 +139,36 @@
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
this.screen = p_91153_;
|
||||
this.screen = screen;
|
||||
if (this.screen != null) {
|
||||
this.screen.added();
|
||||
@@ -1207,6 +_,7 @@
|
||||
@@ -1241,6 +_,7 @@
|
||||
Util.shutdownExecutors();
|
||||
RenderSystem.getSamplerCache().close();
|
||||
RenderSystem.getDevice().close();
|
||||
+ net.minecraftforge.fml.config.ConfigTracker.INSTANCE.forceUnload();
|
||||
+ net.minecraftforge.fml.config.ConfigTracker.forceUnload();
|
||||
} catch (Throwable throwable) {
|
||||
LOGGER.error("Shutdown failure!", throwable);
|
||||
throw throwable;
|
||||
@@ -1289,7 +_,9 @@
|
||||
RenderSystem.getDevice().createCommandEncoder().clearColorAndDepthTextures(rendertarget.getColorTexture(), 0, rendertarget.getDepthTexture(), 1.0);
|
||||
profilerfiller.push("gameRenderer");
|
||||
if (!this.noRender) {
|
||||
+ net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderTickStart(this.deltaTracker);
|
||||
this.gameRenderer.render(this.deltaTracker, p_91384_);
|
||||
+ net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderTickEnd(this.deltaTracker);
|
||||
}
|
||||
|
||||
profilerfiller.popPush("blit");
|
||||
@@ -1401,10 +_,12 @@
|
||||
@@ -1352,7 +_,9 @@
|
||||
profilerfiller.popPush("gpuAsync");
|
||||
RenderSystem.executePendingTasks();
|
||||
profilerfiller.pop();
|
||||
+ net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderTickStart(this.deltaTracker);
|
||||
this.gameRenderer.render(this.deltaTracker, advanceGameTime);
|
||||
+ net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderTickEnd(this.deltaTracker);
|
||||
profilerfiller.push("present");
|
||||
if (!this.gameRenderer.getGameRenderState().windowRenderState.isMinimized) {
|
||||
this.mainRenderTarget.blitToScreen();
|
||||
@@ -1456,6 +_,7 @@
|
||||
this.window.setGuiScale(i);
|
||||
if (this.screen != null) {
|
||||
this.screen.resize(this.window.getGuiScaledWidth(), this.window.getGuiScaledHeight());
|
||||
+ net.minecraftforge.client.ForgeHooksClient.resizeGuiLayers(this, this.window.getGuiScaledWidth(), this.window.getGuiScaledHeight());
|
||||
}
|
||||
|
||||
RenderTarget rendertarget = this.getMainRenderTarget();
|
||||
rendertarget.resize(this.window.getWidth(), this.window.getHeight());
|
||||
+ if (this.gameRenderer != null)
|
||||
this.gameRenderer.resize(this.window.getWidth(), this.window.getHeight());
|
||||
this.mouseHandler.setIgnoreFirstMove();
|
||||
}
|
||||
@@ -1542,6 +_,7 @@
|
||||
@@ -1600,6 +_,7 @@
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
@@ -186,8 +176,8 @@
|
||||
this.running = false;
|
||||
}
|
||||
|
||||
@@ -1571,10 +_,18 @@
|
||||
if (p_91387_ && this.hitResult != null && this.hitResult.getType() == HitResult.Type.BLOCK) {
|
||||
@@ -1629,10 +_,18 @@
|
||||
if (down && this.hitResult != null && this.hitResult.getType() == HitResult.Type.BLOCK) {
|
||||
BlockHitResult blockhitresult = (BlockHitResult)this.hitResult;
|
||||
BlockPos blockpos = blockhitresult.getBlockPos();
|
||||
- if (!this.level.getBlockState(blockpos).isAir()) {
|
||||
@@ -208,7 +198,7 @@
|
||||
this.player.swing(InteractionHand.MAIN_HAND);
|
||||
}
|
||||
}
|
||||
@@ -1611,6 +_,8 @@
|
||||
@@ -1675,6 +_,8 @@
|
||||
this.player.swing(InteractionHand.MAIN_HAND);
|
||||
return true;
|
||||
} else {
|
||||
@@ -217,7 +207,7 @@
|
||||
switch (this.hitResult.getType()) {
|
||||
case ENTITY:
|
||||
AttackRange attackrange = itemstack.get(DataComponents.ATTACK_RANGE);
|
||||
@@ -1621,7 +_,7 @@
|
||||
@@ -1685,7 +_,7 @@
|
||||
case BLOCK:
|
||||
BlockHitResult blockhitresult = (BlockHitResult)this.hitResult;
|
||||
BlockPos blockpos = blockhitresult.getBlockPos();
|
||||
@@ -226,19 +216,18 @@
|
||||
this.gameMode.startDestroyBlock(blockpos, blockhitresult.getDirection());
|
||||
if (this.level.getBlockState(blockpos).isAir()) {
|
||||
flag = true;
|
||||
@@ -1634,9 +_,10 @@
|
||||
@@ -1698,8 +_,10 @@
|
||||
}
|
||||
|
||||
this.player.resetAttackStrengthTicker();
|
||||
+ net.minecraftforge.event.ForgeEventFactory.onLeftClickEmpty(this.player);
|
||||
}
|
||||
|
||||
- if (!this.player.isSpectator()) {
|
||||
+ if (!this.player.isSpectator() && inputEvent.shouldSwingHand()) {
|
||||
this.player.swing(InteractionHand.MAIN_HAND);
|
||||
}
|
||||
|
||||
@@ -1655,6 +_,12 @@
|
||||
+ if (inputEvent.shouldSwingHand())
|
||||
this.player.swing(InteractionHand.MAIN_HAND);
|
||||
return flag;
|
||||
}
|
||||
@@ -1716,6 +_,12 @@
|
||||
}
|
||||
|
||||
for (InteractionHand interactionhand : InteractionHand.values()) {
|
||||
@@ -251,25 +240,25 @@
|
||||
ItemStack itemstack = this.player.getItemInHand(interactionhand);
|
||||
if (!itemstack.isItemEnabled(this.level.enabledFeatures())) {
|
||||
return;
|
||||
@@ -1676,7 +_,7 @@
|
||||
@@ -1734,7 +_,7 @@
|
||||
&& this.gameMode.interact(this.player, entity, entityhitresult, interactionhand) instanceof InteractionResult.Success interactionresult$success2
|
||||
)
|
||||
{
|
||||
- if (interactionresult$success2.swingSource() == InteractionResult.SwingSource.CLIENT) {
|
||||
+ if (interactionresult$success2.swingSource() == InteractionResult.SwingSource.CLIENT && inputEvent.shouldSwingHand()) {
|
||||
this.player.swing(interactionhand);
|
||||
}
|
||||
|
||||
if (interactionresult instanceof InteractionResult.Success interactionresult$success2) {
|
||||
- if (interactionresult$success2.swingSource() == InteractionResult.SwingSource.CLIENT) {
|
||||
+ if (interactionresult$success2.swingSource() == InteractionResult.SwingSource.CLIENT && inputEvent.shouldSwingHand()) {
|
||||
this.player.swing(interactionhand);
|
||||
}
|
||||
|
||||
@@ -1689,7 +_,7 @@
|
||||
@@ -1746,7 +_,7 @@
|
||||
int i = itemstack.getCount();
|
||||
InteractionResult interactionresult1 = this.gameMode.useItemOn(this.player, interactionhand, blockhitresult);
|
||||
if (interactionresult1 instanceof InteractionResult.Success interactionresult$success) {
|
||||
InteractionResult interactionresult = this.gameMode.useItemOn(this.player, interactionhand, blockhitresult);
|
||||
if (interactionresult instanceof InteractionResult.Success interactionresult$success) {
|
||||
- if (interactionresult$success.swingSource() == InteractionResult.SwingSource.CLIENT) {
|
||||
+ if (interactionresult$success.swingSource() == InteractionResult.SwingSource.CLIENT && inputEvent.shouldSwingHand()) {
|
||||
this.player.swing(interactionhand);
|
||||
if (!itemstack.isEmpty() && (itemstack.getCount() != i || this.player.hasInfiniteMaterials())) {
|
||||
this.gameRenderer.itemInHandRenderer.itemUsed(interactionhand);
|
||||
@@ -1705,6 +_,9 @@
|
||||
@@ -1762,6 +_,9 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -279,16 +268,16 @@
|
||||
if (!itemstack.isEmpty()
|
||||
&& this.gameMode.useItem(this.player, interactionhand) instanceof InteractionResult.Success interactionresult$success1) {
|
||||
if (interactionresult$success1.swingSource() == InteractionResult.SwingSource.CLIENT) {
|
||||
@@ -1734,6 +_,8 @@
|
||||
@@ -1791,6 +_,8 @@
|
||||
}
|
||||
|
||||
ProfilerFiller profilerfiller = Profiler.get();
|
||||
+ net.minecraftforge.event.ForgeEventFactory.onPreClientTick();
|
||||
+
|
||||
profilerfiller.push("gui");
|
||||
this.textInputManager.tick();
|
||||
this.chatListener.tick();
|
||||
this.gui.tick(this.pause);
|
||||
@@ -1815,6 +_,7 @@
|
||||
@@ -1873,6 +_,7 @@
|
||||
|
||||
this.tutorial.tick();
|
||||
|
||||
@@ -296,7 +285,7 @@
|
||||
try {
|
||||
this.level.tick(() -> true);
|
||||
} catch (Throwable throwable1) {
|
||||
@@ -1828,6 +_,7 @@
|
||||
@@ -1886,6 +_,7 @@
|
||||
|
||||
throw new ReportedException(crashreport1);
|
||||
}
|
||||
@@ -304,7 +293,7 @@
|
||||
}
|
||||
|
||||
profilerfiller.popPush("animateTick");
|
||||
@@ -1852,6 +_,7 @@
|
||||
@@ -1910,6 +_,7 @@
|
||||
profilerfiller.popPush("keyboard");
|
||||
this.keyboardHandler.tick();
|
||||
profilerfiller.pop();
|
||||
@@ -312,15 +301,15 @@
|
||||
}
|
||||
|
||||
private boolean isLevelRunningNormally() {
|
||||
@@ -2070,6 +_,7 @@
|
||||
@@ -2140,6 +_,7 @@
|
||||
}
|
||||
|
||||
public void setLevel(ClientLevel p_91157_) {
|
||||
public void setLevel(final ClientLevel level) {
|
||||
+ if (this.level != null) net.minecraftforge.event.ForgeEventFactory.onLevelUnload(this.level);
|
||||
this.level = p_91157_;
|
||||
this.updateLevelInEngines(p_91157_);
|
||||
this.level = level;
|
||||
this.updateLevelInEngines(level);
|
||||
}
|
||||
@@ -2131,6 +_,7 @@
|
||||
@@ -2201,6 +_,7 @@
|
||||
IntegratedServer integratedserver = this.singleplayerServer;
|
||||
this.singleplayerServer = null;
|
||||
this.gameRenderer.resetData();
|
||||
@@ -328,25 +317,25 @@
|
||||
this.gameMode = null;
|
||||
this.narrator.clear();
|
||||
this.clientLevelTeardownInProgress = true;
|
||||
@@ -2138,6 +_,7 @@
|
||||
@@ -2208,6 +_,7 @@
|
||||
try {
|
||||
if (this.level != null) {
|
||||
this.gui.onDisconnected();
|
||||
+ net.minecraftforge.event.ForgeEventFactory.onLevelUnload(this.level);
|
||||
}
|
||||
|
||||
if (integratedserver != null) {
|
||||
@@ -2150,6 +_,7 @@
|
||||
this.level = null;
|
||||
@@ -2222,6 +_,7 @@
|
||||
}
|
||||
|
||||
profilerfiller.pop();
|
||||
+ net.minecraftforge.client.ForgeHooksClient.handleClientLevelClosing(this.level);
|
||||
}
|
||||
|
||||
this.setScreenAndShow(p_457642_);
|
||||
@@ -2292,6 +_,7 @@
|
||||
this.setScreenAndShow(screen);
|
||||
@@ -2374,6 +_,7 @@
|
||||
|
||||
private void pickBlock() {
|
||||
private void pickBlockOrEntity() {
|
||||
if (this.hitResult != null && this.hitResult.getType() != HitResult.Type.MISS) {
|
||||
+ if (net.minecraftforge.client.event.ForgeEventFactoryClient.onClickInputPickBlock(this.options.keyPickItem)) return;
|
||||
boolean flag = this.hasControlDown();
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
this.activeButton = null;
|
||||
}
|
||||
|
||||
+ if (net.minecraftforge.client.event.ForgeEventFactoryClient.onMouseButtonPre(mousebuttoninfo, p_423948_)) return;
|
||||
+ if (net.minecraftforge.client.event.ForgeEventFactoryClient.onMouseButtonPre(mousebuttoninfo, action)) return;
|
||||
if (this.minecraft.getOverlay() == null) {
|
||||
if (this.minecraft.screen == null) {
|
||||
if (!this.mouseGrabbed && flag) {
|
||||
@@ -30,11 +30,11 @@
|
||||
KeyMapping.click(inputconstants$key);
|
||||
}
|
||||
}
|
||||
+ net.minecraftforge.client.event.ForgeEventFactoryClient.onMouseButtonPost(mousebuttoninfo, p_423948_);
|
||||
+ net.minecraftforge.client.event.ForgeEventFactoryClient.onMouseButtonPost(mousebuttoninfo, action);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -207,7 +_,9 @@
|
||||
@@ -202,7 +_,9 @@
|
||||
if (this.minecraft.screen != null) {
|
||||
double d3 = this.getScaledXPos(this.minecraft.getWindow());
|
||||
double d4 = this.getScaledYPos(this.minecraft.getWindow());
|
||||
@@ -45,7 +45,7 @@
|
||||
this.minecraft.screen.afterMouseAction();
|
||||
} else if (this.minecraft.player != null) {
|
||||
Vector2i vector2i = this.scrollWheelHandler.onMouseScroll(d1, d2);
|
||||
@@ -216,6 +_,7 @@
|
||||
@@ -211,6 +_,7 @@
|
||||
}
|
||||
|
||||
int i = vector2i.y == 0 ? -vector2i.x : vector2i.y;
|
||||
@@ -53,7 +53,7 @@
|
||||
if (this.minecraft.player.isSpectator()) {
|
||||
if (this.minecraft.gui.getSpectatorGui().isMenuActive()) {
|
||||
this.minecraft.gui.getSpectatorGui().onMouseScrolled(-i);
|
||||
@@ -324,7 +_,7 @@
|
||||
@@ -315,7 +_,7 @@
|
||||
double d5 = getScaledYPos(window, this.accumulatedDY);
|
||||
|
||||
try {
|
||||
@@ -62,7 +62,7 @@
|
||||
} catch (Throwable throwable) {
|
||||
CrashReport crashreport1 = CrashReport.forThrowable(throwable, "mouseDragged event handler");
|
||||
screen.fillCrashDetails(crashreport1);
|
||||
@@ -411,6 +_,14 @@
|
||||
@@ -400,6 +_,14 @@
|
||||
|
||||
public double ypos() {
|
||||
return this.ypos;
|
||||
|
||||
@@ -1,45 +1,35 @@
|
||||
--- a/net/minecraft/client/Options.java
|
||||
+++ b/net/minecraft/client/Options.java
|
||||
@@ -816,7 +_,8 @@
|
||||
},
|
||||
new OptionInstance.LazyEnum<>(
|
||||
() -> Stream.concat(Stream.of(""), Minecraft.getInstance().getSoundManager().getAvailableSoundDevices().stream()).toList(),
|
||||
- p_232011_ -> Minecraft.getInstance().isRunning() && p_232011_ != "" && !Minecraft.getInstance().getSoundManager().getAvailableSoundDevices().contains(p_232011_)
|
||||
+ // FORGE: fix incorrect string comparison - PR #8767
|
||||
+ p_232011_ -> Minecraft.getInstance().isRunning() && (p_232011_ == null || !p_232011_.isEmpty()) && !Minecraft.getInstance().getSoundManager().getAvailableSoundDevices().contains(p_232011_)
|
||||
? Optional.empty()
|
||||
: Optional.of(p_232011_),
|
||||
Codec.STRING
|
||||
@@ -848,6 +_,7 @@
|
||||
@@ -921,6 +_,7 @@
|
||||
);
|
||||
public boolean syncWrites;
|
||||
public boolean startedCleanly = true;
|
||||
+ private final Map<String, String> unknownKeys = new java.util.HashMap<>();
|
||||
|
||||
private static void operateOnLevelRenderer(Consumer<LevelRenderer> p_457625_) {
|
||||
LevelRenderer levelrenderer = Minecraft.getInstance().levelRenderer;
|
||||
@@ -1313,6 +_,7 @@
|
||||
public static boolean isSoundDeviceDefault(final String deviceName) {
|
||||
return deviceName.equals("");
|
||||
@@ -1396,6 +_,7 @@
|
||||
}
|
||||
|
||||
public Options(Minecraft p_92138_, File p_92139_) {
|
||||
public Options(final Minecraft minecraft, final File workingDirectory) {
|
||||
+ setForgeKeybindProperties();
|
||||
this.minecraft = p_92138_;
|
||||
this.optionsFile = new File(p_92139_, "options.txt");
|
||||
this.minecraft = minecraft;
|
||||
this.optionsFile = new File(workingDirectory, "options.txt");
|
||||
boolean flag = Runtime.getRuntime().maxMemory() >= 1000000000L;
|
||||
@@ -1463,15 +_,28 @@
|
||||
this.startedCleanly = p_168428_.process("startedCleanly", this.startedCleanly);
|
||||
p_168428_.process("musicToast", this.musicToast);
|
||||
p_168428_.process("musicFrequency", this.musicFrequency);
|
||||
+ processOptionsKeysOnly(p_168428_);
|
||||
+ processOptionsEnd(p_168428_);
|
||||
@@ -1548,15 +_,28 @@
|
||||
this.startedCleanly = access.process("startedCleanly", this.startedCleanly);
|
||||
access.process("musicToast", this.musicToast);
|
||||
access.process("musicFrequency", this.musicFrequency);
|
||||
+ processOptionsKeysOnly(access);
|
||||
+ processOptionsEnd(access);
|
||||
+ }
|
||||
|
||||
+ // FORGE: split off to allow reloading keys after mod loading is done
|
||||
+ private void processOptionsKeysOnly(Options.FieldAccess p_168428_) {
|
||||
+ private void processOptionsKeysOnly(Options.FieldAccess access) {
|
||||
for (KeyMapping keymapping : this.keyMappings) {
|
||||
- String s = keymapping.saveString();
|
||||
+ String s = keymapping.saveString() + (keymapping.getKeyModifier() != net.minecraftforge.client.settings.KeyModifier.NONE ? ":" + keymapping.getKeyModifier() : "");
|
||||
String s1 = p_168428_.process("key_" + keymapping.getName(), s);
|
||||
String s1 = access.process("key_" + keymapping.getName(), s);
|
||||
if (!s.equals(s1)) {
|
||||
keymapping.setKey(InputConstants.getKey(s1));
|
||||
+ if (s1.indexOf(':') != -1) {
|
||||
@@ -52,11 +42,11 @@
|
||||
}
|
||||
+ }
|
||||
|
||||
+ private void processOptionsEnd(Options.FieldAccess p_168428_) {
|
||||
+ private void processOptionsEnd(Options.FieldAccess access) {
|
||||
for (SoundSource soundsource : SoundSource.values()) {
|
||||
p_168428_.process("soundCategory_" + soundsource.getName(), this.soundSourceVolumes.get(soundsource));
|
||||
access.process("soundCategory_" + soundsource.getName(), this.soundSourceVolumes.get(soundsource));
|
||||
}
|
||||
@@ -1486,6 +_,10 @@
|
||||
@@ -1571,6 +_,10 @@
|
||||
}
|
||||
|
||||
public void load() {
|
||||
@@ -67,7 +57,7 @@
|
||||
try {
|
||||
if (!this.optionsFile.exists()) {
|
||||
return;
|
||||
@@ -1505,7 +_,8 @@
|
||||
@@ -1590,7 +_,8 @@
|
||||
}
|
||||
|
||||
final CompoundTag compoundtag1 = this.dataFix(compoundtag);
|
||||
@@ -75,11 +65,11 @@
|
||||
+ java.util.function.Consumer<FieldAccess> processor = limited ? this::processOptionsKeysOnly : this::processOptions;
|
||||
+ processor.accept(
|
||||
new Options.FieldAccess() {
|
||||
private @Nullable String getValue(String p_394210_) {
|
||||
Tag tag = compoundtag1.get(p_394210_);
|
||||
@@ -1585,6 +_,17 @@
|
||||
{
|
||||
Objects.requireNonNull(Options.this);
|
||||
@@ -1672,6 +_,17 @@
|
||||
);
|
||||
compoundtag1.getString("fullscreenResolution").ifPresent(p_389133_ -> this.fullscreenVideoModeString = p_389133_);
|
||||
compoundtag1.getString("fullscreenResolution").ifPresent(fullscreenResolution -> this.fullscreenVideoModeString = fullscreenResolution);
|
||||
KeyMapping.resetMapping();
|
||||
+
|
||||
+ if (limited) {
|
||||
@@ -95,19 +85,23 @@
|
||||
} catch (Exception exception) {
|
||||
LOGGER.error("Failed to load options", (Throwable)exception);
|
||||
}
|
||||
@@ -1612,9 +_,11 @@
|
||||
@@ -1699,6 +_,7 @@
|
||||
public void save() {
|
||||
try (final PrintWriter printwriter = new PrintWriter(new OutputStreamWriter(new FileOutputStream(this.optionsFile), StandardCharsets.UTF_8))) {
|
||||
printwriter.println("version:" + SharedConstants.getCurrentVersion().dataVersion().version());
|
||||
+ var seen = new java.util.HashSet<String>();
|
||||
this.processOptions(
|
||||
new Options.FieldAccess() {
|
||||
public void writePrefix(String p_168491_) {
|
||||
+ seen.add(p_168491_);
|
||||
printwriter.print(p_168491_);
|
||||
{
|
||||
@@ -1706,6 +_,7 @@
|
||||
}
|
||||
|
||||
public void writePrefix(final String name) {
|
||||
+ seen.add(name);
|
||||
printwriter.print(name);
|
||||
printwriter.print(':');
|
||||
}
|
||||
@@ -1670,6 +_,12 @@
|
||||
@@ -1761,6 +_,12 @@
|
||||
if (s != null) {
|
||||
printwriter.println("fullscreenResolution:" + s);
|
||||
}
|
||||
@@ -120,7 +114,7 @@
|
||||
} catch (Exception exception) {
|
||||
LOGGER.error("Failed to save options", (Throwable)exception);
|
||||
}
|
||||
@@ -1707,6 +_,7 @@
|
||||
@@ -1798,6 +_,7 @@
|
||||
}
|
||||
|
||||
public void broadcastOptions() {
|
||||
@@ -128,10 +122,10 @@
|
||||
if (this.minecraft.player != null) {
|
||||
this.minecraft.player.connection.broadcastClientInformation(this.buildPlayerInformation());
|
||||
}
|
||||
@@ -1820,6 +_,23 @@
|
||||
@@ -1915,6 +_,23 @@
|
||||
|
||||
public static Component genericValueLabel(Component p_231901_, int p_231902_) {
|
||||
return genericValueLabel(p_231901_, Component.literal(Integer.toString(p_231902_)));
|
||||
public static Component genericValueLabel(final Component caption, final int value) {
|
||||
return genericValueLabel(caption, Component.literal(Integer.toString(value)));
|
||||
+ }
|
||||
+
|
||||
+ private void setForgeKeybindProperties() {
|
||||
@@ -151,4 +145,4 @@
|
||||
+ keySmoothCamera.setKeyConflictContext(inGame);
|
||||
}
|
||||
|
||||
public static Component genericValueOrOffLabel(Component p_345288_, int p_344826_) {
|
||||
public static Component genericValueOrOffLabel(final Component caption, final int value) {
|
||||
@@ -1,32 +1,32 @@
|
||||
--- a/net/minecraft/client/Screenshot.java
|
||||
+++ b/net/minecraft/client/Screenshot.java
|
||||
@@ -43,6 +_,13 @@
|
||||
file2 = new File(file1, p_92297_);
|
||||
@@ -45,6 +_,13 @@
|
||||
file2 = new File(file1, forceName);
|
||||
}
|
||||
|
||||
+ var event = new net.minecraftforge.client.event.ScreenshotEvent(p_447863_, file2);
|
||||
+ var event = new net.minecraftforge.client.event.ScreenshotEvent(image, file2);
|
||||
+ if (net.minecraftforge.client.event.ScreenshotEvent.BUS.post(event)) {
|
||||
+ p_92301_.accept(event.getCancelMessage());
|
||||
+ callback.accept(event.getCancelMessage());
|
||||
+ return;
|
||||
+ }
|
||||
+ final File target = event.getScreenshotFile();
|
||||
+ final File outputFile = event.getScreenshotFile();
|
||||
+
|
||||
Util.ioPool()
|
||||
.execute(
|
||||
() -> {
|
||||
@@ -50,10 +_,13 @@
|
||||
NativeImage $$4x = p_447863_;
|
||||
@@ -52,10 +_,13 @@
|
||||
NativeImage nativeimage = image;
|
||||
|
||||
try {
|
||||
- p_447863_.writeToFile(file2);
|
||||
- image.writeToFile(file2);
|
||||
- Component component = Component.literal(file2.getName())
|
||||
+ p_447863_.writeToFile(target);
|
||||
+ Component component = Component.literal(target.getName())
|
||||
+ image.writeToFile(outputFile);
|
||||
+ Component component = Component.literal(outputFile.getName())
|
||||
.withStyle(ChatFormatting.UNDERLINE)
|
||||
.withStyle(p_389149_ -> p_389149_.withClickEvent(new ClickEvent.OpenFile(file2.getAbsoluteFile())));
|
||||
.withStyle(s -> s.withClickEvent(new ClickEvent.OpenFile(file2.getAbsoluteFile())));
|
||||
+ if (event.getResultMessage() != null)
|
||||
+ p_92301_.accept(event.getResultMessage());
|
||||
+ callback.accept(event.getResultMessage());
|
||||
+ else
|
||||
p_92301_.accept(Component.translatable("screenshot.success", component));
|
||||
callback.accept(Component.translatable("screenshot.success", component));
|
||||
} catch (Throwable throwable1) {
|
||||
if (p_447863_ != null) {
|
||||
if (image != null) {
|
||||
@@ -1,21 +1,22 @@
|
||||
--- a/net/minecraft/client/ToggleKeyMapping.java
|
||||
+++ b/net/minecraft/client/ToggleKeyMapping.java
|
||||
@@ -31,7 +_,7 @@
|
||||
@@ -38,7 +_,7 @@
|
||||
@Override
|
||||
public void setDown(boolean p_92534_) {
|
||||
public void setDown(final boolean down) {
|
||||
if (this.needsToggle.getAsBoolean()) {
|
||||
- if (p_92534_) {
|
||||
+ if (p_92534_ && isConflictContextAndModifierActive()) {
|
||||
- if (down) {
|
||||
+ if (down && isConflictContextAndModifierActive()) {
|
||||
super.setDown(!this.isDown());
|
||||
}
|
||||
} else {
|
||||
@@ -56,5 +_,9 @@
|
||||
@@ -66,5 +_,10 @@
|
||||
|
||||
protected void reset() {
|
||||
super.setDown(false);
|
||||
+ }
|
||||
+
|
||||
+ @Override public boolean isDown() {
|
||||
+ @Override
|
||||
+ public boolean isDown() {
|
||||
+ return this.isDown && (isConflictContextAndModifierActive() || needsToggle.getAsBoolean());
|
||||
}
|
||||
}
|
||||
@@ -1,44 +1,19 @@
|
||||
--- a/net/minecraft/client/color/block/BlockColors.java
|
||||
+++ b/net/minecraft/client/color/block/BlockColors.java
|
||||
@@ -30,7 +_,8 @@
|
||||
private static final int DEFAULT = -1;
|
||||
public static final int LILY_PAD_IN_WORLD = -14647248;
|
||||
public static final int LILY_PAD_DEFAULT = -9321636;
|
||||
- private final IdMapper<BlockColor> blockColors = new IdMapper<>(32);
|
||||
+ // Forge: Use registry delegate as non-Vanilla block ids are not constant
|
||||
+ private final java.util.Map<net.minecraft.core.Holder.Reference<Block>, BlockColor> blockColors = new java.util.HashMap<>(32);
|
||||
private final Map<Block, Set<Property<?>>> coloringStates = Maps.newHashMap();
|
||||
|
||||
public static BlockColors createDefault() {
|
||||
@@ -95,11 +_,12 @@
|
||||
}, Blocks.MELON_STEM, Blocks.PUMPKIN_STEM);
|
||||
blockcolors.addColoringState(StemBlock.AGE, Blocks.MELON_STEM, Blocks.PUMPKIN_STEM);
|
||||
blockcolors.register((p_92596_, p_92597_, p_92598_, p_92599_) -> p_92597_ != null && p_92598_ != null ? -14647248 : -9321636, Blocks.LILY_PAD);
|
||||
@@ -45,6 +_,7 @@
|
||||
blockcolors.register(List.of(BlockTintSources.constant(-2046180)), Blocks.ATTACHED_MELON_STEM, Blocks.ATTACHED_PUMPKIN_STEM);
|
||||
blockcolors.register(List.of(BlockTintSources.stem()), Blocks.MELON_STEM, Blocks.PUMPKIN_STEM);
|
||||
blockcolors.register(List.of(BlockTintSources.constant(-9321636, -14647248)), Blocks.LILY_PAD);
|
||||
+ net.minecraftforge.client.ForgeHooksClient.onBlockColorsInit(blockcolors);
|
||||
return blockcolors;
|
||||
}
|
||||
|
||||
public int getColor(BlockState p_92583_, Level p_92584_, BlockPos p_92585_) {
|
||||
- BlockColor blockcolor = this.blockColors.byId(BuiltInRegistries.BLOCK.getId(p_92583_.getBlock()));
|
||||
+ BlockColor blockcolor = this.blockColors.get(net.minecraftforge.registries.ForgeRegistries.BLOCKS.getDelegateOrThrow(p_92583_.getBlock()));
|
||||
if (blockcolor != null) {
|
||||
return blockcolor.getColor(p_92583_, null, null, 0);
|
||||
} else {
|
||||
@@ -109,13 +_,15 @@
|
||||
}
|
||||
|
||||
public int getColor(BlockState p_92578_, @Nullable BlockAndTintGetter p_92579_, @Nullable BlockPos p_92580_, int p_92581_) {
|
||||
- BlockColor blockcolor = this.blockColors.byId(BuiltInRegistries.BLOCK.getId(p_92578_.getBlock()));
|
||||
+ BlockColor blockcolor = this.blockColors.get(net.minecraftforge.registries.ForgeRegistries.BLOCKS.getDelegateOrThrow(p_92578_.getBlock()));
|
||||
return blockcolor == null ? -1 : blockcolor.getColor(p_92578_, p_92579_, p_92580_, p_92581_);
|
||||
@@ -57,6 +_,8 @@
|
||||
return layer >= list.size() ? null : list.get(layer);
|
||||
}
|
||||
|
||||
+ /** @deprecated Register via {@link net.minecraftforge.client.event.RegisterColorHandlersEvent.Block} */
|
||||
+ @Deprecated
|
||||
public void register(BlockColor p_92590_, Block... p_92591_) {
|
||||
for (Block block : p_92591_) {
|
||||
- this.blockColors.addMapping(p_92590_, BuiltInRegistries.BLOCK.getId(block));
|
||||
+ this.blockColors.put(net.minecraftforge.registries.ForgeRegistries.BLOCKS.getDelegateOrThrow(block), p_92590_);
|
||||
}
|
||||
}
|
||||
|
||||
public void register(final List<BlockTintSource> layers, final Block... blocks) {
|
||||
for (Block block : blocks) {
|
||||
this.sources.put(block, layers);
|
||||
@@ -1,12 +1,12 @@
|
||||
--- a/net/minecraft/client/data/Main.java
|
||||
+++ b/net/minecraft/client/data/Main.java
|
||||
@@ -30,13 +_,18 @@
|
||||
@@ -28,13 +_,18 @@
|
||||
OptionSpec<Void> optionspec1 = optionparser.accepts("client", "Include client generators");
|
||||
OptionSpec<Void> optionspec2 = optionparser.accepts("all", "Include all generators");
|
||||
OptionSpec<String> optionspec3 = optionparser.accepts("output", "Output folder").withRequiredArg().defaultsTo("generated");
|
||||
+ OptionSpec<String> inputSpec = optionparser.accepts("input", "Input folder").withRequiredArg();
|
||||
+ var loader = net.minecraftforge.data.loading.DatagenModLoader.setup(optionparser, true);
|
||||
OptionSet optionset = optionparser.parse(p_375526_);
|
||||
OptionSet optionset = optionparser.parse(args);
|
||||
- if (!optionset.has(optionspec) && optionset.hasOptions()) {
|
||||
+ if (!optionset.has(optionspec) && optionset.hasOptions() && loader.hasArgs(optionset)) {
|
||||
+ var input = optionset.valuesOf(inputSpec).stream().map(Paths::get).toList();
|
||||
@@ -15,8 +15,8 @@
|
||||
boolean flag1 = flag || optionset.has(optionspec1);
|
||||
Bootstrap.bootStrap();
|
||||
ClientBootstrap.bootstrap();
|
||||
+ if (!loader.run(optionset, path, input, flag, flag1, flag, flag, true))
|
||||
+ if (!loader.run(optionset, path, input, flag, flag1, flag, flag))
|
||||
+ return;
|
||||
DataGenerator datagenerator = new DataGenerator(path, SharedConstants.getCurrentVersion(), true);
|
||||
DataGenerator datagenerator = new DataGenerator.Cached(path, SharedConstants.getCurrentVersion(), true);
|
||||
addClientProviders(datagenerator, flag1);
|
||||
datagenerator.run();
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/client/data/models/ItemModelGenerators.java
|
||||
+++ b/net/minecraft/client/data/models/ItemModelGenerators.java
|
||||
@@ -912,6 +_,9 @@
|
||||
@@ -922,6 +_,9 @@
|
||||
this.declareCustomModelItem(Items.COD);
|
||||
this.declareCustomModelItem(Items.FEATHER);
|
||||
this.declareCustomModelItem(Items.LEAD);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
--- a/net/minecraft/client/data/models/ModelProvider.java
|
||||
+++ b/net/minecraft/client/data/models/ModelProvider.java
|
||||
@@ -45,11 +_,11 @@
|
||||
@@ -44,11 +_,11 @@
|
||||
|
||||
@Override
|
||||
public CompletableFuture<?> run(CachedOutput p_376268_) {
|
||||
public CompletableFuture<?> run(final CachedOutput cache) {
|
||||
- ModelProvider.ItemInfoCollector modelprovider$iteminfocollector = new ModelProvider.ItemInfoCollector();
|
||||
- ModelProvider.BlockStateGeneratorCollector modelprovider$blockstategeneratorcollector = new ModelProvider.BlockStateGeneratorCollector();
|
||||
+ ModelProvider.ItemInfoCollector modelprovider$iteminfocollector = new ModelProvider.ItemInfoCollector(this::getKnownItems);
|
||||
@@ -16,15 +16,15 @@
|
||||
modelprovider$blockstategeneratorcollector.validate();
|
||||
modelprovider$iteminfocollector.finalizeAndValidate();
|
||||
return CompletableFuture.allOf(
|
||||
@@ -59,6 +_,22 @@
|
||||
@@ -58,6 +_,22 @@
|
||||
);
|
||||
}
|
||||
|
||||
+ protected Stream<Block> getKnownBlocks() {
|
||||
+ protected java.util.stream.Stream<Block> getKnownBlocks() {
|
||||
+ return BuiltInRegistries.BLOCK.stream().filter(block -> "minecraft".equals(block.builtInRegistryHolder().key().identifier().getNamespace()));
|
||||
+ }
|
||||
+
|
||||
+ protected Stream<Item> getKnownItems() {
|
||||
+ protected java.util.stream.Stream<Item> getKnownItems() {
|
||||
+ return BuiltInRegistries.ITEM.stream().filter(item -> "minecraft".equals(item.builtInRegistryHolder().key().identifier().getNamespace()));
|
||||
+ }
|
||||
+
|
||||
@@ -39,73 +39,74 @@
|
||||
@Override
|
||||
public final String getName() {
|
||||
return "Model Definitions";
|
||||
@@ -67,6 +_,15 @@
|
||||
@@ -66,6 +_,15 @@
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static class BlockStateGeneratorCollector implements Consumer<BlockModelDefinitionGenerator> {
|
||||
private final Map<Block, BlockModelDefinitionGenerator> generators = new HashMap<>();
|
||||
+ private final Supplier<Stream<Block>> known;
|
||||
+ private final Supplier<java.util.stream.Stream<Block>> known;
|
||||
+
|
||||
+ public BlockStateGeneratorCollector() {
|
||||
+ this(() -> BuiltInRegistries.BLOCK.stream().filter(block -> "minecraft".equals(block.builtInRegistryHolder().key().identifier().getNamespace())));
|
||||
+ }
|
||||
+
|
||||
+ public BlockStateGeneratorCollector(Supplier<Stream<Block>> known) {
|
||||
+ public BlockStateGeneratorCollector(Supplier<java.util.stream.Stream<Block>> known) {
|
||||
+ this.known = known;
|
||||
+ }
|
||||
|
||||
public void accept(BlockModelDefinitionGenerator p_393399_) {
|
||||
Block block = p_393399_.block();
|
||||
@@ -77,7 +_,7 @@
|
||||
public void accept(final BlockModelDefinitionGenerator generator) {
|
||||
Block block = generator.block();
|
||||
@@ -76,8 +_,7 @@
|
||||
}
|
||||
|
||||
public void validate() {
|
||||
- Stream<Holder.Reference<Block>> stream = BuiltInRegistries.BLOCK.listElements().filter(p_376480_ -> true);
|
||||
+ Stream<Holder.Reference<Block>> stream = known.get().map(Block::builtInRegistryHolder);
|
||||
List<Identifier> list = stream.filter(p_378423_ -> !this.generators.containsKey(p_378423_.value()))
|
||||
.map(p_447940_ -> p_447940_.key().identifier())
|
||||
- List<Identifier> list = BuiltInRegistries.BLOCK
|
||||
- .listElements()
|
||||
+ List<Identifier> list = known.get().map(Block::builtInRegistryHolder)
|
||||
.filter(e -> !this.generators.containsKey(e.value()))
|
||||
.map(e -> e.key().identifier())
|
||||
.toList();
|
||||
@@ -97,6 +_,15 @@
|
||||
public static class ItemInfoCollector implements ItemModelOutput {
|
||||
private final Map<Item, ClientItem> itemInfos = new HashMap<>();
|
||||
private final Map<Item, Item> copies = new HashMap<>();
|
||||
+ private final Supplier<Stream<Item>> known;
|
||||
+ private final Supplier<java.util.stream.Stream<Item>> known;
|
||||
+
|
||||
+ public ItemInfoCollector() {
|
||||
+ this(() -> BuiltInRegistries.ITEM.stream().filter(item -> "minecraft".equals(item.builtInRegistryHolder().key().identifier().getNamespace())));
|
||||
+ }
|
||||
+
|
||||
+ public ItemInfoCollector(Supplier<Stream<Item>> known) {
|
||||
+ public ItemInfoCollector(Supplier<java.util.stream.Stream<Item>> known) {
|
||||
+ this.known = known;
|
||||
+ }
|
||||
|
||||
@Override
|
||||
public void accept(Item p_376450_, ItemModel.Unbaked p_378513_, ClientItem.Properties p_455809_) {
|
||||
public void accept(final Item item, final ItemModel.Unbaked model, final ClientItem.Properties properties) {
|
||||
@@ -115,7 +_,7 @@
|
||||
this.copies.put(p_376965_, p_377438_);
|
||||
this.copies.put(acceptor, donor);
|
||||
}
|
||||
|
||||
- public void finalizeAndValidate() {
|
||||
+ public void generateDefaultBlockModels() {
|
||||
BuiltInRegistries.ITEM.forEach(p_447944_ -> {
|
||||
if (!this.copies.containsKey(p_447944_)) {
|
||||
if (p_447944_ instanceof BlockItem blockitem && !this.itemInfos.containsKey(blockitem)) {
|
||||
BuiltInRegistries.ITEM.forEach(item -> {
|
||||
if (!this.copies.containsKey(item)) {
|
||||
if (item instanceof BlockItem blockitem && !this.itemInfos.containsKey(blockitem)) {
|
||||
@@ -124,6 +_,8 @@
|
||||
}
|
||||
}
|
||||
});
|
||||
+ }
|
||||
+ public void finalizeAndValidate() {
|
||||
this.copies.forEach((p_376289_, p_375718_) -> {
|
||||
ClientItem clientitem = this.itemInfos.get(p_375718_);
|
||||
this.copies.forEach((acceptor, donor) -> {
|
||||
ClientItem clientitem = this.itemInfos.get(donor);
|
||||
if (clientitem == null) {
|
||||
@@ -132,8 +_,8 @@
|
||||
this.register(p_376289_, clientitem);
|
||||
this.register(acceptor, clientitem);
|
||||
}
|
||||
});
|
||||
- List<Identifier> list = BuiltInRegistries.ITEM
|
||||
- .listElements()
|
||||
+ List<Identifier> list = known.get()
|
||||
+ .map(item -> item.builtInRegistryHolder())
|
||||
.filter(p_377225_ -> !this.itemInfos.containsKey(p_377225_.value()))
|
||||
.map(p_447943_ -> p_447943_.key().identifier())
|
||||
.filter(e -> !this.itemInfos.containsKey(e.value()))
|
||||
.map(e -> e.key().identifier())
|
||||
.toList();
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/client/gui/Font.java
|
||||
+++ b/net/minecraft/client/gui/Font.java
|
||||
@@ -32,7 +_,7 @@
|
||||
@@ -33,7 +_,7 @@
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/client/gui/Gui.java
|
||||
+++ b/net/minecraft/client/gui/Gui.java
|
||||
@@ -151,7 +_,7 @@
|
||||
@@ -150,7 +_,7 @@
|
||||
public float vignetteBrightness = 1.0F;
|
||||
private int toolHighlightTimer;
|
||||
private ItemStack lastToolHighlight = ItemStack.EMPTY;
|
||||
@@ -9,63 +9,63 @@
|
||||
private final SubtitleOverlay subtitleOverlay;
|
||||
private final SpectatorGui spectatorGui;
|
||||
private final PlayerTabOverlay tabList;
|
||||
@@ -193,6 +_,7 @@
|
||||
() -> new JumpableVehicleBarRenderer(p_330021_)
|
||||
@@ -192,6 +_,7 @@
|
||||
() -> new JumpableVehicleBarRenderer(minecraft)
|
||||
);
|
||||
this.resetTitleTimes();
|
||||
+ net.minecraftforge.client.gui.overlay.ForgeLayeredDraw.init(this, p_330021_);
|
||||
+ net.minecraftforge.client.gui.overlay.ForgeLayeredDraw.init(this, minecraft);
|
||||
}
|
||||
|
||||
public void resetTitleTimes() {
|
||||
@@ -203,6 +_,10 @@
|
||||
@@ -202,6 +_,10 @@
|
||||
|
||||
public void render(GuiGraphics p_282884_, DeltaTracker p_342095_) {
|
||||
public void extractRenderState(final GuiGraphicsExtractor graphics, final DeltaTracker deltaTracker) {
|
||||
if (!(this.minecraft.screen instanceof LevelLoadingScreen)) {
|
||||
+ if (Boolean.valueOf(true)) {
|
||||
+ net.minecraftforge.client.gui.overlay.ForgeLayeredDraw.beginRender(p_282884_, p_342095_);
|
||||
+ net.minecraftforge.client.gui.overlay.ForgeLayeredDraw.extractRenderState(graphics, deltaTracker);
|
||||
+ return;
|
||||
+ }
|
||||
if (!this.minecraft.options.hideGui) {
|
||||
this.renderCameraOverlays(p_282884_, p_342095_);
|
||||
this.renderCrosshair(p_282884_, p_342095_);
|
||||
@@ -386,7 +_,7 @@
|
||||
this.extractCameraOverlays(graphics, deltaTracker);
|
||||
this.extractCrosshair(graphics, deltaTracker);
|
||||
@@ -385,7 +_,7 @@
|
||||
int i = Mth.floor(this.minecraft.mouseHandler.getScaledXPos(window));
|
||||
int j = Mth.floor(this.minecraft.mouseHandler.getScaledYPos(window));
|
||||
p_329202_.nextStratum();
|
||||
- this.chat.render(p_329202_, this.getFont(), this.tickCount, i, j, false, false);
|
||||
+ net.minecraftforge.client.ForgeHooksClient.onCustomizeChatEvent(p_329202_, this.chat, window, i, j, this.tickCount, this.getFont());
|
||||
graphics.nextStratum();
|
||||
- this.chat.extractRenderState(graphics, this.getFont(), this.tickCount, i, j, ChatComponent.DisplayMode.BACKGROUND, false);
|
||||
+ net.minecraftforge.client.ForgeHooksClient.onCustomizeChatEvent(graphics, this.chat, window, i, j, this.tickCount, this.getFont());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -476,6 +_,8 @@
|
||||
@@ -475,6 +_,8 @@
|
||||
|
||||
for (MobEffectInstance mobeffectinstance : Ordering.natural().reverse().sortedCopy(collection)) {
|
||||
Holder<MobEffect> holder = mobeffectinstance.getEffect();
|
||||
+ var renderer = net.minecraftforge.client.extensions.common.IClientMobEffectExtensions.of(mobeffectinstance);
|
||||
+ if (!renderer.isVisibleInGui(mobeffectinstance)) continue;
|
||||
if (mobeffectinstance.showIcon()) {
|
||||
int k = p_282812_.guiWidth();
|
||||
int k = graphics.guiWidth();
|
||||
int l = 1;
|
||||
@@ -506,6 +_,7 @@
|
||||
@@ -505,6 +_,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
+ if (renderer.renderGuiIcon(mobeffectinstance, this, p_282812_, k, l, 0, f)) continue;
|
||||
p_282812_.blitSprite(RenderPipelines.GUI_TEXTURED, getMobEffectSprite(holder), k + 3, l + 3, 18, 18, ARGB.white(f));
|
||||
+ if (renderer.extractGuiIcon(mobeffectinstance, this, graphics, k, l, 0, f)) continue;
|
||||
graphics.blitSprite(RenderPipelines.GUI_TEXTURED, getMobEffectSprite(holder), k + 3, l + 3, 18, 18, ARGB.white(f));
|
||||
}
|
||||
}
|
||||
@@ -602,6 +_,10 @@
|
||||
@@ -605,6 +_,10 @@
|
||||
}
|
||||
|
||||
public void renderSelectedItemName(GuiGraphics p_283501_) {
|
||||
+ renderSelectedItemName(p_283501_, 0);
|
||||
public void extractSelectedItemName(final GuiGraphicsExtractor graphics) {
|
||||
+ renderSelectedItemName(graphics, 0);
|
||||
+ }
|
||||
+
|
||||
+ public void renderSelectedItemName(GuiGraphics p_283501_, int yShift) {
|
||||
Profiler.get().push("selectedItemName");
|
||||
+ public void renderSelectedItemName(final GuiGraphicsExtractor graphics, int yShift) {
|
||||
if (this.toolHighlightTimer > 0 && !this.lastToolHighlight.isEmpty()) {
|
||||
MutableComponent mutablecomponent = Component.empty().append(this.lastToolHighlight.getHoverName()).withStyle(this.lastToolHighlight.getRarity().color());
|
||||
@@ -609,9 +_,13 @@
|
||||
MutableComponent mutablecomponent = Component.empty()
|
||||
.append(this.lastToolHighlight.getHoverName())
|
||||
@@ -613,9 +_,13 @@
|
||||
mutablecomponent.withStyle(ChatFormatting.ITALIC);
|
||||
}
|
||||
|
||||
@@ -75,27 +75,29 @@
|
||||
+ if (font == null)
|
||||
+ font = this.getFont();
|
||||
+ int i = font.width(highlightTip);
|
||||
int j = (p_283501_.guiWidth() - i) / 2;
|
||||
- int k = p_283501_.guiHeight() - 59;
|
||||
+ int k = p_283501_.guiHeight() - Math.max(yShift, 59);
|
||||
int j = (graphics.guiWidth() - i) / 2;
|
||||
- int k = graphics.guiHeight() - 59;
|
||||
+ int k = graphics.guiHeight() - Math.max(yShift, 59);
|
||||
if (!this.minecraft.gameMode.canHurtPlayer()) {
|
||||
k += 14;
|
||||
}
|
||||
@@ -622,7 +_,7 @@
|
||||
@@ -626,7 +_,7 @@
|
||||
}
|
||||
|
||||
if (l > 0) {
|
||||
- p_283501_.drawStringWithBackdrop(this.getFont(), mutablecomponent, j, k, i, ARGB.white(l));
|
||||
+ p_283501_.drawStringWithBackdrop(font, highlightTip, j, k, i, ARGB.white(l));
|
||||
- graphics.textWithBackdrop(this.getFont(), mutablecomponent, j, k, i, ARGB.white(l));
|
||||
+ graphics.textWithBackdrop(font, highlightTip, j, k, i, ARGB.white(l));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1148,7 +_,7 @@
|
||||
ItemStack itemstack = this.minecraft.player.getInventory().getSelectedItem();
|
||||
if (itemstack.isEmpty()) {
|
||||
}
|
||||
@@ -1165,7 +_,9 @@
|
||||
this.toolHighlightTimer = 0;
|
||||
- } else if (this.lastToolHighlight.isEmpty() || !itemstack.is(this.lastToolHighlight.getItem()) || !itemstack.getHoverName().equals(this.lastToolHighlight.getHoverName())) {
|
||||
+ } else if (this.lastToolHighlight.isEmpty() || !itemstack.is(this.lastToolHighlight.getItem()) || !itemstack.getHoverName().equals(this.lastToolHighlight.getHoverName()) || !itemstack.getHighlightTip(itemstack.getHoverName()).equals(lastToolHighlight.getHighlightTip(lastToolHighlight.getHoverName()))) {
|
||||
} else if (this.lastToolHighlight.isEmpty()
|
||||
|| !itemstack.is(this.lastToolHighlight.getItem())
|
||||
- || !itemstack.getHoverName().equals(this.lastToolHighlight.getHoverName())) {
|
||||
+ || !itemstack.getHoverName().equals(this.lastToolHighlight.getHoverName())
|
||||
+ || !itemstack.getHighlightTip(itemstack.getHoverName()).equals(lastToolHighlight.getHighlightTip(lastToolHighlight.getHoverName()))
|
||||
+ ) {
|
||||
this.toolHighlightTimer = (int)(40.0 * this.minecraft.options.notificationDisplayTime().get());
|
||||
} else if (this.toolHighlightTimer > 0) {
|
||||
this.toolHighlightTimer--;
|
||||
@@ -1,164 +0,0 @@
|
||||
--- a/net/minecraft/client/gui/GuiGraphics.java
|
||||
+++ b/net/minecraft/client/gui/GuiGraphics.java
|
||||
@@ -86,7 +_,7 @@
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
-public class GuiGraphics {
|
||||
+public class GuiGraphics implements net.minecraftforge.client.extensions.IForgeGuiGraphics {
|
||||
private static final int EXTRA_SPACE_AFTER_FIRST_TOOLTIP_LINE = 2;
|
||||
final Minecraft minecraft;
|
||||
private final Matrix3x2fStack pose;
|
||||
@@ -972,6 +_,7 @@
|
||||
CrashReport crashreport = CrashReport.forThrowable(throwable, "Rendering item");
|
||||
CrashReportCategory crashreportcategory = crashreport.addCategory("Item being rendered");
|
||||
crashreportcategory.setDetail("Item Type", () -> String.valueOf(p_283653_.getItem()));
|
||||
+ crashreportcategory.setDetail("Registry Name", () -> String.valueOf(net.minecraftforge.registries.ForgeRegistries.ITEMS.getKey(p_283653_.getItem())));
|
||||
crashreportcategory.setDetail("Item Components", () -> String.valueOf(p_283653_.getComponents()));
|
||||
crashreportcategory.setDetail("Item Foil", () -> String.valueOf(p_283653_.hasFoil()));
|
||||
throw new ReportedException(crashreport);
|
||||
@@ -990,6 +_,7 @@
|
||||
this.renderItemCooldown(p_283349_, p_282641_, p_282146_);
|
||||
this.renderItemCount(p_282005_, p_283349_, p_282641_, p_282146_, p_282803_);
|
||||
this.pose.popMatrix();
|
||||
+ net.minecraftforge.client.ItemDecoratorHandler.of(p_283349_).render(this, p_282005_, p_283349_, p_282641_, p_282146_);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1001,21 +_,30 @@
|
||||
this.setTooltipForNextFrame(this.minecraft.font, p_407686_, DefaultTooltipPositioner.INSTANCE, p_410475_, p_407139_, false);
|
||||
}
|
||||
|
||||
+ private ItemStack tooltipStack = ItemStack.EMPTY;
|
||||
+
|
||||
public void setTooltipForNextFrame(Font p_408152_, ItemStack p_410145_, int p_410585_, int p_408354_) {
|
||||
+ this.tooltipStack = p_410145_;
|
||||
this.setTooltipForNextFrame(
|
||||
p_408152_, Screen.getTooltipFromItem(this.minecraft, p_410145_), p_410145_.getTooltipImage(), p_410585_, p_408354_, p_410145_.get(DataComponents.TOOLTIP_STYLE)
|
||||
);
|
||||
+ this.tooltipStack = ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
public void setTooltipForNextFrame(Font p_407170_, List<Component> p_407123_, Optional<TooltipComponent> p_409349_, int p_406573_, int p_409911_) {
|
||||
this.setTooltipForNextFrame(p_407170_, p_407123_, p_409349_, p_406573_, p_409911_, null);
|
||||
}
|
||||
|
||||
+ public void setTooltipForNextFrame(Font font, List<Component> textComponents, Optional<TooltipComponent> tooltipComponent, ItemStack stack, int mouseX, int mouseY) {
|
||||
+ this.tooltipStack = stack;
|
||||
+ this.setTooltipForNextFrame(font, textComponents, tooltipComponent, mouseX, mouseY, stack.get(DataComponents.TOOLTIP_STYLE));
|
||||
+ this.tooltipStack = ItemStack.EMPTY;
|
||||
+ }
|
||||
+
|
||||
public void setTooltipForNextFrame(
|
||||
Font p_408450_, List<Component> p_405939_, Optional<TooltipComponent> p_456997_, int p_409519_, int p_410392_, @Nullable Identifier p_460731_
|
||||
) {
|
||||
- List<ClientTooltipComponent> list = p_405939_.stream().map(Component::getVisualOrderText).map(ClientTooltipComponent::create).collect(Util.toMutableList());
|
||||
- p_456997_.ifPresent(p_325321_ -> list.add(list.isEmpty() ? 0 : 1, ClientTooltipComponent.create(p_325321_)));
|
||||
+ List<ClientTooltipComponent> list = net.minecraftforge.client.ForgeHooksClient.gatherTooltipComponents(this.tooltipStack, p_405939_, p_456997_, p_409519_, guiWidth(), guiHeight(), p_408450_);
|
||||
this.setTooltipForNextFrameInternal(p_408450_, list, p_409519_, p_410392_, DefaultTooltipPositioner.INSTANCE, p_460731_, false);
|
||||
}
|
||||
|
||||
@@ -1028,7 +_,22 @@
|
||||
}
|
||||
|
||||
public void setComponentTooltipForNextFrame(Font p_406239_, List<Component> p_410275_, int p_410594_, int p_409343_) {
|
||||
- this.setComponentTooltipForNextFrame(p_406239_, p_410275_, p_410594_, p_409343_, null);
|
||||
+ List<ClientTooltipComponent> components = net.minecraftforge.client.ForgeHooksClient.gatherTooltipComponents(this.tooltipStack, p_410275_, p_410594_, guiWidth(), guiHeight(), p_406239_);
|
||||
+ this.setTooltipForNextFrameInternal(p_406239_, components, p_410594_, p_409343_, DefaultTooltipPositioner.INSTANCE, null, false);
|
||||
+ }
|
||||
+
|
||||
+ public void renderComponentTooltip(Font font, List<? extends net.minecraft.network.chat.FormattedText> tooltips, int mouseX, int mouseY, ItemStack stack) {
|
||||
+ this.tooltipStack = stack;
|
||||
+ List<ClientTooltipComponent> components = net.minecraftforge.client.ForgeHooksClient.gatherTooltipComponents(stack, tooltips, mouseX, guiWidth(), guiHeight(), font);
|
||||
+ this.setTooltipForNextFrameInternal(font, components, mouseX, mouseY, DefaultTooltipPositioner.INSTANCE, null, false);
|
||||
+ this.tooltipStack = ItemStack.EMPTY;
|
||||
+ }
|
||||
+
|
||||
+ public void renderComponentTooltipFromElements(Font font, List<com.mojang.datafixers.util.Either<FormattedText, TooltipComponent>> elements, int mouseX, int mouseY, ItemStack stack) {
|
||||
+ this.tooltipStack = stack;
|
||||
+ List<ClientTooltipComponent> components = net.minecraftforge.client.ForgeHooksClient.gatherTooltipComponentsFromElements(stack, elements, mouseX, guiWidth(), guiHeight(), font);
|
||||
+ this.setTooltipForNextFrameInternal(font, components, mouseX, mouseY, DefaultTooltipPositioner.INSTANCE, null, false);
|
||||
+ this.tooltipStack = ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
public void setComponentTooltipForNextFrame(Font p_408650_, List<Component> p_407512_, int p_406019_, int p_408123_, @Nullable Identifier p_456486_) {
|
||||
@@ -1073,24 +_,31 @@
|
||||
int p_407794_,
|
||||
int p_408784_,
|
||||
ClientTooltipPositioner p_408798_,
|
||||
- @Nullable Identifier p_451079_,
|
||||
+ @Nullable Identifier p_456486_,
|
||||
boolean p_410618_
|
||||
) {
|
||||
if (!p_409928_.isEmpty()) {
|
||||
if (this.deferredTooltip == null || p_410618_) {
|
||||
- this.deferredTooltip = () -> this.renderTooltip(p_406605_, p_409928_, p_407794_, p_408784_, p_408798_, p_451079_);
|
||||
+ final var stackContext = this.tooltipStack;
|
||||
+ this.deferredTooltip = () -> this.renderTooltip(p_406605_, p_409928_, p_407794_, p_408784_, p_408798_, p_456486_, stackContext);
|
||||
}
|
||||
}
|
||||
+ }
|
||||
+
|
||||
+ public void renderTooltip(Font p_283128_, List<ClientTooltipComponent> p_282716_, int p_283678_, int p_281696_, ClientTooltipPositioner p_409451_, @Nullable Identifier p_456486_) {
|
||||
+ renderTooltip(p_283128_, p_282716_, p_283678_, p_281696_, p_409451_, p_456486_, ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
public void renderTooltip(
|
||||
- Font p_283128_, List<ClientTooltipComponent> p_282716_, int p_283678_, int p_281696_, ClientTooltipPositioner p_409451_, @Nullable Identifier p_459396_
|
||||
+ Font p_283128_, List<ClientTooltipComponent> p_282716_, int p_283678_, int p_281696_, ClientTooltipPositioner p_409451_, @Nullable Identifier p_459396_, ItemStack itemstack
|
||||
) {
|
||||
+ var preEvent = net.minecraftforge.client.ForgeHooksClient.onRenderTooltipPre(itemstack, this, p_283678_, p_281696_, guiWidth(), guiHeight(), p_282716_, p_283128_, p_409451_, p_459396_);
|
||||
+ if (preEvent == null) return;
|
||||
int i = 0;
|
||||
int j = p_282716_.size() == 1 ? -2 : 0;
|
||||
|
||||
for (ClientTooltipComponent clienttooltipcomponent : p_282716_) {
|
||||
- int k = clienttooltipcomponent.getWidth(p_283128_);
|
||||
+ int k = clienttooltipcomponent.getWidth(preEvent.getFont());
|
||||
if (k > i) {
|
||||
i = k;
|
||||
}
|
||||
@@ -1100,16 +_,16 @@
|
||||
|
||||
int l1 = i;
|
||||
int i2 = j;
|
||||
- Vector2ic vector2ic = p_409451_.positionTooltip(this.guiWidth(), this.guiHeight(), p_283678_, p_281696_, i, j);
|
||||
+ Vector2ic vector2ic = p_409451_.positionTooltip(this.guiWidth(), this.guiHeight(), preEvent.getX(), preEvent.getY(), i, j);
|
||||
int l = vector2ic.x();
|
||||
int i1 = vector2ic.y();
|
||||
this.pose.pushMatrix();
|
||||
- TooltipRenderUtil.renderTooltipBackground(this, l, i1, i, j, p_459396_);
|
||||
+ TooltipRenderUtil.renderTooltipBackground(this, l, i1, i, j, preEvent.getBackground());
|
||||
int j1 = i1;
|
||||
|
||||
for (int k1 = 0; k1 < p_282716_.size(); k1++) {
|
||||
ClientTooltipComponent clienttooltipcomponent1 = p_282716_.get(k1);
|
||||
- clienttooltipcomponent1.renderText(this, p_283128_, l, j1);
|
||||
+ clienttooltipcomponent1.renderText(this, preEvent.getFont(), l, j1);
|
||||
j1 += clienttooltipcomponent1.getHeight(p_283128_) + (k1 == 0 ? 2 : 0);
|
||||
}
|
||||
|
||||
@@ -1117,7 +_,7 @@
|
||||
|
||||
for (int j2 = 0; j2 < p_282716_.size(); j2++) {
|
||||
ClientTooltipComponent clienttooltipcomponent2 = p_282716_.get(j2);
|
||||
- clienttooltipcomponent2.renderImage(p_283128_, l, j1, l1, i2, this);
|
||||
+ clienttooltipcomponent2.renderImage(preEvent.getFont(), l, j1, l1, i2, this);
|
||||
j1 += clienttooltipcomponent2.getHeight(p_283128_) + (j2 == 0 ? 2 : 0);
|
||||
}
|
||||
|
||||
@@ -1328,6 +_,14 @@
|
||||
|
||||
public void submitProfilerChartRenderState(List<ResultField> p_408565_, int p_410147_, int p_406156_, int p_407365_, int p_408180_) {
|
||||
this.guiRenderState.submitPicturesInPictureState(new GuiProfilerChartRenderState(p_408565_, p_410147_, p_406156_, p_407365_, p_408180_, this.scissorStack.peek()));
|
||||
+ }
|
||||
+
|
||||
+ public GuiRenderState getRenderState() {
|
||||
+ return this.guiRenderState;
|
||||
+ }
|
||||
+
|
||||
+ public GuiGraphics.ScissorStack getScissorStack() {
|
||||
+ return this.scissorStack;
|
||||
}
|
||||
|
||||
public TextureAtlasSprite getSprite(Material p_430745_) {
|
||||
@@ -0,0 +1,171 @@
|
||||
--- a/net/minecraft/client/gui/GuiGraphicsExtractor.java
|
||||
+++ b/net/minecraft/client/gui/GuiGraphicsExtractor.java
|
||||
@@ -88,7 +_,7 @@
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
-public class GuiGraphicsExtractor {
|
||||
+public class GuiGraphicsExtractor implements net.minecraftforge.client.extensions.IForgeGuiGraphicsExtractor {
|
||||
private static final int EXTRA_SPACE_AFTER_FIRST_TOOLTIP_LINE = 2;
|
||||
private final Minecraft minecraft;
|
||||
private final Matrix3x2fStack pose;
|
||||
@@ -867,6 +_,7 @@
|
||||
CrashReport crashreport = CrashReport.forThrowable(throwable, "Rendering item");
|
||||
CrashReportCategory crashreportcategory = crashreport.addCategory("Item being rendered");
|
||||
crashreportcategory.setDetail("Item Type", () -> String.valueOf(itemStack.getItem()));
|
||||
+ crashreportcategory.setDetail("Registry Name", () -> String.valueOf(net.minecraftforge.registries.ForgeRegistries.ITEMS.getKey(itemStack.getItem())));
|
||||
crashreportcategory.setDetail("Item Components", () -> String.valueOf(itemStack.getComponents()));
|
||||
crashreportcategory.setDetail("Item Foil", () -> String.valueOf(itemStack.hasFoil()));
|
||||
throw new ReportedException(crashreport);
|
||||
@@ -893,6 +_,7 @@
|
||||
this.itemCooldown(itemStack, x, y);
|
||||
this.itemCount(font, itemStack, x, y, countText);
|
||||
this.pose.popMatrix();
|
||||
+ net.minecraftforge.client.ItemDecoratorHandler.of(itemStack).render(this, font, itemStack, x, y);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1069,16 +_,25 @@
|
||||
this.setTooltipForNextFrame(this.minecraft.font, formattedCharSequences, DefaultTooltipPositioner.INSTANCE, x, y, false);
|
||||
}
|
||||
|
||||
+ private ItemStack tooltipStack = ItemStack.EMPTY;
|
||||
public void setTooltipForNextFrame(final Font font, final ItemStack itemStack, final int xo, final int yo) {
|
||||
+ this.tooltipStack = itemStack;
|
||||
this.setTooltipForNextFrame(
|
||||
font, Screen.getTooltipFromItem(this.minecraft, itemStack), itemStack.getTooltipImage(), xo, yo, itemStack.get(DataComponents.TOOLTIP_STYLE)
|
||||
);
|
||||
+ this.tooltipStack = ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
public void setTooltipForNextFrame(final Font font, final List<Component> texts, final Optional<TooltipComponent> optionalImage, final int xo, final int yo) {
|
||||
this.setTooltipForNextFrame(font, texts, optionalImage, xo, yo, null);
|
||||
}
|
||||
|
||||
+ public void setTooltipForNextFrame(Font font, List<Component> texts, Optional<TooltipComponent> optionalImage, ItemStack stack, int xo, int yo) {
|
||||
+ this.tooltipStack = stack;
|
||||
+ this.setTooltipForNextFrame(font, texts, optionalImage, xo, yo, stack.get(DataComponents.TOOLTIP_STYLE));
|
||||
+ this.tooltipStack = ItemStack.EMPTY;
|
||||
+ }
|
||||
+
|
||||
public void setTooltipForNextFrame(
|
||||
final Font font,
|
||||
final List<Component> texts,
|
||||
@@ -1087,8 +_,7 @@
|
||||
final int yo,
|
||||
final @Nullable Identifier style
|
||||
) {
|
||||
- List<ClientTooltipComponent> list = texts.stream().map(Component::getVisualOrderText).map(ClientTooltipComponent::create).collect(Util.toMutableList());
|
||||
- optionalImage.ifPresent(image -> list.add(list.isEmpty() ? 0 : 1, ClientTooltipComponent.create(image)));
|
||||
+ List<ClientTooltipComponent> list = net.minecraftforge.client.ForgeHooksClient.gatherTooltipComponents(this.tooltipStack, texts, optionalImage, xo, guiWidth(), guiHeight(), font);
|
||||
this.setTooltipForNextFrameInternal(font, list, xo, yo, DefaultTooltipPositioner.INSTANCE, style, false);
|
||||
}
|
||||
|
||||
@@ -1116,7 +_,22 @@
|
||||
}
|
||||
|
||||
public void setComponentTooltipForNextFrame(final Font font, final List<Component> lines, final int xo, final int yo) {
|
||||
- this.setComponentTooltipForNextFrame(font, lines, xo, yo, null);
|
||||
+ List<ClientTooltipComponent> components = net.minecraftforge.client.ForgeHooksClient.gatherTooltipComponents(this.tooltipStack, lines, xo, guiWidth(), guiHeight(), font);
|
||||
+ this.setTooltipForNextFrameInternal(font, components, xo, yo, DefaultTooltipPositioner.INSTANCE, null, false);
|
||||
+ }
|
||||
+
|
||||
+ public void renderComponentTooltip(Font font, List<? extends net.minecraft.network.chat.FormattedText> lines, int xo, int yo, ItemStack stack) {
|
||||
+ this.tooltipStack = stack;
|
||||
+ List<ClientTooltipComponent> components = net.minecraftforge.client.ForgeHooksClient.gatherTooltipComponents(stack, lines, xo, guiWidth(), guiHeight(), font);
|
||||
+ this.setTooltipForNextFrameInternal(font, components, xo, yo, DefaultTooltipPositioner.INSTANCE, null, false);
|
||||
+ this.tooltipStack = ItemStack.EMPTY;
|
||||
+ }
|
||||
+
|
||||
+ public void renderComponentTooltipFromElements(Font font, List<com.mojang.datafixers.util.Either<FormattedText, TooltipComponent>> lines, int xo, int yo, ItemStack stack) {
|
||||
+ this.tooltipStack = stack;
|
||||
+ List<ClientTooltipComponent> components = net.minecraftforge.client.ForgeHooksClient.gatherTooltipComponentsFromElements(stack, lines, xo, guiWidth(), guiHeight(), font);
|
||||
+ this.setTooltipForNextFrameInternal(font, components, xo, yo, DefaultTooltipPositioner.INSTANCE, null, false);
|
||||
+ this.tooltipStack = ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
public void setComponentTooltipForNextFrame(final Font font, final List<Component> lines, final int xo, final int yo, final @Nullable Identifier style) {
|
||||
@@ -1167,10 +_,16 @@
|
||||
) {
|
||||
if (!lines.isEmpty()) {
|
||||
if (this.deferredTooltip == null || replaceExisting) {
|
||||
- this.deferredTooltip = () -> this.tooltip(font, lines, xo, yo, positioner, style);
|
||||
+ final var stackContext = this.tooltipStack;
|
||||
+ this.deferredTooltip = () -> this.tooltip(font, lines, xo, yo, positioner, style, stackContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
+
|
||||
+ public void tooltip(Font font, List<ClientTooltipComponent> lines, int xo, int yo, ClientTooltipPositioner positioner, @Nullable Identifier style) {
|
||||
+ tooltip(font, lines, xo, yo, positioner, style, ItemStack.EMPTY);
|
||||
+ }
|
||||
+
|
||||
|
||||
public void tooltip(
|
||||
final Font font,
|
||||
@@ -1178,13 +_,16 @@
|
||||
final int xo,
|
||||
final int yo,
|
||||
final ClientTooltipPositioner positioner,
|
||||
- final @Nullable Identifier style
|
||||
+ final @Nullable Identifier style,
|
||||
+ ItemStack itemstack
|
||||
) {
|
||||
+ var preEvent = net.minecraftforge.client.ForgeHooksClient.onRenderTooltipPre(itemstack, this, xo, yo, guiWidth(), guiHeight(), lines, font, positioner, style);
|
||||
+ if (preEvent == null) return;
|
||||
int i = 0;
|
||||
int j = lines.size() == 1 ? -2 : 0;
|
||||
|
||||
for (ClientTooltipComponent clienttooltipcomponent : lines) {
|
||||
- int k = clienttooltipcomponent.getWidth(font);
|
||||
+ int k = clienttooltipcomponent.getWidth(preEvent.getFont());
|
||||
if (k > i) {
|
||||
i = k;
|
||||
}
|
||||
@@ -1194,25 +_,25 @@
|
||||
|
||||
int l1 = i;
|
||||
int i2 = j;
|
||||
- Vector2ic vector2ic = positioner.positionTooltip(this.guiWidth(), this.guiHeight(), xo, yo, i, j);
|
||||
+ Vector2ic vector2ic = positioner.positionTooltip(this.guiWidth(), this.guiHeight(), preEvent.getX(), preEvent.getY(), i, j);
|
||||
int l = vector2ic.x();
|
||||
int i1 = vector2ic.y();
|
||||
this.pose.pushMatrix();
|
||||
- TooltipRenderUtil.extractTooltipBackground(this, l, i1, i, j, style);
|
||||
+ TooltipRenderUtil.extractTooltipBackground(this, l, i1, i, j, preEvent.getBackground());
|
||||
int j1 = i1;
|
||||
|
||||
for (int k1 = 0; k1 < lines.size(); k1++) {
|
||||
ClientTooltipComponent clienttooltipcomponent1 = lines.get(k1);
|
||||
- clienttooltipcomponent1.extractText(this, font, l, j1);
|
||||
- j1 += clienttooltipcomponent1.getHeight(font) + (k1 == 0 ? 2 : 0);
|
||||
+ clienttooltipcomponent1.extractText(this, preEvent.getFont(), l, j1);
|
||||
+ j1 += clienttooltipcomponent1.getHeight(preEvent.getFont()) + (k1 == 0 ? 2 : 0);
|
||||
}
|
||||
|
||||
j1 = i1;
|
||||
|
||||
for (int j2 = 0; j2 < lines.size(); j2++) {
|
||||
ClientTooltipComponent clienttooltipcomponent2 = lines.get(j2);
|
||||
- clienttooltipcomponent2.extractImage(font, l, j1, l1, i2, this);
|
||||
- j1 += clienttooltipcomponent2.getHeight(font) + (j2 == 0 ? 2 : 0);
|
||||
+ clienttooltipcomponent2.extractImage(preEvent.getFont(), l, j1, l1, i2, this);
|
||||
+ j1 += clienttooltipcomponent2.getHeight(preEvent.getFont()) + (j2 == 0 ? 2 : 0);
|
||||
}
|
||||
|
||||
this.pose.popMatrix();
|
||||
@@ -1287,6 +_,14 @@
|
||||
|
||||
private ActiveTextCollector.Parameters createDefaultTextParameters(final float opacity) {
|
||||
return new ActiveTextCollector.Parameters(new Matrix3x2f(this.pose), opacity, this.scissorStack.peek());
|
||||
+ }
|
||||
+
|
||||
+ public GuiRenderState getRenderState() {
|
||||
+ return this.guiRenderState;
|
||||
+ }
|
||||
+
|
||||
+ public GuiGraphicsExtractor.ScissorStack getScissorStack() {
|
||||
+ return this.scissorStack;
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@@ -1,7 +1,7 @@
|
||||
--- a/net/minecraft/client/gui/components/AbstractWidget.java
|
||||
+++ b/net/minecraft/client/gui/components/AbstractWidget.java
|
||||
@@ -221,6 +_,23 @@
|
||||
this.focused = p_93693_;
|
||||
this.focused = focused;
|
||||
}
|
||||
|
||||
+ public static final int UNSET_FG_COLOR = -1;
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
--- a/net/minecraft/client/gui/components/BossHealthOverlay.java
|
||||
+++ b/net/minecraft/client/gui/components/BossHealthOverlay.java
|
||||
@@ -67,13 +_,16 @@
|
||||
@@ -68,13 +_,16 @@
|
||||
|
||||
for (LerpingBossEvent lerpingbossevent : this.events.values()) {
|
||||
int k = i / 2 - 91;
|
||||
+ var event = net.minecraftforge.client.ForgeHooksClient.onCustomizeBossEventProgress(p_283175_, this.minecraft.getWindow(), lerpingbossevent, k, j, 10 + this.minecraft.font.lineHeight);
|
||||
+ var event = net.minecraftforge.client.ForgeHooksClient.onCustomizeBossEventProgress(graphics, this.minecraft.getWindow(), lerpingbossevent, k, j, 10 + this.minecraft.font.lineHeight);
|
||||
+ if (event != null) {
|
||||
this.drawBar(p_283175_, k, j, lerpingbossevent);
|
||||
this.extractBar(graphics, k, j, lerpingbossevent);
|
||||
Component component = lerpingbossevent.getName();
|
||||
int l = this.minecraft.font.width(component);
|
||||
int i1 = i / 2 - l / 2;
|
||||
int j1 = j - 9;
|
||||
p_283175_.drawString(this.minecraft.font, component, i1, j1, -1);
|
||||
graphics.text(this.minecraft.font, component, i1, j1, -1);
|
||||
- j += 10 + 9;
|
||||
+ }
|
||||
+ j += event.getIncrement();
|
||||
if (j >= p_283175_.guiHeight() / 3) {
|
||||
if (j >= graphics.guiHeight() / 3) {
|
||||
break;
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
--- a/net/minecraft/client/gui/components/Button.java
|
||||
+++ b/net/minecraft/client/gui/components/Button.java
|
||||
@@ -33,6 +_,12 @@
|
||||
this.createNarration = p_259552_;
|
||||
@@ -39,6 +_,12 @@
|
||||
this.createNarration = createNarration;
|
||||
}
|
||||
|
||||
+ // Forge (GH-9238)
|
||||
@@ -11,9 +11,9 @@
|
||||
+ }
|
||||
+
|
||||
@Override
|
||||
public void onPress(InputWithModifiers p_424878_) {
|
||||
public void onPress(final InputWithModifiers input) {
|
||||
this.onPress.onPress(this);
|
||||
@@ -96,9 +_,12 @@
|
||||
@@ -102,9 +_,12 @@
|
||||
}
|
||||
|
||||
public Button build() {
|
||||
@@ -29,10 +29,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,6 +_,10 @@
|
||||
int p_455297_, int p_455388_, int p_459653_, int p_452847_, Component p_459347_, Button.OnPress p_453378_, Button.CreateNarration p_456163_
|
||||
@@ -130,6 +_,10 @@
|
||||
final Button.CreateNarration createNarration
|
||||
) {
|
||||
super(p_455297_, p_455388_, p_459653_, p_452847_, p_459347_, p_453378_, p_456163_);
|
||||
super(x, y, width, height, message, onPress, createNarration);
|
||||
+ }
|
||||
+
|
||||
+ protected Plain(Builder builder) {
|
||||
|
||||
+3
-3
@@ -1,10 +1,10 @@
|
||||
--- a/net/minecraft/client/gui/components/debug/DebugEntryLookingAtEntity.java
|
||||
+++ b/net/minecraft/client/gui/components/debug/DebugEntryLookingAtEntity.java
|
||||
@@ -25,6 +_,7 @@
|
||||
@@ -29,6 +_,7 @@
|
||||
if (entity != null) {
|
||||
list.add(ChatFormatting.UNDERLINE + "Targeted Entity");
|
||||
list.add(String.valueOf(BuiltInRegistries.ENTITY_TYPE.getKey(entity.getType())));
|
||||
list.add(entity.typeHolder().getRegisteredName());
|
||||
+ entity.getType().builtInRegistryHolder().tags().forEach(t -> list.add("#" + t.location()));
|
||||
}
|
||||
|
||||
p_426755_.addToGroup(GROUP, list);
|
||||
displayer.addToGroup(GROUP, list);
|
||||
+4
-4
@@ -1,10 +1,10 @@
|
||||
--- a/net/minecraft/client/gui/components/toasts/ToastManager.java
|
||||
+++ b/net/minecraft/client/gui/components/toasts/ToastManager.java
|
||||
@@ -142,6 +_,7 @@
|
||||
@@ -143,6 +_,7 @@
|
||||
}
|
||||
|
||||
public void addToast(Toast p_360768_) {
|
||||
+ if (net.minecraftforge.client.event.ForgeEventFactoryClient.onToastAdd(p_360768_)) return;
|
||||
this.queued.add(p_360768_);
|
||||
public void addToast(final Toast toast) {
|
||||
+ if (net.minecraftforge.client.event.ForgeEventFactoryClient.onToastAdd(toast)) return;
|
||||
this.queued.add(toast);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
--- a/net/minecraft/client/gui/render/GuiRenderer.java
|
||||
+++ b/net/minecraft/client/gui/render/GuiRenderer.java
|
||||
@@ -138,6 +_,7 @@
|
||||
@@ -131,6 +_,7 @@
|
||||
builder.put((Class<? extends PictureInPictureRenderState>)pictureinpicturerenderer.getRenderStateClass(), pictureinpicturerenderer);
|
||||
}
|
||||
|
||||
+ net.minecraftforge.client.ForgeHooksClient.onRegisterPictureInPictureRenderers(p_410565_, p_410441_, builder);
|
||||
+ net.minecraftforge.client.ForgeHooksClient.onRegisterPictureInPictureRenderers(pictureInPictureRenderers, bufferSource, builder);
|
||||
this.pictureInPictureRenderers = builder.buildOrThrow();
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
--- a/net/minecraft/client/gui/screens/ChatScreen.java
|
||||
+++ b/net/minecraft/client/gui/screens/ChatScreen.java
|
||||
@@ -115,6 +_,7 @@
|
||||
} else if (p_426273_.isConfirmation()) {
|
||||
this.handleChatInput(this.input.getValue(), true);
|
||||
this.exitReason = ChatScreen.ExitReason.DONE;
|
||||
+ if (this.minecraft.screen == this) // FORGE: Prevent closing the screen if another screen has been opened.
|
||||
this.minecraft.setScreen(null);
|
||||
return true;
|
||||
} else {
|
||||
@@ -139,6 +_,7 @@
|
||||
this.handleChatInput(this.input.getValue(), true);
|
||||
if (this.closeOnSubmit) {
|
||||
this.exitReason = ChatScreen.ExitReason.DONE;
|
||||
+ if (this.minecraft.screen == this) // FORGE: Prevent closing the screen if another screen has been opened.
|
||||
this.minecraft.setScreen(null);
|
||||
} else {
|
||||
this.input.setValue("");
|
||||
@@ -1,11 +1,11 @@
|
||||
--- a/net/minecraft/client/gui/screens/ConnectScreen.java
|
||||
+++ b/net/minecraft/client/gui/screens/ConnectScreen.java
|
||||
@@ -102,6 +_,8 @@
|
||||
@@ -114,6 +_,8 @@
|
||||
}
|
||||
|
||||
if (optional.isEmpty()) {
|
||||
+ ConnectScreen.LOGGER.error("Couldn't connect to server: Unknown host \"{}\"", p_249536_.getHost());
|
||||
+ ConnectScreen.LOGGER.error("Couldn't connect to server: Unknown host \"{}\"", hostAndPort.getHost());
|
||||
+ net.minecraftforge.network.DualStackUtils.logInitialPreferences();
|
||||
p_251955_.execute(
|
||||
() -> p_251955_.setScreen(new DisconnectedScreen(ConnectScreen.this.parent, ConnectScreen.this.connectFailedTitle, ConnectScreen.UNKNOWN_HOST_MESSAGE))
|
||||
);
|
||||
minecraft.execute(
|
||||
() -> minecraft.setScreen(
|
||||
new DisconnectedScreen(ConnectScreen.this.parent, ConnectScreen.this.connectFailedTitle, ConnectScreen.UNKNOWN_HOST_MESSAGE)
|
||||
@@ -1,25 +1,25 @@
|
||||
--- a/net/minecraft/client/gui/screens/LoadingOverlay.java
|
||||
+++ b/net/minecraft/client/gui/screens/LoadingOverlay.java
|
||||
@@ -63,6 +_,8 @@
|
||||
return p_169325_ & 16777215 | p_169326_ << 24;
|
||||
@@ -64,6 +_,8 @@
|
||||
return color & 16777215 | alpha << 24;
|
||||
}
|
||||
|
||||
+ protected boolean renderContents(GuiGraphics gui, float alpha) { return true; }
|
||||
+ protected boolean extractContentRenderState(final GuiGraphicsExtractor graphics, float alpha) { return true; }
|
||||
+
|
||||
@Override
|
||||
public void render(GuiGraphics p_281839_, int p_282704_, int p_283650_, float p_283394_) {
|
||||
int i = p_281839_.guiWidth();
|
||||
public void extractRenderState(final GuiGraphicsExtractor graphics, final int mouseX, final int mouseY, final float a) {
|
||||
int i = graphics.guiWidth();
|
||||
@@ -103,6 +_,7 @@
|
||||
f2 = 1.0F;
|
||||
}
|
||||
|
||||
+ if (renderContents(p_281839_, f2)) {
|
||||
int l2 = (int)(p_281839_.guiWidth() * 0.5);
|
||||
int i1 = (int)(p_281839_.guiHeight() * 0.5);
|
||||
double d0 = Math.min(p_281839_.guiWidth() * 0.75, (double)p_281839_.guiHeight()) * 0.25;
|
||||
+ if (extractContentRenderState(graphics, f2)) {
|
||||
int k2 = (int)(graphics.guiWidth() * 0.5);
|
||||
int i1 = (int)(graphics.guiHeight() * 0.5);
|
||||
double d0 = Math.min(graphics.guiWidth() * 0.75, (double)graphics.guiHeight()) * 0.25;
|
||||
@@ -118,6 +_,7 @@
|
||||
if (f < 1.0F) {
|
||||
this.drawProgressBar(p_281839_, i / 2 - k1, i2 - 5, i / 2 + k1, i2 + 5, 1.0F - Mth.clamp(f, 0.0F, 1.0F));
|
||||
this.extractProgressBar(graphics, i / 2 - k1, i2 - 5, i / 2 + k1, i2 + 5, 1.0F - Mth.clamp(f, 0.0F, 1.0F));
|
||||
}
|
||||
+ }
|
||||
|
||||
|
||||
@@ -3,17 +3,17 @@
|
||||
@@ -41,11 +_,16 @@
|
||||
private static final Map<MenuType<?>, MenuScreens.ScreenConstructor<?, ?>> SCREENS = Maps.newHashMap();
|
||||
|
||||
public static <T extends AbstractContainerMenu> void create(MenuType<T> p_96202_, Minecraft p_96203_, int p_96204_, Component p_96205_) {
|
||||
+ getScreenFactory(p_96202_, p_96203_, p_96204_, p_96205_).ifPresent(f -> f.fromPacket(p_96205_, p_96202_, p_96203_, p_96204_));
|
||||
public static <T extends AbstractContainerMenu> void create(final MenuType<T> type, final Minecraft minecraft, final int containerId, final Component title) {
|
||||
+ getScreenFactory(type, minecraft, containerId, title).ifPresent(f -> f.fromPacket(title, type, minecraft, containerId));
|
||||
+ }
|
||||
+
|
||||
+ public static <T extends AbstractContainerMenu> java.util.Optional<ScreenConstructor<T, ?>> getScreenFactory(@Nullable MenuType<T> p_96202_, Minecraft p_96203_, int p_96204_, Component p_96205_) {
|
||||
MenuScreens.ScreenConstructor<T, ?> screenconstructor = getConstructor(p_96202_);
|
||||
+ public static <T extends AbstractContainerMenu> java.util.Optional<ScreenConstructor<T, ?>> getScreenFactory(@Nullable MenuType<T> type, Minecraft minecraft, int containerId, Component title) {
|
||||
MenuScreens.ScreenConstructor<T, ?> screenconstructor = getConstructor(type);
|
||||
if (screenconstructor == null) {
|
||||
LOGGER.warn("Failed to create screen for menu type: {}", BuiltInRegistries.MENU.getKey(p_96202_));
|
||||
LOGGER.warn("Failed to create screen for menu type: {}", BuiltInRegistries.MENU.getKey(type));
|
||||
+ return java.util.Optional.empty();
|
||||
} else {
|
||||
- screenconstructor.fromPacket(p_96205_, p_96202_, p_96203_, p_96204_);
|
||||
- screenconstructor.fromPacket(title, type, minecraft, containerId);
|
||||
+ return java.util.Optional.of(screenconstructor);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
--- a/net/minecraft/client/gui/screens/PauseScreen.java
|
||||
+++ b/net/minecraft/client/gui/screens/PauseScreen.java
|
||||
@@ -102,6 +_,7 @@
|
||||
@@ -104,6 +_,7 @@
|
||||
} else {
|
||||
gridlayout$rowhelper.addChild(this.openScreenButton(PLAYER_REPORTING, () -> new SocialInteractionsScreen(this)));
|
||||
}
|
||||
+ gridlayout$rowhelper.addChild(Button.builder(Component.translatable("fml.menu.mods"), button -> this.minecraft.setScreen(new net.minecraftforge.client.gui.ModListScreen(this))).width(BUTTON_WIDTH_FULL).build(), 2);
|
||||
|
||||
this.disconnectButton = gridlayout$rowhelper.addChild(Button.builder(CommonComponents.disconnectButtonLabel(this.minecraft.isLocalServer()), p_280815_ -> {
|
||||
p_280815_.active = false;
|
||||
this.disconnectButton = gridlayout$rowhelper.addChild(
|
||||
Button.builder(
|
||||
@@ -8,10 +8,10 @@
|
||||
+ this.minecraft.popGuiLayer();
|
||||
}
|
||||
|
||||
protected <T extends GuiEventListener & Renderable & NarratableEntry> T addRenderableWidget(T p_169406_) {
|
||||
protected <T extends GuiEventListener & Renderable & NarratableEntry> T addRenderableWidget(final T widget) {
|
||||
@@ -326,8 +_,10 @@
|
||||
this.width = p_96608_;
|
||||
this.height = p_96609_;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
if (!this.initialized) {
|
||||
+ if (!net.minecraftforge.client.event.ScreenEvent.Init.Pre.BUS.post(new net.minecraftforge.client.event.ScreenEvent.Init.Pre(this, this.children, this::addEventWidget, this::removeWidget)))
|
||||
this.init();
|
||||
@@ -30,20 +30,20 @@
|
||||
+ net.minecraftforge.client.event.ScreenEvent.Init.Post.BUS.post(new net.minecraftforge.client.event.ScreenEvent.Init.Post(this, this.children, this::addEventWidget, this::removeWidget));
|
||||
}
|
||||
|
||||
protected void fadeWidgets(float p_409453_) {
|
||||
protected void fadeWidgets(final float widgetFade) {
|
||||
@@ -385,6 +_,8 @@
|
||||
this.renderMenuBackground(p_283688_);
|
||||
this.extractMenuBackground(graphics);
|
||||
}
|
||||
|
||||
+ net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderScreenBackground(this, p_283688_);
|
||||
+ net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderScreenBackground(this, graphics);
|
||||
+
|
||||
this.minecraft.gui.renderDeferredSubtitles();
|
||||
this.minecraft.gui.extractDeferredSubtitles();
|
||||
}
|
||||
|
||||
@@ -467,6 +_,19 @@
|
||||
@@ -474,6 +_,19 @@
|
||||
}
|
||||
|
||||
public void onFilesDrop(List<Path> p_96591_) {
|
||||
public void onFilesDrop(final List<Path> files) {
|
||||
+ }
|
||||
+
|
||||
+ @Nullable
|
||||
@@ -59,4 +59,4 @@
|
||||
+ this.children.add(guiEventListener);
|
||||
}
|
||||
|
||||
private void scheduleNarration(long p_169381_, boolean p_169382_) {
|
||||
private void scheduleNarration(final long delay, final boolean ignoreSuppression) {
|
||||
Loaded 100 of 1558 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user