 |
你只需要下載vs code然後使用copilot選一個較好的LLM,就可以由他幫你改,以下內容是改的過程筆記,這不是要給你看的,是要你把這份筆記丟給AI看,讓它加速更改。
# Server_Game_2.jar Bytecode 修改筆記
## 目標檔案
- **JAR:** `gameserver/Server_Game_2.jar`
- **Class:** `com/lineage/server/model/gametime/L1GameTime.class`
- **欄位:** `private static final long BASE_TIME_IN_MILLIS_REAL`
- **Offset:** `0x0061`(class 檔案內第 97 byte 開始,共 8 bytes,Big-Endian)
## 修改紀錄
| 日期 | 舊值 | 新值 | 有效期限 |
|------|------|------|---------|
| 2026-02-26 | `1057233600000L` (2003-07-03) | `1547121600000L` (2019-01-10) | 至 2030-05-15 |
### Server_Game.jar
| 日期 | 修改項目 | 舊值 | 新值 | 說明 |
|------|---------|------|------|------|
| 2026-02-27 | BASE_TIME (#7) | `1278680880000L` (2010-07-09) | `1547121600000L` (2019-01-10) | 溢出從 2021-11-11 延至 2030-05-15 |
| 2026-02-27 | 到期日 Date (#56) | `1798646400782L` | `4102444800000L` (2100-01-01) | `Date.after()` 到期檢查延至 2100 年 |
## 溢出原理
`L1GameTime.valueOf()` 計算公式:
```java
long t1 = currentTimeMillis - BASE_TIME_IN_MILLIS_REAL;
int t2 = (int)((t1 * 6) / 1000L); // 結果轉 int,最大 2147483647
```
**溢出時間 = BASE 日期 + (2147483647 × 1000 ÷ 6) ms ≈ BASE + 11.34 年**
> [!IMPORTANT]
> BASE 不能大於當前系統時間,否則 `t1 < 0` 會拋 `IllegalArgumentException`。
## 常用值速查
| BASE 值 | 對應日期 (UTC) | Hex (Big-Endian) | 溢出時間 |
|---------|---------------|-------------------|---------|
| `1057233600000L` | 2003-07-03 12:00 | `00 00 00 F6 28 08 7E 00` | 2014-11-05 |
| `1547121600000L` | 2019-01-10 12:00 | `00 00 01 68 37 A2 26 00` | 2030-05-15 |
## 修改步驟(PowerShell)
```powershell
# 1. 備份
Copy-Item "gameserver\Server_Game_2.jar" "gameserver\Server_Game_2.jar.bak"
# 2. 解壓目標 class
New-Item -ItemType Directory -Force "gameserver\_patch" | Out-Null
Push-Location "gameserver\_patch"
jar xf "..\Server_Game_2.jar" "com/lineage/server/model/gametime/L1GameTime.class"
# 3. 二進制替換(修改下面的 oldPattern / newPattern)
$classPath = Join-Path (Get-Location) "com\lineage\server\model\gametime\L1GameTime.class"
$bytes = [System.IO.File]::ReadAllBytes($classPath)
$oldPattern = @(0x00, 0x00, 0x01, 0x68, 0x37, 0xA2, 0x26, 0x00) # 當前值
$newPattern = @(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00) # 替換成新值
for ($i = 0; $i -le $bytes.Length - 8; $i++) {
$match = $true
for ($j = 0; $j -lt 8; $j++) {
if ($bytes[$i + $j] -ne $oldPattern[$j]) { $match = $false; break }
}
if ($match) {
Write-Host "找到: offset $i"
for ($j = 0; $j -lt 8; $j++) { $bytes[$i + $j] = $newPattern[$j] }
[System.IO.File]::WriteAllBytes($classPath, $bytes)
jar uf "..\Server_Game_2.jar" "com/lineage/server/model/gametime/L1GameTime.class"
Write-Host "完成"
break
}
}
Pop-Location
Remove-Item -Recurse -Force "gameserver\_patch"
```
## 計算新值的 Hex
```powershell
# 將 epoch ms 轉 8-byte big-endian hex
$val = [long1547121600000 # 改成你要的值
$b = [BitConverter]::GetBytes($val); [Array]::Reverse($b)
Write-Host (-join ($b | ForEach-Object { '0x' + $_.ToString('X2') + ', ' }))
# 計算溢出日期
$overflowMs = [long]($val + [math]::Floor(2147483647 * 1000.0 / 6))
$overflow = [DateTimeOffset]::FromUnixTimeMilliseconds($overflowMs)
Write-Host ("溢出時間: " + $overflow.UtcDateTime.ToString("yyyy-MM-dd"))
```
| |