高分辨率物品
TIP
本教程使用附着物(attachable)。如果您不了解什么是附着物,请先阅读此页面:附着物
简介
在大多数情况下,创建物品时使用标准的16x16分辨率就足够了。但有时您可能希望物品具有更精细的细节。不过您可能已经注意到高分辨率物品存在一个问题:它们最终看起来会变得更大,而不是更精细!

解决方案是使用附着物来在手持时缩小物品尺寸。相关的计算可能需要大量调试,因此本页面提供了创建附着物所需的代码,可将您的物品缩放回正常大小!虽然这个方法并非完美,但最终效果会与普通物品非常相似,仅在旋转角度和攻击动画方面存在细微差异。其主要原理是通过动画将物品尺寸缩小到应有的比例。
所需文件
要实现这个修复方案,我们需要准备:几何模型、渲染控制器、附着物和动画文件。
以下是几何模型文件。它的作用是使用纹理网格读取附着物中使用的纹理,并基于此创建几何模型,无需费力地用立方体建模来匹配物品!此文件通常不需要任何编辑。
RP/models/entity/large_item.geo.json
json
{
"format_version": "1.16.0",
"minecraft:geometry": [
{
"description": {
"identifier": "geometry.large_item",
"texture_width": 16,
"texture_height": 16,
"visible_bounds_width": 2,
"visible_bounds_height": 1.5,
"visible_bounds_offset": [0, 0.25, 0]
},
"bones": [
{
"name": "rightitem",
"pivot": [0, 0, 0],
"texture_meshes": [
{
"texture": "default",
"position": [0, 0, 0],
"local_pivot": [8, 0, 8]
}
]
}
]
}
]
}以下是渲染控制器文件的内容。这个文件也很简单,通常不需要编辑。
RP/render_controllers/large_item.render_controllers.json
json
{
"format_version": "1.8.0",
"render_controllers": {
"controller.render.large_item": {
"geometry": "Geometry.default",
"materials": [{ "*": "variable.is_enchanted ? Material.enchanted : Material.default" }],
"textures": ["Texture.default", "Texture.enchanted"]
}
}
}以下是附着物文件的内容。注意:您需要将<identifier>替换为您的物品标识符,并将<path>替换为物品纹理的文件路径(应与item_texture.json中使用的路径一致)。
RP/attachables/large_item.json
json
{
"format_version": "1.10.0",
"minecraft:attachable": {
"description": {
//将<identifier>替换为您的物品完整标识符
"identifier": "<identifier>",
"materials": {
"default": "entity_alphatest",
"enchanted": "entity_alphatest_glint"
},
"textures": {
//将<path>替换为物品纹理的文件路径,应与item_texture.json中给出的路径一致
"default": "<path>",
"enchanted": "textures/misc/enchanted_item_glint"
},
"geometry": {
"default": "geometry.large_item"
},
"animations": {
"hold": "animation.large_item.hold"
},
"scripts": {
"animate": ["hold"]
},
"render_controllers": ["controller.render.large_item"]
}
}
}现在我们已经准备好了这些文件,接下来可以创建实现所有神奇效果的动画了!这个动画将使您的物品旋转角度与原版物品手持时的旋转角度保持一致,同时将物品缩小到合适的大小。
RP/animations/large_item.animation.json
json
{
"format_version": "1.10.0",
"animations": {
"animation.large_item.hold": {
"loop": true,
"bones": {
"rightitem": {
//这些动画参数用于正确定位物品
"position": [
"c.is_first_person ? -6 : 1",
"c.is_first_person ? 0 : -1",
"c.is_first_person ? -1 : -6"
],
"rotation": [
"c.is_first_person ? 45 : 15",
"c.is_first_person ? -15 : 0",
"c.is_first_person ? 30 : -165"
],
"scale": [
"c.is_first_person ? 1 : 0.5",
"c.is_first_person ? 1 : 0.5",
"c.is_first_person ? 1 : 0.5"
]
}
}
}
}
}最终效果
完成以上所有文件的配置后,您的物品看起来应该会好很多!例如,这是我在资源包中应用本教程所有文件后,使用第一张图片中的物品替换所有相应值后的效果:

