better logic

This commit is contained in:
Sunch 2025-04-27 20:49:19 +08:00
parent f6ca62ff6c
commit 0049ac9b04

View file

@ -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;
}