Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add unpick mappings to parchment #320

Draft
wants to merge 3 commits into
base: versions/1.21.x
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 66 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ 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
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.+'
}

Expand Down Expand Up @@ -62,6 +63,11 @@ repositories {
configurations {
enigma
remapper
unpick
}

sourceSets {
constants
}

dependencies {
Expand All @@ -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'

Expand Down Expand Up @@ -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.
Expand All @@ -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')
Expand Down Expand Up @@ -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)
}
}
Expand Down
17 changes: 9 additions & 8 deletions data/net/minecraft/world/level/LevelWriter.mapping
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions enigma_unpicked
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env sh
./gradlew enigmaUnpicked
2 changes: 2 additions & 0 deletions enigma_unpicked.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@echo off
gradlew.bat enigma_unpicked
4 changes: 3 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -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
org.gradle.jvmargs=-Xmx1G

unpick_version = 2.3.1
4 changes: 4 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ pluginManagement {
name 'MinecraftForge'
url 'https://maven.minecraftforge.net/'
}
maven {
name 'FabricMC'
url 'https://maven.fabricmc.net/'
}
gradlePluginPortal()
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
57 changes: 57 additions & 0 deletions unpick-definitions/set_block_flags.unpick
Original file line number Diff line number Diff line change
@@ -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 <init> (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
5 changes: 5 additions & 0 deletions unpick-definitions/unpick.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"version": 1,
"unpickGroup": "net.fabricmc.unpick",
"unpickVersion": "${version}"
}
Loading