feat(nms): 添加冒险模式物品组件支持,包括可破坏方块和可放置方块 #606
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
功能描述
为
NMSItemTag
添加冒险模式物品组件支持,包括可破坏方块 (can_break
) 和可放置方块 (can_place_on
) 的完整操作功能,并提供跨版本兼容性。新增 API
setItemCanBreak(ItemStack, List<String>)
- 设置物品可破坏方块列表setItemCanPlaceOn(ItemStack, List<String>)
- 设置物品可放置方块列表hasItemCanBreak(ItemStack)
- 检查物品是否包含可破坏方块组件hasItemCanPlaceOn(ItemStack)
- 检查物品是否包含可放置方块组件removeItemCanBreak(ItemStack)
- 移除物品可破坏方块列表removeItemCanPlaceOn(ItemStack)
- 移除物品可放置方块列表版本兼容性实现
1.20.5+ 版本 (现代数据组件系统)
DataComponents.CAN_BREAK
和DataComponents.CAN_PLACE_ON
AdventureModePredicate
和CriterionConditionBlock
实现1.20.4 及以下版本 (传统 NBT 系统)
CanDestroy
和CanPlaceOn
ItemTagList
存储方块名称列表测试环境
Breaking Changes
无破坏性变更,所有新增方法均为可选功能,且保持向下兼容。