Skip to content

Commit

Permalink
Update to forge 49.0.20 (a4c26c9)
Browse files Browse the repository at this point in the history
  • Loading branch information
JustRed23 committed Feb 5, 2024
1 parent 0d77edd commit ab43802
Show file tree
Hide file tree
Showing 33 changed files with 289 additions and 241 deletions.
34 changes: 17 additions & 17 deletions CREDITS.txt
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
Minecraft Forge: Credits/Thank You

Forge is a set of tools and modifications to the Minecraft base game code to assist
mod developers in creating new and exciting content. It has been in development for
several years now, but I would like to take this time thank a few people who have
helped it along it's way.
Forge is a set of tools and modifications to the Minecraft base game code to assist
mod developers in creating new and exciting content. It has been in development for
several years now, but I would like to take this time thank a few people who have
helped it along its way.

First, the people who originally created the Forge projects way back in Minecraft
alpha. Eloraam of RedPower, and SpaceToad of Buildcraft, without their acceptiance
First, the people who originally created the Forge projects way back in Minecraft
alpha. Eloraam of RedPower, and SpaceToad of Buildcraft, without their acceptiance
of me taking over the project, who knows what Minecraft modding would be today.

Secondly, someone who has worked with me, and developed some of the core features
that allow modding to be as functional, and as simple as it is, cpw. For developing
FML, which stabelized the client and server modding ecosystem. As well as the base
FML, which stabilized the client and server modding ecosystem. As well as the base
loading system that allows us to modify Minecraft's code as elegently as possible.

Mezz, who has stepped up as the issue and pull request manager. Helping to keep me
sane as well as guiding the community into creating better additions to Forge.

Searge, Bspks, Fesh0r, ProfMobious, and all the rest over on the MCP team {of which
I am a part}. For creating some of the core tools needed to make Minecraft modding
Searge, Bspks, Fesh0r, ProfMobious, and all the rest over on the MCP team {of which
I am a part}. For creating some of the core tools needed to make Minecraft modding
both possible, and as stable as can be.
On that note, here is some specific information of the MCP data we use:
* Minecraft Coder Pack (MCP) *
Forge Mod Loader and Minecraft Forge have permission to distribute and automatically
download components of MCP and distribute MCP data files. This permission is not
Forge Mod Loader and Minecraft Forge have permission to distribute and automatically
download components of MCP and distribute MCP data files. This permission is not
transitive and others wishing to redistribute the Minecraft Forge source independently
should seek permission of MCP or remove the MCP data files and request their users
should seek permission of MCP or remove the MCP data files and request their users
to download MCP separately.
And lastly, the countless community members who have spent time submitting bug reports,

And lastly, the countless community members who have spent time submitting bug reports,
pull requests, and just helping out the community in general. Thank you.

--LexManos
Expand All @@ -45,13 +45,13 @@ and minecraft clients.
The code is authored by cpw.

It began by partially implementing an API defined by the client side ModLoader, authored by Risugami.
http://www.minecraftforum.net/topic/75440-
https://www.minecraftforum.net/topic/75440-
This support has been dropped as of Minecraft release 1.7, as Risugami no longer maintains ModLoader.

It also contains suggestions and hints and generous helpings of code from LexManos, author of MinecraftForge.
http://www.minecraftforge.net/
https://minecraftforge.net/

Additionally, it contains an implementation of topological sort based on that
Additionally, it contains an implementation of topological sort based on that
published at http://keithschwarz.com/interesting/code/?dir=topological-sort

It also contains code from the Maven project for performing versioned dependency
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ project(':mcp') {

if (System.env.TEAMCITY_VERSION) {
//Only setup the CI environment if and only if the environment variables are set.
tasks.configureTeamCity {
tasks.named('configureTeamCity').configure {
doLast {
println "##teamcity[buildNumber '${project(':forge').version}']"
println "##teamcity[setParameter name='env.PUBLISHED_JAVA_ARTIFACT_VERSION' value='${project(':forge').version}']"
Expand Down
8 changes: 4 additions & 4 deletions buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ repositories {
}

dependencies {
implementation 'org.ow2.asm:asm:9.5'
implementation 'org.ow2.asm:asm-tree:9.5'
implementation 'org.ow2.asm:asm:9.6'
implementation 'org.ow2.asm:asm-tree:9.6'
implementation 'net.minecraftforge:srgutils:0.5.+'
implementation 'commons-io:commons-io:2.12.0'
implementation 'commons-io:commons-io:2.13.0'
implementation 'com.google.code.gson:gson:2.10.1'
implementation 'org.eclipse.jgit:org.eclipse.jgit:6.5.0.202303070854-r'
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package net.minecraftforge.forge.tasks

import org.gradle.api.artifacts.ResolvedArtifact
import org.gradle.api.tasks.*
import org.gradle.api.DefaultTask
import org.gradle.api.file.ConfigurableFileCollection
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.tasks.bundling.AbstractArchiveTask

import java.util.zip.ZipFile

abstract class BundleList extends DefaultTask {
@InputFiles abstract ConfigurableFileCollection getConfig()
Expand All @@ -24,28 +26,24 @@ abstract class BundleList extends DefaultTask {
void run() {
def entries = [:] as TreeMap
def resolved = project.configurations.installer.resolvedConfiguration.resolvedArtifacts
for (ResolvedArtifact dep : resolved) {
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
entries.put("$info.art.group:$info.art.name:$info.art.classifier", "$file.sha256\t$info.name\t$info.path")

var classifier = 'server'
var genned = project.tasks.applyServerBinPatches
info = Util.getMavenInfoFromTask(genned, classifier)
file = genned.output.get().asFile
entries.put("$info.art.group:$info.art.name:$info.art.classifier", "$file.sha256\t$info.name\t$info.path")

[
project.tasks.universalJar
].forEach{ packed ->
def info = Util.getMavenInfoFromTask(packed)
def file = packed.archiveFile.get().asFile
entries.put("$info.art.group:$info.art.name:$info.art.classifier", "$file.sha256\t$info.name\t$info.path")
}
[
'server': project.tasks.applyServerBinPatches
].forEach { classifier, genned ->
def info = Util.getMavenInfoFromTask(genned, classifier)
def file = genned.output.get().asFile
entries.put("$info.art.group:$info.art.name:$info.art.classifier", "$file.sha256\t$info.name\t$info.path")
}

try (def zip = new java.util.zip.ZipFile(serverBundle.get().asFile)) {
try (def zip = new ZipFile(serverBundle.get().asFile)) {
def entry = zip.getEntry('META-INF/libraries.list')
def data = zip.getInputStream(entry).text.split('\n')
for (def line : data) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.minecraftforge.forge.tasks

import groovy.json.JsonBuilder
import groovy.transform.CompileStatic
import org.gradle.api.DefaultTask
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.tasks.InputFile
Expand All @@ -10,6 +11,7 @@ import org.objectweb.asm.tree.ClassNode
import org.objectweb.asm.tree.FieldNode
import org.objectweb.asm.tree.MethodNode

@CompileStatic
abstract class BytecodeFinder extends DefaultTask {
@InputFile abstract RegularFileProperty getJar()
// It should be fine to mark the output as internal as we want to control when we run it anyways.
Expand All @@ -24,22 +26,22 @@ abstract class BytecodeFinder extends DefaultTask {
protected void exec() {
Util.init()

def outputFile = output.get().asFile
var outputFile = output.get().asFile
if (outputFile.exists())
outputFile.delete()

pre()

Util.processClassNodes(jar.get().asFile, this::process)
Util.processClassNodes(jar.get().asFile, this.&process)

post()
outputFile.text = new JsonBuilder(getData()).toPrettyString()
}


protected process(ClassNode node) {
if (node.fields != null) node.fields.each { process(node, it) }
if (node.methods != null) node.methods.each { process(node, it) }
if (node.fields !== null) node.fields.each { process(node, it) }
if (node.methods !== null) node.methods.each { process(node, it) }
}

protected pre() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ abstract class BytecodePredicateFinder extends BytecodeFinder {
@Internal
abstract Property<Closure<Boolean>> getPredicate()

private final Set<String> matches = new HashSet()
private final Set<String> matches = new HashSet<>()

@Override
protected process(ClassNode parent, MethodNode node) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package net.minecraftforge.forge.tasks;

import groovy.transform.CompileDynamic;
import groovy.transform.CompileStatic;

import java.util.Properties;
import java.util.Enumeration;
import java.util.Map;
Expand All @@ -26,6 +29,7 @@ import java.util.Set;
* This does the same thing, as well as sorting alphabetically.
* It also ignores all comments. We can add them latter if someone cares.
*/
@CompileStatic
public class CleanProperties extends Properties {
private static final long serialVersionUID = 1L;
private static final String LINE_SEP = System.getProperty("line.separator");
Expand Down Expand Up @@ -58,6 +62,7 @@ public class CleanProperties extends Properties {
return Collections.enumeration(ret);
}

@CompileDynamic
@Override
public Set<Map.Entry<Object, Object>> entrySet() {
Set<Map.Entry<Object, Object>> ret = new TreeSet<>((l, r) -> ((String)l.getKey()).compareTo((String)r.getKey()));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package net.minecraftforge.forge.tasks

import groovy.transform.stc.FirstParam

import java.util.function.BiConsumer

public class ClosureHelper {
Expand All @@ -22,7 +24,7 @@ public class ClosureHelper {
}
}

static <T> T apply(T obj, Closure cl) {
static <T> T apply(T obj, @DelegatesTo(value = FirstParam, strategy = Closure.DELEGATE_FIRST) Closure cl) {
cl.delegate = obj
cl.resolveStrategy = Closure.DELEGATE_FIRST
cl()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,23 @@ abstract class DownloadLibraries extends DefaultTask {
def run() {
Util.init()
File outputDir = output.get().asFile
def libraries = new ArrayList()
var libraries = new ArrayList<String>()

def json = input.get().asFile.json().libraries.each { lib ->
//TODO: Thread?
def artifacts = [lib.downloads.artifact] + lib.downloads.get('classifiers', [:]).values()
artifacts.each{ art ->
def target = new File(outputDir, art.path)
libraries.add(target.absolutePath)
if (!target.exists() || !art.sha1.equals(target.sha1())) {
if (!target.exists() || art.sha1 != target.sha1()) {
project.logger.lifecycle("Downloading ${art.url}")
if (!target.parentFile.exists()) {
target.parentFile.mkdirs()
}
new URL(art.url).withInputStream { i ->
target.withOutputStream { it << i }
}
if (!art.sha1.equals(target.sha1())) {
if (art.sha1 != target.sha1()) {
throw new IllegalStateException("Failed to download ${art.url} to ${target.canonicalPath} SHA Mismatch")
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
package net.minecraftforge.forge.tasks

import groovy.transform.CompileStatic
import org.gradle.api.DefaultTask
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.provider.Property
import org.gradle.api.tasks.*

import java.util.zip.ZipFile

@CompileStatic
abstract class ExtractFile extends DefaultTask {
@InputFile abstract RegularFileProperty getInput()
@Input abstract Property<String> getTarget()
@OutputFile abstract RegularFileProperty getOutput()

@TaskAction
protected void exec() {
def zip = new java.util.zip.ZipFile(input.get().asFile);
def entry = zip.getEntry(target.get())
var zip = new ZipFile(input.get().asFile);
var entry = zip.getEntry(target.get())
if (entry == null)
throw new IllegalStateException(input.get().asFile.absolutePath + " does not contain " + target.get())
def stream = zip.getInputStream(entry)
var stream = zip.getInputStream(entry)
output.get().asFile.withOutputStream { out ->
stream.transferTo(out)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
package net.minecraftforge.forge.tasks

import groovy.transform.CompileStatic
import groovy.transform.EqualsAndHashCode

import java.util.ArrayList
import java.util.HashMap
import java.util.TreeMap
import java.util.TreeSet
import java.util.function.BiConsumer

import org.gradle.api.DefaultTask
import org.gradle.api.tasks.*

import org.objectweb.asm.Opcodes
import org.objectweb.asm.Type
import org.objectweb.asm.tree.AbstractInsnNode
import org.objectweb.asm.tree.ClassNode
import org.objectweb.asm.tree.FieldNode
import org.objectweb.asm.tree.MethodNode

import static org.objectweb.asm.Opcodes.*
Expand All @@ -34,17 +25,17 @@ abstract class FieldCompareFinder extends BytecodeFinder {

@Override
protected process(ClassNode parent, MethodNode node) {
def last = null
AbstractInsnNode last = null
def parentInstance = new ObjectTarget(owner: parent.name, name: '', desc: '')
for (int x = 0; x < node.instructions.size(); x++) {
def current = node.instructions.get(x)
if (current.opcode == IF_ACMPEQ || current.opcode == IF_ACMPNE) {
if (last != null && (last.opcode == GETSTATIC || last.opcode == GETFIELD)) {
if (current.opcode === IF_ACMPEQ || current.opcode === IF_ACMPNE) {
if (last !== null && (last.opcode === GETSTATIC || last.opcode === GETFIELD)) {
def target = new Search(cls: last.owner, name: last.name)
def wanted = fieldsReverse.get(target)
def original = fields.get(wanted)
def instance = new ObjectTarget(owner: parent.name, name: node.name, desc: node.desc)
if (wanted != null && (original.blacklist == null || (!original.blacklist.contains(instance) && !original.blacklist.contains(parentInstance)))) {
if (wanted !== null && (original.blacklist === null || (!original.blacklist.contains(instance) && !original.blacklist.contains(parentInstance)))) {
targets.computeIfAbsent(wanted, { k -> new TreeSet() }).add(instance)
}
}
Expand All @@ -68,9 +59,10 @@ abstract class FieldCompareFinder extends BytecodeFinder {
}
return ret
}


@CompileStatic
@EqualsAndHashCode(excludes = ['replacement', 'blacklist'])
public static class Search {
static class Search {
@Input
String cls

Expand All @@ -89,17 +81,17 @@ abstract class FieldCompareFinder extends BytecodeFinder {
return cls + '.' + name
}

def blacklist(def owner, def name, def desc) {
if (blacklist == null)
blacklist = new HashSet()
def blacklist(String owner, String name, String desc) {
if (blacklist === null)
blacklist = new HashSet<>()
blacklist.add(new ObjectTarget(owner: owner, name: name, desc: desc))
}
def blacklist(def owner) {
def blacklist(String owner) {
blacklist(owner, '', '')
}
}

def fields(Closure cl) {
void fields(Closure cl) {
new ClosureHelper(cl, {name, ccl ->
def search = ClosureHelper.apply(new Search(), ccl)
this.fields.put(name, search)
Expand Down
Loading

0 comments on commit ab43802

Please sign in to comment.