From 5cf73fb724cb94965ed92b1a4b80a902e4dd585e Mon Sep 17 00:00:00 2001 From: joe Date: Mon, 20 Jan 2025 21:10:28 +0000 Subject: [PATCH 1/2] Add unpick mappings to parchment --- build.gradle | 73 +++++++++++++++++-- .../minecraft/world/level/LevelWriter.mapping | 17 +++-- gradle.properties | 4 +- settings.gradle | 4 + .../parchmentmc/constants/package-info.java | 5 ++ unpick-definitions/set_block_flags.unpick | 57 +++++++++++++++ unpick-definitions/unpick.json | 5 ++ 7 files changed, 149 insertions(+), 16 deletions(-) create mode 100644 src/constants/java/org/parchmentmc/constants/package-info.java create mode 100644 unpick-definitions/set_block_flags.unpick create mode 100644 unpick-definitions/unpick.json diff --git a/build.gradle b/build.gradle index 44a6dc7b5..cf5311819 100644 --- a/build.gradle +++ b/build.gradle @@ -2,6 +2,7 @@ import com.google.common.io.ByteStreams import org.parchmentmc.compass.CompassPlugin import org.parchmentmc.compass.tasks.GenerateExport import org.parchmentmc.compass.tasks.GenerateSanitizedExport +import org.parchmentmc.compass.tasks.GenerateUnpickData import org.parchmentmc.compass.tasks.VersionDownload import java.time.OffsetDateTime @@ -9,9 +10,9 @@ import java.time.ZoneOffset import java.time.format.DateTimeFormatter plugins { - id 'java-base' + id 'java' id 'maven-publish' - id 'org.parchmentmc.compass' version '0.10.0' + id 'org.parchmentmc.compass' version '0.11.0' id 'org.parchmentmc.writtenbooks' version '0.5.+' } @@ -62,6 +63,11 @@ repositories { configurations { enigma remapper + unpick +} + +sourceSets { + constants } dependencies { @@ -71,6 +77,8 @@ dependencies { // ForgeAutoRenamingTool, for remapping the client JAR remapper 'net.minecraftforge:ForgeAutoRenamingTool:1.0.2' + unpick "net.fabricmc.unpick:unpick-cli:${project.unpick_version}" + // Enigma, gorgeous interface for editing mappings enigma 'org.quiltmc:enigma-swing:2.5.2' @@ -109,6 +117,44 @@ tasks.register('enigma', EnigmaExec) { mappings = project.compass.productionData } +final constantsJar = tasks.register('constantsJar', Jar) { + dependsOn constantsClasses + from constantsClasses + archiveBaseName = 'parchment-constants' + destinationDirectory = temporaryDir +} + +final generateUnpickData = tasks.register('generateUnpickData', GenerateUnpickData) { + group = 'unpick' + inputDirectory = file('unpick-definitions') + output = new File(temporaryDir, 'unpick_combined.unpick') +} + +def unpickedJar = project.layout.buildDirectory.dir('unpicked') + .zip(project.compass.version) { d, ver -> d.file("$ver-unpicked.jar") } +tasks.register('unpickJar', JavaExec) { + group = 'unpick' + dependsOn remapJar, generateUnpickData, constantsJar + classpath = configurations.unpick + mainClass = 'daomephsta.unpick.cli.Main' + args( + remapJar.flatMap { it.outputJar }.get().asFile.absolutePath, + unpickedJar.get().asFile.absolutePath, + generateUnpickData.flatMap { it.output }.get().asFile.absolutePath, + constantsJar.flatMap { it.archiveFile }.get().asFile.absolutePath + ) + + doFirst { + mkdir(unpickedJar.get().asFile.parent) + } +} + +tasks.register('enigmaUnpicked', EnigmaExec) { + dependsOn unpickJar + inputJar = unpickedJar + mappings = project.compass.productionData +} + tasks.withType(GenerateExport).configureEach { // Disable blackstone if UPDATING is set. // This will ensure cascaded method data does not get mixed into the production data when updating. @@ -125,26 +171,38 @@ tasks.register('generateSanitizedExport', GenerateSanitizedExport) { tasks.register('officialExportZip', Zip) { group = 'build' description = "Creates a ZIP archive containing the export produced by the 'official' intermediate provider and production data." - from(tasks.named('generateOfficialExport', GenerateExport).flatMap { it.output }) + from(tasks.named('generateOfficialExport', GenerateExport).flatMap { it.output }) { + rename { 'parchment.json' } + } archiveBaseName = 'officialExport' } tasks.register('officialSanitizedExportZip', Zip) { group = 'build' description = "Creates a ZIP archive containing the sanitized export produced by the 'official' intermediate provider and production data." - from(tasks.named('generateSanitizedExport', GenerateExport).flatMap { it.output }) + from(tasks.named('generateSanitizedExport', GenerateExport).flatMap { it.output }) { + rename { 'parchment.json' } + } archiveBaseName = 'officialSanitizedExport' } tasks.register('officialStagingExportZip', Zip) { group = 'build' description = "Creates a ZIP archive containing the export produced by the 'official' intermediate provider and staging data." - from(tasks.named('generateOfficialStagingExport', GenerateExport).flatMap { it.output }) + from(tasks.named('generateOfficialStagingExport', GenerateExport).flatMap { it.output }) { + rename { 'parchment.json' } + } archiveBaseName = 'officialStagingExport' } tasks.withType(Zip).matching { it.name.startsWith 'official' }.configureEach { - rename { 'parchment.json' } + from(generateUnpickData.flatMap { it.output }) { + rename generateUnpickData.flatMap { it.output }.get().asFile.name, 'extras/definitions.unpick' + } + from(file('unpick-definitions/unpick.json')) { + expand version: project.unpick_version + rename 'unpick.json', 'extras/unpick.json' + } reproducibleFileOrder = true preserveFileTimestamps = false destinationDirectory = project.layout.buildDirectory.dir('exportZips') @@ -225,7 +283,8 @@ abstract class RemapJar extends JavaExec { ['--input', inputJar.get().asFile.absolutePath, '--map', mappings.get().asFile.absolutePath, '--output', outputJar.get().asFile.absolutePath, - '--log', logFile.get().asFile.absolutePath] + '--log', logFile.get().asFile.absolutePath, + '--strip-sigs'] } as CommandLineArgumentProvider) } } diff --git a/data/net/minecraft/world/level/LevelWriter.mapping b/data/net/minecraft/world/level/LevelWriter.mapping index a28cd8831..415ef1b3e 100644 --- a/data/net/minecraft/world/level/LevelWriter.mapping +++ b/data/net/minecraft/world/level/LevelWriter.mapping @@ -18,14 +18,15 @@ CLASS net/minecraft/world/level/LevelWriter ARG 1 pos ARG 2 isMoving METHOD setBlock (Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;I)Z - COMMENT Sets a block state into this world.Flags are as follows: - COMMENT 1 will cause a block update. - COMMENT 2 will send the change to clients. - COMMENT 4 will prevent the block from being re-rendered. - COMMENT 8 will force any re-renders to run on the main thread instead - COMMENT 16 will prevent neighbor reactions (e.g. fences connecting, observers pulsing). - COMMENT 32 will prevent neighbor reactions from spawning drops. - COMMENT 64 will signify the block is being moved. + COMMENT Sets a block state into this world. Flags are as follows: + COMMENT {@link net.minecraft.world.level.block.Block#UPDATE_NEIGHBORS Block.UPDATE_NEIGHBORS} will cause a block update. + COMMENT {@link net.minecraft.world.level.block.Block#UPDATE_CLIENTS Block.UPDATE_CLIENTS} will send the change to clients. + COMMENT {@link net.minecraft.world.level.block.Block#UPDATE_INVISIBLE Block.UPDATE_INVISIBLE} will prevent the block from being re-rendered. + COMMENT {@link net.minecraft.world.level.block.Block#UPDATE_IMMEDIATE Block.UPDATE_IMMEDIATE} will force any re-renders to run on the main thread instead. + COMMENT {@link net.minecraft.world.level.block.Block#UPDATE_KNOWN_SHAPE Block.UPDATE_KNOWN_SHAPE} will prevent neighbor reactions (e.g. fences connecting, observers pulsing). + COMMENT {@link net.minecraft.world.level.block.Block#UPDATE_SUPPRESS_DROPS Block.UPDATE_SUPPRESS_DROPS} will prevent neighbor reactions from spawning drops. + COMMENT {@link net.minecraft.world.level.block.Block#UPDATE_MOVE_BY_PISTON Block.UPDATE_MOVE_BY_PISTON} will signify the block is being moved. + COMMENT {@link net.minecraft.world.level.block.Block#UPDATE_SKIP_SHAPE_UPDATE_ON_WIRE Block.UPDATE_SKIP_SHAPE_UPDATE_ON_WIRE} will skip shape updates for redstone wire. COMMENT Flags can be OR-ed ARG 1 pos ARG 2 newState diff --git a/gradle.properties b/gradle.properties index e98b2a13f..67986e801 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,5 @@ # Blackstone requires a good chunk of memory to parse and hold. # This ensures gradle doesn't run out of memory and should speed up exports as it doesn't have to GC as often. -org.gradle.jvmargs=-Xmx1G \ No newline at end of file +org.gradle.jvmargs=-Xmx1G + +unpick_version = 2.3.1 diff --git a/settings.gradle b/settings.gradle index 706514e7e..9cc9b11a8 100644 --- a/settings.gradle +++ b/settings.gradle @@ -8,6 +8,10 @@ pluginManagement { name 'MinecraftForge' url 'https://maven.minecraftforge.net/' } + maven { + name 'FabricMC' + url 'https://maven.fabricmc.net/' + } gradlePluginPortal() } } diff --git a/src/constants/java/org/parchmentmc/constants/package-info.java b/src/constants/java/org/parchmentmc/constants/package-info.java new file mode 100644 index 000000000..c92abe805 --- /dev/null +++ b/src/constants/java/org/parchmentmc/constants/package-info.java @@ -0,0 +1,5 @@ +/** + * A constants jar is required for unpick CLI to work. In practice it will be empty for all modern Minecraft versions + * since they no longer strip constants, unless we ever want to define our own constants that Mojang doesn't define. + */ +package org.parchmentmc.constants; diff --git a/unpick-definitions/set_block_flags.unpick b/unpick-definitions/set_block_flags.unpick new file mode 100644 index 000000000..a1ee8c672 --- /dev/null +++ b/unpick-definitions/set_block_flags.unpick @@ -0,0 +1,57 @@ +v2 + +flag set_block_flags net/minecraft/world/level/block/Block UPDATE_ALL +flag set_block_flags net/minecraft/world/level/block/Block UPDATE_ALL_IMMEDIATE +flag set_block_flags net/minecraft/world/level/block/Block UPDATE_NEIGHBORS +flag set_block_flags net/minecraft/world/level/block/Block UPDATE_CLIENTS +flag set_block_flags net/minecraft/world/level/block/Block UPDATE_NONE +flag set_block_flags net/minecraft/world/level/block/Block UPDATE_IMMEDIATE +flag set_block_flags net/minecraft/world/level/block/Block UPDATE_KNOWN_SHAPE +flag set_block_flags net/minecraft/world/level/block/Block UPDATE_SUPPRESS_DROPS +flag set_block_flags net/minecraft/world/level/block/Block UPDATE_MOVE_BY_PISTON +flag set_block_flags net/minecraft/world/level/block/Block UPDATE_SKIP_SHAPE_UPDATE_ON_WIRE + +target_method net/minecraft/world/level/LevelWriter setBlock (Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;I)Z + param 2 set_block_flags +target_method net/minecraft/world/level/LevelWriter setBlock (Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;II)Z + param 2 set_block_flags +target_method net/minecraft/world/level/Level sendBlockUpdated (Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/block/state/BlockState;I)V + param 3 set_block_flags +target_method net/minecraft/world/level/block/state/BlockBehaviour$BlockStateBase updateNeighbourShapes (Lnet/minecraft/world/level/LevelAccessor;Lnet/minecraft/core/BlockPos;I)V + param 2 set_block_flags +target_method net/minecraft/world/level/block/state/BlockBehaviour$BlockStateBase updateNeighbourShapes (Lnet/minecraft/world/level/LevelAccessor;Lnet/minecraft/core/BlockPos;II)V + param 2 set_block_flags +target_method net/minecraft/world/level/block/state/BlockBehaviour$BlockStateBase updateIndirectNeighbourShapes (Lnet/minecraft/world/level/LevelAccessor;Lnet/minecraft/core/BlockPos;I)V + param 2 set_block_flags +target_method net/minecraft/world/level/block/state/BlockBehaviour$BlockStateBase updateIndirectNeighbourShapes (Lnet/minecraft/world/level/LevelAccessor;Lnet/minecraft/core/BlockPos;II)V + param 2 set_block_flags +target_method net/minecraft/world/level/block/Block updateOrDestroy (Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/LevelAccessor;Lnet/minecraft/core/BlockPos;I)V + param 4 set_block_flags +target_method net/minecraft/world/level/block/Block updateOrDestroy (Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/LevelAccessor;Lnet/minecraft/core/BlockPos;II)V + param 4 set_block_flags +target_method net/minecraft/world/level/block/state/BlockBehaviour updateIndirectNeighbourShapes (Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/LevelAccessor;Lnet/minecraft/core/BlockPos;II)V + param 3 set_block_flags +target_method net/minecraft/world/level/block/DoublePlantBlock placeAt (Lnet/minecraft/world/level/LevelAccessor;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/core/BlockPos;I)V + param 3 set_block_flags +target_method net/minecraft/world/level/block/MossyCarpetBlock placeAt (Lnet/minecraft/world/level/LevelAccessor;Lnet/minecraft/core/BlockPos;Lnet/minecraft/util/RandomSource;I)V + param 3 set_block_flags +target_method net/minecraft/client/multiplayer/ClientPacketListener lambda$handleChunkBlocksUpdate$1 (Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;)V + param 0 set_block_flags +target_method net/minecraft/commands/arguments/blocks/BlockInput place (Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/core/BlockPos;I)Z + param 2 set_block_flags +target_method net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate placeInWorld (Lnet/minecraft/world/level/ServerLevelAccessor;Lnet/minecraft/core/BlockPos;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/levelgen/structure/templatesystem/StructurePlaceSettings;Lnet/minecraft/util/RandomSource;I)Z + param 5 set_block_flags +target_method net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate updateShapeAtEdge (Lnet/minecraft/world/level/LevelAccessor;ILnet/minecraft/world/phys/shapes/DiscreteVoxelShape;Lnet/minecraft/core/BlockPos;)V + param 1 set_block_flags +target_method net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate updateShapeAtEdge (Lnet/minecraft/world/level/LevelAccessor;ILnet/minecraft/world/phys/shapes/DiscreteVoxelShape;III)V + param 1 set_block_flags +target_method net/minecraft/world/level/redstone/NeighborUpdater shapeUpdate (Lnet/minecraft/core/Direction;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/core/BlockPos;Lnet/minecraft/core/BlockPos;II)V + param 4 set_block_flags +target_method net/minecraft/world/level/redstone/NeighborUpdater executeShapeUpdate (Lnet/minecraft/world/level/LevelAccessor;Lnet/minecraft/core/Direction;Lnet/minecraft/core/BlockPos;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;II)V + param 5 set_block_flags +target_method net/minecraft/world/level/LevelAccessor neighborShapeChanged (Lnet/minecraft/core/Direction;Lnet/minecraft/core/BlockPos;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;II)V + param 4 set_block_flags +target_method net/minecraft/world/level/redstone/CollectingNeighborUpdater$ShapeUpdate (Lnet/minecraft/core/Direction;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/core/BlockPos;Lnet/minecraft/core/BlockPos;II)V + param 4 set_block_flags +target_method net/minecraft/client/multiplayer/ClientLevel setServerVerifiedBlockState (Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;I)V + param 2 set_block_flags diff --git a/unpick-definitions/unpick.json b/unpick-definitions/unpick.json new file mode 100644 index 000000000..701cac300 --- /dev/null +++ b/unpick-definitions/unpick.json @@ -0,0 +1,5 @@ +{ + "version": 1, + "unpickGroup": "net.fabricmc.unpick", + "unpickVersion": "${version}" +} From 0b8ef065e96dee7b076eef89ab0604de737cfd92 Mon Sep 17 00:00:00 2001 From: joe Date: Mon, 20 Jan 2025 21:18:39 +0000 Subject: [PATCH 2/2] Add shell scripts for unpicked enigma --- enigma_unpicked | 2 ++ enigma_unpicked.bat | 2 ++ 2 files changed, 4 insertions(+) create mode 100755 enigma_unpicked create mode 100644 enigma_unpicked.bat diff --git a/enigma_unpicked b/enigma_unpicked new file mode 100755 index 000000000..99013dc0a --- /dev/null +++ b/enigma_unpicked @@ -0,0 +1,2 @@ +#!/usr/bin/env sh +./gradlew enigmaUnpicked diff --git a/enigma_unpicked.bat b/enigma_unpicked.bat new file mode 100644 index 000000000..28fcbec7a --- /dev/null +++ b/enigma_unpicked.bat @@ -0,0 +1,2 @@ +@echo off +gradlew.bat enigma_unpicked \ No newline at end of file