ItemModelResolver.java
net.minecraft.client.renderer.item.ItemModelResolver
信息
- 全限定名:net.minecraft.client.renderer.item.ItemModelResolver
- 类型:public class
- 包:net.minecraft.client.renderer.item
- 源码路径:src/main/java/net/minecraft/client/renderer/item/ItemModelResolver.java
- 起始行号:L18
- 职责:
TODO
字段/常量
modelManager- 类型:
ModelManager - 修饰符:
private final - 源码定位:
L19 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
public ItemModelResolver(ModelManager modelManager) @ L21
- 构造器名:ItemModelResolver
- 源码定位:L21
- 修饰符:public
参数:
- modelManager: ModelManager
说明:
TODO
方法
下面的方法块按源码顺序生成。
private ClientItem.Properties getItemProperties(Identifier modelId) @ L25
- 方法名:getItemProperties
- 源码定位:L25
- 返回类型:ClientItem.Properties
- 修饰符:private
参数:
- modelId: Identifier
说明:
TODO
private ItemModel getItemModel(Identifier modelId) @ L29
- 方法名:getItemModel
- 源码定位:L29
- 返回类型:ItemModel
- 修饰符:private
参数:
- modelId: Identifier
说明:
TODO
public void updateForLiving(ItemStackRenderState output, ItemStack item, ItemDisplayContext displayContext, LivingEntity entity) @ L33
- 方法名:updateForLiving
- 源码定位:L33
- 返回类型:void
- 修饰符:public
参数:
- output: ItemStackRenderState
- item: ItemStack
- displayContext: ItemDisplayContext
- entity: LivingEntity
说明:
TODO
public void updateForNonLiving(ItemStackRenderState output, ItemStack item, ItemDisplayContext displayContext, Entity entity) @ L37
- 方法名:updateForNonLiving
- 源码定位:L37
- 返回类型:void
- 修饰符:public
参数:
- output: ItemStackRenderState
- item: ItemStack
- displayContext: ItemDisplayContext
- entity: Entity
说明:
TODO
public void updateForTopItem(ItemStackRenderState output, ItemStack item, ItemDisplayContext displayContext, Level level, ItemOwner owner, int seed) @ L41
- 方法名:updateForTopItem
- 源码定位:L41
- 返回类型:void
- 修饰符:public
参数:
- output: ItemStackRenderState
- item: ItemStack
- displayContext: ItemDisplayContext
- level: Level
- owner: ItemOwner
- seed: int
说明:
TODO
public void appendItemLayers(ItemStackRenderState output, ItemStack item, ItemDisplayContext displayContext, Level level, ItemOwner owner, int seed) @ L51
- 方法名:appendItemLayers
- 源码定位:L51
- 返回类型:void
- 修饰符:public
参数:
- output: ItemStackRenderState
- item: ItemStack
- displayContext: ItemDisplayContext
- level: Level
- owner: ItemOwner
- seed: int
说明:
TODO
public boolean shouldPlaySwapAnimation(ItemStack stack) @ L61
- 方法名:shouldPlaySwapAnimation
- 源码定位:L61
- 返回类型:boolean
- 修饰符:public
参数:
- stack: ItemStack
说明:
TODO
public float swapAnimationScale(ItemStack stack) @ L66
- 方法名:swapAnimationScale
- 源码定位:L66
- 返回类型:float
- 修饰符:public
参数:
- stack: ItemStack
说明:
TODO
代码
@OnlyIn(Dist.CLIENT)
public class ItemModelResolver {
private final ModelManager modelManager;
public ItemModelResolver(ModelManager modelManager) {
this.modelManager = modelManager;
}
private ClientItem.Properties getItemProperties(Identifier modelId) {
return this.modelManager.getItemProperties(modelId);
}
private ItemModel getItemModel(Identifier modelId) {
return this.modelManager.getItemModel(modelId);
}
public void updateForLiving(ItemStackRenderState output, ItemStack item, ItemDisplayContext displayContext, LivingEntity entity) {
this.updateForTopItem(output, item, displayContext, entity.level(), entity, entity.getId() + displayContext.ordinal());
}
public void updateForNonLiving(ItemStackRenderState output, ItemStack item, ItemDisplayContext displayContext, Entity entity) {
this.updateForTopItem(output, item, displayContext, entity.level(), entity, entity.getId());
}
public void updateForTopItem(
ItemStackRenderState output, ItemStack item, ItemDisplayContext displayContext, @Nullable Level level, @Nullable ItemOwner owner, int seed
) {
output.clear();
if (!item.isEmpty()) {
output.displayContext = displayContext;
this.appendItemLayers(output, item, displayContext, level, owner, seed);
}
}
public void appendItemLayers(
ItemStackRenderState output, ItemStack item, ItemDisplayContext displayContext, @Nullable Level level, @Nullable ItemOwner owner, int seed
) {
Identifier modelId = item.get(DataComponents.ITEM_MODEL);
if (modelId != null) {
output.setOversizedInGui(this.getItemProperties(modelId).oversizedInGui());
this.getItemModel(modelId).update(output, item, this, displayContext, level instanceof ClientLevel clientLevel ? clientLevel : null, owner, seed);
}
}
public boolean shouldPlaySwapAnimation(ItemStack stack) {
Identifier modelId = stack.get(DataComponents.ITEM_MODEL);
return modelId == null ? true : this.getItemProperties(modelId).handAnimationOnSwap();
}
public float swapAnimationScale(ItemStack stack) {
Identifier modelId = stack.get(DataComponents.ITEM_MODEL);
return modelId == null ? 1.0F : this.getItemProperties(modelId).swapAnimationScale();
}
}引用的其他类
-
- 引用位置:
返回值
- 引用位置:
-
- 引用位置:
返回值
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数/字段
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置: