Archived
为本反编译仓库新增 scripts/remap.ps1,按构建 conf 表将源码中残留的 func_/field_ SRG 名重映射为 MCP 名,匹配全量编译环境对每个反编译仓库 可重复构建的要求。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
98 lines
3.2 KiB
PowerShell
98 lines
3.2 KiB
PowerShell
$root = "C:/Users/layue/Desktop/TDLM/NegoreRouse-1.7.10-r3-decompiled/src/main/java"
|
|
$files = Get-ChildItem -Path $root -Recurse -Filter *.java
|
|
|
|
# Map of SRG names -> MCP name. key is matched followed by '(' (methods)
|
|
# To avoid overmatching method names that are prefixes of other method names,
|
|
# we replace with the trailing paren included.
|
|
$methodMap = [ordered]@{
|
|
# ItemStack
|
|
'func_77973_b' = 'getItem'
|
|
'func_77942_o' = 'hasTagCompound'
|
|
'func_77977_a' = 'getUnlocalizedName'
|
|
'func_77978_p' = 'getTagCompound'
|
|
'func_77964_b' = 'setItemDamage'
|
|
'func_77960_j' = 'getItemDamage'
|
|
'func_77982_d' = 'setTagCompound'
|
|
'func_77966_a' = 'addEnchantment'
|
|
# InventoryCrafting
|
|
'func_70302_i_' = 'getSizeInventory'
|
|
'func_70301_a' = 'getStackInSlot'
|
|
'func_70463_b' = 'getStackInRowAndColumn'
|
|
# NBTTagCompound
|
|
'func_74737_b' = 'copy'
|
|
'func_74764_b' = 'hasKey'
|
|
'func_74776_a' = 'setInteger'
|
|
'func_74760_g' = 'getInteger'
|
|
'func_74763_f' = 'getLong'
|
|
'func_74772_a' = 'setLong'
|
|
'func_74780_a' = 'setDouble'
|
|
'func_74769_h' = 'getDouble'
|
|
# World
|
|
'func_82737_E' = 'getTotalWorldTime'
|
|
'func_72838_d' = 'spawnEntityInWorld'
|
|
'func_72820_D' = 'getWorldTime'
|
|
# Block
|
|
'func_149712_f' = 'getBlockHardness'
|
|
# StatCollector
|
|
'func_74838_a' = 'translateToLocal'
|
|
# Item
|
|
'func_77655_b' = 'setUnlocalizedName'
|
|
'func_111206_d' = 'setTextureName'
|
|
'func_77624_a' = 'addInformation'
|
|
'func_77663_a' = 'onUpdate'
|
|
'func_150894_a' = 'onBlockDestroyed'
|
|
'func_77644_a' = 'hitEntity'
|
|
# CreativeTabs
|
|
'func_78016_d' = 'getTabIconItem'
|
|
# EnchantmentHelper
|
|
'func_82781_a' = 'getEnchantments'
|
|
'func_77506_a' = 'getEnchantmentLevel'
|
|
'func_82782_a' = 'setEnchantments'
|
|
# DamageSource
|
|
'func_76355_l' = 'getDamageType'
|
|
# Entity
|
|
'func_145779_a' = 'dropItem'
|
|
'func_70694_bm' = 'getHeldItem'
|
|
# CombatTracker
|
|
'func_94547_a' = 'recordAttack'
|
|
}
|
|
|
|
$fieldMap = [ordered]@{
|
|
# World
|
|
'field_72995_K' = 'isRemote'
|
|
'field_73012_v' = 'rand'
|
|
'field_70170_p' = 'worldObj'
|
|
# EntityPlayerMP / NetHandlerPlayServer
|
|
'field_147369_b' = 'playerEntity'
|
|
# Enchantment
|
|
'field_77331_b' = 'enchantmentsList'
|
|
'field_77347_r' = 'fireAspect'
|
|
'field_77345_t' = 'knockback'
|
|
'field_151370_z' = 'silkTouch'
|
|
'field_77336_l' = 'looting'
|
|
'field_77334_n' = 'fortune'
|
|
# CreativeTabs
|
|
'field_78032_a' = 'creativeTabArray'
|
|
}
|
|
|
|
foreach ($f in $files) {
|
|
$content = Get-Content -Raw -LiteralPath $f.FullName
|
|
$orig = $content
|
|
# Methods: replace `func_xxx` followed by `(` (no chars between)
|
|
foreach ($k in $methodMap.Keys) {
|
|
# Use regex: \b + key + \( -> replacement + (
|
|
$pattern = [regex]::Escape($k) + '\('
|
|
$content = [regex]::Replace($content, $pattern, $methodMap[$k] + '(')
|
|
}
|
|
# Fields: replace whole token, boundary-safe
|
|
foreach ($k in $fieldMap.Keys) {
|
|
$pattern = '\b' + [regex]::Escape($k) + '\b'
|
|
$content = [regex]::Replace($content, $pattern, $fieldMap[$k])
|
|
}
|
|
if ($content -ne $orig) {
|
|
Set-Content -LiteralPath $f.FullName -Value $content -NoNewline -Encoding UTF8
|
|
Write-Output ("Updated: " + $f.FullName)
|
|
}
|
|
}
|
|
Write-Output "Done"
|