# 3.2版本物品id变更

# 简介

微软在1.20.50继续修改了部分方块ID,取消了附加值,相关链接请参阅基岩版扁平化 (opens new window),请开发者注意适配。

# 处理方法

在ModSDK的接口与事件中,我们针对上述情况做了以下处理:

  1. 对于返回物品信息字典的接口与事件:

newItemName及newAuxValue返回新版名称与附加值。

原字段itemName及auxValue返回旧版名称与附加值。

  1. 对于接受物品信息字典的接口与事件:

当字典存在newItemName及newAuxValue时,使用这两个字段。

不存在时,使用旧字段itemName及auxValue。

# 注意事项

  • 通过附加值获取获取方块状态接口没有做兼容,例如GetBlockAuxValueFromStates、GetBlockStatesFromAuxValue、GetBlockStates、SetBlockStates,如果您的组件对此有依赖,则需要对这次的改动自行做兼容处理。

  • 开发完成或正在开发的组件,建议统一采用newItemName及newAuxValue字段,也不要新旧字段混用。

  • 某些写法可能会失效,例如

    # 获取itemDict,然后在他基础上修改itemName或auxValue后再用来生成
    itemdict = GetPlayerItem()
    itemdict['itemName'] = 'xxx'
    itemdict['auxValue'] = itemdict['auxValue']+1
    SpawnItemToPlayerInv(itemdict)
    

    因为GetPlayerItem返回的itemDict含有新字段,再传入SpawnItemToPlayerInv时,会读取新字段生成物品,因此对原字段的修改无效。

# 物品名称变更表

以下为3.2版本变更了名称的物品列表,表格内的名称省略了minecraft命名空间。

中文名称 旧命名 旧附加值 新命名
花岗岩 stone 1 granite
磨制花岗岩 stone 2 polished_granite
闪长岩 stone 3 diorite
磨制闪长岩 stone 4 polished_diorite
安山岩 stone 5 andesite
磨制安山岩 stone 6 polished_andesite
云杉树木板 planks 1 spruce_planks
白桦木板 planks 2 birch_planks
丛林树木板 planks 3 jungle_planks
金合欢木板 planks 4 acacia_planks
深色橡木板 planks 5 dark_oak_planks
橙色玻璃 stained_glass 1 orange_stained_glass
品红色玻璃 stained_glass 2 magenta_stained_glass
淡蓝色玻璃 stained_glass 3 light_blue_stained_glass
黄色玻璃 stained_glass 4 yellow_stained_glass
黄绿色玻璃 stained_glass 5 lime_stained_glass
粉红色玻璃 stained_glass 6 pink_stained_glass
灰色玻璃 stained_glass 7 gray_stained_glass
淡灰色玻璃 stained_glass 8 light_gray_stained_glass
青色玻璃 stained_glass 9 cyan_stained_glass
紫色玻璃 stained_glass 10 purple_stained_glass
蓝色玻璃 stained_glass 11 blue_stained_glass
棕色玻璃 stained_glass 12 brown_stained_glass
绿色玻璃 stained_glass 13 green_stained_glass
红色玻璃 stained_glass 14 red_stained_glass
黑色玻璃 stained_glass 15 black_stained_glass
橙色玻璃板 stained_glass_pane 1 orange_stained_glass_pane
品红色玻璃板 stained_glass_pane 2 magenta_stained_glass_pane
淡蓝色玻璃板 stained_glass_pane 3 light_blue_stained_glass_pane
黄色玻璃板 stained_glass_pane 4 yellow_stained_glass_pane
黄绿色玻璃板 stained_glass_pane 5 lime_stained_glass_pane
粉红色玻璃板 stained_glass_pane 6 pink_stained_glass_pane
灰色玻璃板 stained_glass_pane 7 gray_stained_glass_pane
淡灰色玻璃板 stained_glass_pane 8 light_gray_stained_glass_pane
青色玻璃板 stained_glass_pane 9 cyan_stained_glass_pane
紫色玻璃板 stained_glass_pane 10 purple_stained_glass_pane
蓝色玻璃板 stained_glass_pane 11 blue_stained_glass_pane
棕色玻璃板 stained_glass_pane 12 brown_stained_glass_pane
绿色玻璃板 stained_glass_pane 13 green_stained_glass_pane
红色玻璃板 stained_glass_pane 14 red_stained_glass_pane
黑色玻璃板 stained_glass_pane 15 black_stained_glass_pane
橙色陶瓦 stained_hardened_clay 1 orange_terracotta
品红色陶瓦 stained_hardened_clay 2 magenta_terracotta
淡蓝色陶瓦 stained_hardened_clay 3 light_blue_terracotta
黄色陶瓦 stained_hardened_clay 4 yellow_terracotta
黄绿色陶瓦 stained_hardened_clay 5 lime_terracotta
粉红色陶瓦 stained_hardened_clay 6 pink_terracotta
灰色陶瓦 stained_hardened_clay 7 gray_terracotta
淡灰色陶瓦 stained_hardened_clay 8 light_gray_terracotta
青色陶瓦 stained_hardened_clay 9 cyan_terracotta
紫色陶瓦 stained_hardened_clay 10 purple_terracotta
蓝色陶瓦 stained_hardened_clay 11 blue_terracotta
棕色陶瓦 stained_hardened_clay 12 brown_terracotta
绿色陶瓦 stained_hardened_clay 13 green_terracotta
红色陶瓦 stained_hardened_clay 14 red_terracotta
黑色陶瓦 stained_hardened_clay 15 black_terracotta
橙色混凝土粉末 concretepowder 1 orange_concrete_powder
品红色混凝土粉末 concretepowder 2 magenta_concrete_powder
淡蓝色混凝土粉末 concretepowder 3 light_blue_concrete_powder
黄色混凝土粉末 concretepowder 4 yellow_concrete_powder
黄绿色混凝土粉末 concretepowder 5 lime_concrete_powder
粉红色混凝土粉末 concretepowder 6 pink_concrete_powder
灰色混凝土粉末 concretepowder 7 gray_concrete_powder
淡灰色混凝土粉末 concretepowder 8 light_gray_concrete_powder
青色混凝土粉末 concretepowder 9 cyan_concrete_powder
紫色混凝土粉末 concretepowder 10 purple_concrete_powder
蓝色混凝土粉末 concretepowder 11 blue_concrete_powder
棕色混凝土粉末 concretepowder 12 brown_concrete_powder
绿色混凝土粉末 concretepowder 13 green_concrete_powder
红色混凝土粉末 concretepowder 14 red_concrete_powder
黑色混凝土粉末 concretepowder 15 black_concrete_powder

为方便开发者转换数据,下面提供了一个Python函数,该函数根据旧命名和旧附加值返回新命名。将以下代码保存在一个py文件中,导入后调用其中的get_new_name函数即可:

# -*- coding: utf-8 -*-
# 定义旧命名和新命名的映射关系
mapping = {
	('stone', 1): 'granite',
	('stone', 2): 'polished_granite',
	('stone', 3): 'diorite',
	('stone', 4): 'polished_diorite',
	('stone', 5): 'andesite',
	('stone', 6): 'polished_andesite',
	('planks', 1): 'spruce_planks',
	('planks', 2): 'birch_planks',
	('planks', 3): 'jungle_planks',
	('planks', 4): 'acacia_planks',
	('planks', 5): 'dark_oak_planks',
	('stained_glass', 1): 'orange_stained_glass',
	('stained_glass', 2): 'magenta_stained_glass',
	('stained_glass', 3): 'light_blue_stained_glass',
	('stained_glass', 4): 'yellow_stained_glass',
	('stained_glass', 5): 'lime_stained_glass',
	('stained_glass', 6): 'pink_stained_glass',
	('stained_glass', 7): 'gray_stained_glass',
	('stained_glass', 8): 'light_gray_stained_glass',
	('stained_glass', 9): 'cyan_stained_glass',
	('stained_glass', 10): 'purple_stained_glass',
	('stained_glass', 11): 'blue_stained_glass',
	('stained_glass', 12): 'brown_stained_glass',
	('stained_glass', 13): 'green_stained_glass',
	('stained_glass', 14): 'red_stained_glass',
	('stained_glass', 15): 'black_stained_glass',
	('stained_glass_pane', 1): 'orange_stained_glass_pane',
	('stained_glass_pane', 2): 'magenta_stained_glass_pane',
	('stained_glass_pane', 3): 'light_blue_stained_glass_pane',
	('stained_glass_pane', 4): 'yellow_stained_glass_pane',
	('stained_glass_pane', 5): 'lime_stained_glass_pane',
	('stained_glass_pane', 6): 'pink_stained_glass_pane',
	('stained_glass_pane', 7): 'gray_stained_glass_pane',
	('stained_glass_pane', 8): 'light_gray_stained_glass_pane',
	('stained_glass_pane', 9): 'cyan_stained_glass_pane',
	('stained_glass_pane', 10): 'purple_stained_glass_pane',
	('stained_glass_pane', 11): 'blue_stained_glass_pane',
	('stained_glass_pane', 12): 'brown_stained_glass_pane',
	('stained_glass_pane', 13): 'green_stained_glass_pane',
	('stained_glass_pane', 14): 'red_stained_glass_pane',
	('stained_glass_pane', 15): 'black_stained_glass_pane',
	('stained_hardened_clay', 1): 'orange_terracotta',
	('stained_hardened_clay', 2): 'magenta_terracotta',
	('stained_hardened_clay', 3): 'light_blue_terracotta',
	('stained_hardened_clay', 4): 'yellow_terracotta',
	('stained_hardened_clay', 5): 'lime_terracotta',
	('stained_hardened_clay', 6): 'pink_terracotta',
	('stained_hardened_clay', 7): 'gray_terracotta',
	('stained_hardened_clay', 8): 'light_gray_terracotta',
	('stained_hardened_clay', 9): 'cyan_terracotta',
	('stained_hardened_clay', 10): 'purple_terracotta',
	('stained_hardened_clay', 11): 'blue_terracotta',
	('stained_hardened_clay', 12): 'brown_terracotta',
	('stained_hardened_clay', 13): 'green_terracotta',
	('stained_hardened_clay', 14): 'red_terracotta',
	('stained_hardened_clay', 15): 'black_terracotta',
	('concretepowder', 1): 'orange_concrete_powder',
	('concretepowder', 2): 'magenta_concrete_powder',
	('concretepowder', 3): 'light_blue_concrete_powder',
	('concretepowder', 4): 'yellow_concrete_powder',
	('concretepowder', 5): 'lime_concrete_powder',
	('concretepowder', 6): 'pink_concrete_powder',
	('concretepowder', 7): 'gray_concrete_powder',
	('concretepowder', 8): 'light_gray_concrete_powder',
	('concretepowder', 9): 'cyan_concrete_powder',
	('concretepowder', 10): 'purple_concrete_powder',
	('concretepowder', 11): 'blue_concrete_powder',
	('concretepowder', 12): 'brown_concrete_powder',
	('concretepowder', 13): 'green_concrete_powder',
	('concretepowder', 14): 'red_concrete_powder',
	('concretepowder', 15): 'black_concrete_powder'
}

def get_new_name(old_name, old_aux):
    # 根据旧命名和旧附加值返回新命名
    return mapping.get((old_name, old_aux), old_name)

这个函数 get_new_name 接受两个参数:old_nameold_aux,并返回对应的新命名。如果输入的旧命名和旧附加值在映射表中找不到,会返回 old_name

简介

处理方法

注意事项

物品名称变更表