1.20.1forge and fabric自定义纹理渲染层——像原版那样让物品在世界内渲染出来

文章介绍了如何在Minecraft中实现和注册ItemInHandLayer,用于渲染玩家手上的物品,包括继承、添加层、注册过程以及使用的一些API。同时提到了饰品栏API和可能存在的问题,如多个古遗物渲染位置冲突。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

总览

让物品纹理在世界内渲染出来
就是像原版那样,把手上的东西渲染出来
分为以下几个步骤
1、继承ItemInHandLayer
2、添加这个layer
3、注册这个layer
另外,莱特兰团队制作的一系列模组也是很赞的,可以支持一下国内团队!

实现ItemInHandLayer

为什么是ItemInHandLayer?
因为只渲染纹理,没有模型的话,原版就是这样实现的
如果你想渲染模型,那就需要RenderLayer
这里,以ItemInHandLayer为例

public class TestLayer extends ItemInHandLayer{
   
	//纹理大小预设
    float scaleX=1;
    float scaleY=1;
    float scaleZ=1;
    ItemInHandRenderer itemInHandRenderer;
	//这里的EntityModelSet我们不需要,先不用管
    public TestLayer(RenderLayerParent parent, EntityModelSet set, ItemInHandRenderer renderer) {
   
        this(parent, set, 1.0F, 1.0F, 1.0F, renderer);
    }

    public TestLayer(RenderLayerParent parent, EntityModelSet set, float x, float y, float z, ItemInHandRenderer renderer) {
   
        super(parent,renderer);
        this.scaleX = x;
        this.scaleY = y;
        this.scaleZ = z;
        this.itemInHandRenderer = renderer;
    }

    public void render(PoseStack pose, MultiBufferSource buffer, int i, LivingEntity entity, float f0, float f1, float f2, 
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值