From f6ca62ff6c656adfdf2f0ebabb946131df43c74e Mon Sep 17 00:00:00 2001 From: Sunch <120295462+Sunch233@users.noreply.github.com> Date: Sun, 27 Apr 2025 19:53:50 +0800 Subject: [PATCH 1/2] typo --- src/API/BlockAPI.php | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/API/BlockAPI.php b/src/API/BlockAPI.php index 5e44794d..4c08f29c 100755 --- a/src/API/BlockAPI.php +++ b/src/API/BlockAPI.php @@ -645,7 +645,10 @@ class BlockAPI{ } } - public static function convertHighItemIdsToOldItemIds(int $protocolId, int $itemId){ + /** + * 方块/物品id转换,防止新版本影响旧版本视觉效果 + */ + public static function convertHighItemIdsToOldItemIds(int $protocolId, int $itemId) : int{ if ($protocolId >= ProtocolInfo::CURRENT_PROTOCOL) { return $itemId; } @@ -653,18 +656,18 @@ class BlockAPI{ $idMap = []; if ($protocolId < ProtocolInfo9::CURRENT_PROTOCOL_9) { $idMap += [ - 87 => 49, - 405 => 336, - 406 => 336, + NETHERRACK => OBSIDIAN, //block + NETHER_BRICK => BRICK, //item + NETHER_QUARTZ => BRICK, //item ]; } if ($protocolId < ProtocolInfo12::CURRENT_PROTOCOL_12) { $idMap += [ - 91 => 103, - 361 => 362, - 400 => 297, - 457 => 295, - 458 => 297, + LIT_PUMPKIN => MELON_BLOCK, //block + PUMPKIN_SEEDS => MELON_SEEDS, //item + PUMPKIN_PIE => BREAD, //item + BEETROOT => BREAD, //item + BEETROOT_SEEDS => SEEDS, //item ]; } From 0049ac9b046365ed48842d9639f6d87c96827f23 Mon Sep 17 00:00:00 2001 From: Sunch <120295462+Sunch233@users.noreply.github.com> Date: Sun, 27 Apr 2025 20:49:19 +0800 Subject: [PATCH 2/2] better logic --- src/API/BlockAPI.php | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/API/BlockAPI.php b/src/API/BlockAPI.php index 4c08f29c..208cd1a4 100755 --- a/src/API/BlockAPI.php +++ b/src/API/BlockAPI.php @@ -649,11 +649,18 @@ class BlockAPI{ * 方块/物品id转换,防止新版本影响旧版本视觉效果 */ public static function convertHighItemIdsToOldItemIds(int $protocolId, int $itemId) : int{ - if ($protocolId >= ProtocolInfo::CURRENT_PROTOCOL) { + if ($protocolId >= ProtocolInfo12::CURRENT_PROTOCOL_12) { return $itemId; } - $idMap = []; + $idMap = [ //default for protocol < 12 + LIT_PUMPKIN => MELON_BLOCK, //block + PUMPKIN_SEEDS => MELON_SEEDS, //item + PUMPKIN_PIE => BREAD, //item + BEETROOT => BREAD, //item + BEETROOT_SEEDS => SEEDS, //item + ]; + if ($protocolId < ProtocolInfo9::CURRENT_PROTOCOL_9) { $idMap += [ NETHERRACK => OBSIDIAN, //block @@ -661,15 +668,6 @@ class BlockAPI{ NETHER_QUARTZ => BRICK, //item ]; } - if ($protocolId < ProtocolInfo12::CURRENT_PROTOCOL_12) { - $idMap += [ - LIT_PUMPKIN => MELON_BLOCK, //block - PUMPKIN_SEEDS => MELON_SEEDS, //item - PUMPKIN_PIE => BREAD, //item - BEETROOT => BREAD, //item - BEETROOT_SEEDS => SEEDS, //item - ]; - } return $idMap[$itemId] ?? $itemId; }