mirror of https://github.com/FabricMC/yarn.git
Constant Unpicking (#1952)
This is the first take of this, its done in such a way where we can awlays iterate improvements into it.
This commit is contained in:
parent
4c9fd21882
commit
b9837ab99b
|
@ -30,10 +30,14 @@ Please have a look at the [naming conventions](/CONVENTIONS.md) before submittin
|
|||
Yarn uses Gradle to provide a number of utility tasks for working with the mappings.
|
||||
|
||||
### `yarn`
|
||||
[`setupYarn`](#setupYarn) and download and launch the latest version of [Enigma](https://github.com/FabricMC/Enigma) automatically configured to use the merged jar and the mappings.
|
||||
Setup and download and launch the latest version of [Enigma](https://github.com/FabricMC/Enigma) automatically configured to use the merged jar and the mappings.
|
||||
|
||||
Compared to launching Enigma externally, the gradle task adds a name guesser plugin that automatically map enums and a few constant field names.
|
||||
|
||||
### `yarnUnpicked`
|
||||
Same as above, but unpicks the constants and launches engima with them. Can be a little bit slower to get going.
|
||||
|
||||
|
||||
### `build`
|
||||
Build a GZip'd archive containing a tiny mapping between official (obfuscated), [intermediary](https://github.com/FabricMC/intermediary), and yarn names ("named") and packages enigma mappings into a zip archive..
|
||||
|
||||
|
@ -48,6 +52,3 @@ Downloads the client and server Minecraft jars for the current Minecraft version
|
|||
|
||||
### `mergeJars`
|
||||
Merges the client and server jars into one merged jar, located at `VERSION-merged.jar` in the mappings directory where `VERSION` is the current Minecraft version.
|
||||
|
||||
### `setupYarn`
|
||||
[`download`](#download) and [`mergeJars`](#mergeJars)
|
||||
|
|
192
build.gradle
192
build.gradle
|
@ -5,6 +5,7 @@ buildscript {
|
|||
url 'https://maven.fabricmc.net'
|
||||
}
|
||||
mavenCentral()
|
||||
mavenLocal()
|
||||
}
|
||||
dependencies {
|
||||
classpath "cuchaz:enigma-cli:${project.enigma_version}"
|
||||
|
@ -12,6 +13,9 @@ buildscript {
|
|||
classpath "commons-io:commons-io:2.6"
|
||||
classpath 'de.undercouch:gradle-download-task:4.0.4'
|
||||
classpath 'net.fabricmc:tiny-remapper:0.3.1.72'
|
||||
classpath 'net.fabricmc:mappingpoet:0.1.0+build.2'
|
||||
classpath 'net.fabricmc.unpick:unpick:2.0.1'
|
||||
classpath 'net.fabricmc.unpick:unpick-format-utils:2.0.1'
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -29,6 +33,7 @@ def ENV = System.getenv()
|
|||
def build_number = ENV.BUILD_NUMBER ?: "local"
|
||||
|
||||
def yarnVersion = "${minecraft_version}+build.$build_number"
|
||||
version = yarnVersion
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
@ -40,6 +45,7 @@ repositories {
|
|||
name "Mojang"
|
||||
url 'https://libraries.minecraft.net/'
|
||||
}
|
||||
mavenLocal()
|
||||
}
|
||||
|
||||
configurations {
|
||||
|
@ -58,8 +64,12 @@ configurations {
|
|||
extendsFrom mappingPoetJar
|
||||
transitive = true
|
||||
}
|
||||
unpick
|
||||
}
|
||||
|
||||
def unpickMetaFile = file("unpick-definitions/unpick.json")
|
||||
def unpickMeta = new groovy.json.JsonSlurper().parseText(unpickMetaFile.text)
|
||||
|
||||
dependencies {
|
||||
enigmaRuntime "cuchaz:enigma-swing:${project.enigma_version}"
|
||||
enigmaRuntime "net.fabricmc:stitch:${project.stitch_version}"
|
||||
|
@ -67,6 +77,7 @@ dependencies {
|
|||
javadocClasspath "org.jetbrains:annotations:${project.jetbrains_annotations_version}"
|
||||
decompileClasspath "org.benf:cfr:0.150"
|
||||
mappingPoetJar 'net.fabricmc:mappingpoet:0.2.6'
|
||||
unpick "${unpickMeta.unpickGroup}:unpick-cli:${unpickMeta.unpickVersion}"
|
||||
}
|
||||
|
||||
def setupGroup = "jar setup"
|
||||
|
@ -78,6 +89,7 @@ def cacheFilesMinecraft = file(".gradle/minecraft")
|
|||
def tempDir = file(".gradle/temp")
|
||||
def mergedFile = file("${minecraft_version}-merged.jar")
|
||||
def intermediaryJar = file("${minecraft_version}-intermediary.jar")
|
||||
def unpickedJar = file("${minecraft_version}-intermediary-unpicked.jar")
|
||||
def namedJar = file("${minecraft_version}-named.jar")
|
||||
def versionFile = new File(cacheFilesMinecraft, "${minecraft_version}.json")
|
||||
def clientJar = new File(cacheFilesMinecraft, "${minecraft_version}-client.jar")
|
||||
|
@ -361,11 +373,28 @@ task mapIntermediaryJar(dependsOn: [downloadMcLibs, downloadIntermediary, mergeJ
|
|||
}
|
||||
}
|
||||
|
||||
task setupYarn(dependsOn: mapIntermediaryJar) {
|
||||
task yarnUnpicked(dependsOn: "unpickIntermediaryJar") {
|
||||
group = yarnGroup
|
||||
doLast {
|
||||
ant.setLifecycleLogLevel "WARN"
|
||||
ant.java(
|
||||
classname: 'cuchaz.enigma.gui.Main',
|
||||
classpath: configurations.enigmaRuntime.asPath,
|
||||
fork: true,
|
||||
spawn: true
|
||||
) {
|
||||
jvmarg(value: "-Xmx2048m")
|
||||
arg(value: '-jar')
|
||||
arg(value: unpickedJar.getAbsolutePath())
|
||||
arg(value: '-mappings')
|
||||
arg(value: mappingsDir.getAbsolutePath())
|
||||
arg(value: '-profile')
|
||||
arg(value: 'enigma_profile.json')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
task yarn(dependsOn: setupYarn) {
|
||||
task yarn(dependsOn: mapIntermediaryJar) {
|
||||
group = yarnGroup
|
||||
doLast {
|
||||
ant.setLifecycleLogLevel "WARN"
|
||||
|
@ -574,7 +603,7 @@ task buildTinyWithEnum(dependsOn: "mergeTiny", type: FileOutput) {
|
|||
}
|
||||
}
|
||||
|
||||
task mapNamedJar(dependsOn: ["mergeV2", mapIntermediaryJar]) {
|
||||
task mapNamedJar(dependsOn: ["mergeV2", "unpickIntermediaryJar"]) {
|
||||
group = mapJarGroup
|
||||
inputs.files downloadMcLibs.outputs.files.files
|
||||
outputs.file(namedJar)
|
||||
|
@ -591,7 +620,7 @@ task mapNamedJar(dependsOn: ["mergeV2", mapIntermediaryJar]) {
|
|||
doLast {
|
||||
logger.lifecycle(":mapping minecraft to named")
|
||||
|
||||
mapJar(namedJar, intermediaryJar, mergeV2.output, libraries, "intermediary", "named") {
|
||||
mapJar(namedJar, unpickedJar, mergeV2.output, libraries, "intermediary", "named") {
|
||||
it.withMappings { out ->
|
||||
jsrToJetbrains.each { e ->
|
||||
out.acceptClass e.key, e.value
|
||||
|
@ -601,6 +630,133 @@ task mapNamedJar(dependsOn: ["mergeV2", mapIntermediaryJar]) {
|
|||
}
|
||||
}
|
||||
|
||||
import daomephsta.unpick.constantmappers.datadriven.parser.v2.UnpickV2Reader
|
||||
import daomephsta.unpick.constantmappers.datadriven.parser.v2.UnpickV2Writer
|
||||
import daomephsta.unpick.constantmappers.datadriven.parser.v2.UnpickV2Remapper
|
||||
import daomephsta.unpick.constantmappers.datadriven.parser.MethodKey
|
||||
import net.fabricmc.mapping.tree.TinyMappingFactory
|
||||
|
||||
// Merge all of the unpick definitions into a single file to be shipped
|
||||
task combineUnpickDefinitions(type : FileOutput) {
|
||||
output = new File(tempDir, "definitions.unpick")
|
||||
outputs.upToDateWhen { false }
|
||||
group "unpick"
|
||||
|
||||
doFirst {
|
||||
output.delete()
|
||||
}
|
||||
|
||||
doLast {
|
||||
def writer = new UnpickV2Writer()
|
||||
|
||||
file("unpick-definitions").eachFile {
|
||||
if (!it.name.endsWith(".unpick")) {
|
||||
return
|
||||
}
|
||||
|
||||
it.withInputStream {
|
||||
new UnpickV2Reader(it).withCloseable {
|
||||
it.accept(writer)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
output.text = writer.output
|
||||
}
|
||||
}
|
||||
|
||||
task remapUnpickDefinitionsIntermediary(type : FileOutputInput, dependsOn: [combineUnpickDefinitions, buildYarnTiny]) {
|
||||
output = new File(tempDir, "intermediary-definitions.unpick")
|
||||
input = combineUnpickDefinitions.output
|
||||
File mappingsInput = buildYarnTiny.v2Output
|
||||
|
||||
outputs.upToDateWhen { false }
|
||||
group "unpick"
|
||||
|
||||
doFirst {
|
||||
output.delete()
|
||||
}
|
||||
|
||||
doLast {
|
||||
def classMappings = [:]
|
||||
def methodMappings = [:]
|
||||
|
||||
mappingsInput.withReader {reader ->
|
||||
def tinyTree = TinyMappingFactory.loadWithDetection(reader)
|
||||
|
||||
tinyTree.classes.each { classDef ->
|
||||
classMappings.put(
|
||||
classDef.getName("named"),
|
||||
classDef.getName("intermediary")
|
||||
)
|
||||
|
||||
classDef.methods.each { methodDef ->
|
||||
methodMappings.put(
|
||||
new MethodKey(
|
||||
classDef.getName("named"),
|
||||
methodDef.getName("named"),
|
||||
methodDef.getDescriptor("named")
|
||||
),
|
||||
methodDef.getName("intermediary")
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
input.withInputStream {
|
||||
new UnpickV2Reader(it).withCloseable {reader ->
|
||||
def writer = new UnpickV2Writer()
|
||||
reader.accept(new UnpickV2Remapper(classMappings, methodMappings, writer))
|
||||
output.text = writer.output
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
task unpickIntermediaryJar(type: JavaExec, dependsOn: [mapIntermediaryJar, "constantsJar", remapUnpickDefinitionsIntermediary]) {
|
||||
outputs.upToDateWhen { false }
|
||||
group "unpick"
|
||||
|
||||
main "daomephsta.unpick.cli.Main"
|
||||
classpath configurations.unpick
|
||||
|
||||
doFirst {
|
||||
args intermediaryJar.absolutePath, unpickedJar.absolutePath, remapUnpickDefinitionsIntermediary.output.absolutePath, constantsJar.archiveFile.get().asFile.absolutePath, intermediaryJar.absolutePath
|
||||
|
||||
configurations.decompileClasspath.files.each {
|
||||
args it.absolutePath
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Setup the build for the unpicked constants
|
||||
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
it.options.encoding = "UTF-8"
|
||||
if (JavaVersion.current().isJava9Compatible()) {
|
||||
it.options.release = 8
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
constants
|
||||
}
|
||||
|
||||
task constantsJar(type: Jar) {
|
||||
from sourceSets.constants.output
|
||||
archiveClassifier = "constants"
|
||||
}
|
||||
|
||||
task sourcesJar(type: Jar, dependsOn: classes) {
|
||||
archiveClassifier = "sources"
|
||||
from sourceSets.constants.allSource
|
||||
}
|
||||
|
||||
build.dependsOn constantsJar
|
||||
|
||||
task insertAutoGeneratedEnumMappings(dependsOn : [buildYarnTiny,mapIntermediaryJar], type : FileOutput){
|
||||
group = buildMappingGroup
|
||||
def noEnumV2 = buildYarnTiny.v2Output
|
||||
|
@ -652,7 +808,7 @@ task mergeV2(dependsOn: ["v2UnmergedYarnJar", "invertIntermediaryv2"], type: Fil
|
|||
}
|
||||
}
|
||||
|
||||
task v2UnmergedYarnJar(dependsOn: insertAutoGeneratedEnumMappings, type: Jar) {
|
||||
task v2UnmergedYarnJar(dependsOn: [insertAutoGeneratedEnumMappings, combineUnpickDefinitions], type: Jar) {
|
||||
def mappings = insertAutoGeneratedEnumMappings.output
|
||||
group = "mapping build"
|
||||
outputs.upToDateWhen { false }
|
||||
|
@ -661,6 +817,12 @@ task v2UnmergedYarnJar(dependsOn: insertAutoGeneratedEnumMappings, type: Jar) {
|
|||
from(file(mappings)) {
|
||||
rename mappings.name, "mappings/mappings.tiny"
|
||||
}
|
||||
from(combineUnpickDefinitions.output) {
|
||||
rename combineUnpickDefinitions.output.name, "extras/definitions.unpick"
|
||||
}
|
||||
from (file(unpickMetaFile)) {
|
||||
rename unpickMetaFile.name, "extras/unpick.json"
|
||||
}
|
||||
destinationDirectory.set(file("build/libs"))
|
||||
}
|
||||
|
||||
|
@ -673,6 +835,12 @@ task v2MergedYarnJar(dependsOn: ["mergeV2"], type: Jar) {
|
|||
from(file(mappings)) {
|
||||
rename mappings.name, "mappings/mappings.tiny"
|
||||
}
|
||||
from(combineUnpickDefinitions.output) {
|
||||
rename combineUnpickDefinitions.output.name, "extras/definitions.unpick"
|
||||
}
|
||||
from (file(unpickMetaFile)) {
|
||||
rename unpickMetaFile.name, "extras/unpick.json"
|
||||
}
|
||||
destinationDirectory.set(file("build/libs"))
|
||||
}
|
||||
|
||||
|
@ -697,7 +865,7 @@ task genFakeSource(type: JavaExec, dependsOn: ["mergeV2", "mapNamedJar"]) {
|
|||
}
|
||||
}
|
||||
|
||||
task decompileCFR(type: JavaExec, dependsOn: "mapNamedJar") {
|
||||
task decompileCFR(type: JavaExec, dependsOn: [mapNamedJar]) {
|
||||
classpath = configurations.decompileClasspath
|
||||
main = "org.benf.cfr.reader.Main"
|
||||
|
||||
|
@ -811,6 +979,10 @@ publishing {
|
|||
artifact(v2MergedYarnJar) {
|
||||
classifier "mergedv2"
|
||||
}
|
||||
artifact(constantsJar) {
|
||||
classifier "constants"
|
||||
}
|
||||
artifact sourcesJar
|
||||
artifact javadocJar
|
||||
}
|
||||
|
||||
|
@ -864,6 +1036,14 @@ class FileOutput extends DefaultTask {
|
|||
File output
|
||||
}
|
||||
|
||||
class FileOutputInput extends DefaultTask {
|
||||
@InputFile
|
||||
File input
|
||||
|
||||
@OutputFile
|
||||
File output
|
||||
}
|
||||
|
||||
class WithV2FileOutput extends DefaultTask {
|
||||
@OutputFile
|
||||
File v1Output
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
package net.fabricmc.yarn.constants;
|
||||
|
||||
public final class SetBlockStateFlags {
|
||||
/**
|
||||
* Propagates a change event to surrounding blocks.
|
||||
*/
|
||||
public static final int PROPAGATE_CHANGE = 1;
|
||||
|
||||
/**
|
||||
* Notifies listeners and clients who need to react when the block changes.
|
||||
*/
|
||||
public static final int NOTIFY_LISTENERS = 2;
|
||||
|
||||
/**
|
||||
* Used in conjunction with {@link NOTIFY_LISTENERS} to suppress the render pass on clients.
|
||||
*/
|
||||
public static final int NO_REDRAW = 4;
|
||||
|
||||
/**
|
||||
* Forces a synchronous redraw on clients.
|
||||
*/
|
||||
public static final int REDRAW_ON_MAIN_THREAD = 8;
|
||||
|
||||
/**
|
||||
* Bypass virtual block state changes and forces the passed state to be stored as-is.
|
||||
*/
|
||||
public static final int FORCE_STATE = 16;
|
||||
|
||||
/**
|
||||
* Prevents the previous block (container) from dropping items when destroyed.
|
||||
*/
|
||||
public static final int SKIP_DROPS = 32;
|
||||
|
||||
/**
|
||||
* Signals that the current block is being moved to a different location, usually because of a piston.
|
||||
*/
|
||||
public static final int MOVED = 64;
|
||||
|
||||
/**
|
||||
* Signals that lighting updates should be skipped.
|
||||
*/
|
||||
public static final int SKIP_LIGHTING_UPDATES = 128;
|
||||
|
||||
private SetBlockStateFlags() {
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
v2
|
||||
|
||||
flag set_block_state_flags net/fabricmc/yarn/constants/SetBlockStateFlags PROPAGATE_CHANGE
|
||||
flag set_block_state_flags net/fabricmc/yarn/constants/SetBlockStateFlags NOTIFY_LISTENERS
|
||||
flag set_block_state_flags net/fabricmc/yarn/constants/SetBlockStateFlags NO_REDRAW
|
||||
flag set_block_state_flags net/fabricmc/yarn/constants/SetBlockStateFlags REDRAW_ON_MAIN_THREAD
|
||||
flag set_block_state_flags net/fabricmc/yarn/constants/SetBlockStateFlags FORCE_STATE
|
||||
flag set_block_state_flags net/fabricmc/yarn/constants/SetBlockStateFlags SKIP_DROPS
|
||||
flag set_block_state_flags net/fabricmc/yarn/constants/SetBlockStateFlags MOVED
|
||||
flag set_block_state_flags net/fabricmc/yarn/constants/SetBlockStateFlags SKIP_LIGHTING_UPDATES
|
||||
|
||||
target_method net/minecraft/world/ModifiableWorld setBlockState (Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z
|
||||
param 2 set_block_state_flags
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"version": 1,
|
||||
"unpickGroup": "net.fabricmc.unpick",
|
||||
"unpickVersion": "2.0.1"
|
||||
}
|
Loading…
Reference in New Issue