我的世界 1.16.5 forge 模组开发——粒子

第一个粒子

最近有了些想法,于是乎,重新开始了模组开发的学习。
本文主要用于记录开发过程的问题,留下学习的记录。
基于此教程
与此教程不同的是,这里将更大篇幅的记录粒子开发
而不是浅尝辄止
版本为1.16.5

WindParticle–粒子效果类

没什么可说的,只有一些变量名称的变化

public class WindParticle extends SpriteTexturedParticle {
   
    protected  WindParticle(ClientWorld world, double x, double y, double z, Vector3d speed, Color color, float diameter) {
   
        super(world, x, y, z, speed.x, speed.y, speed.z);

        this.lifetime=100;//最大生命周期
        Random rand = new Random();
        this.xd = rand.nextDouble() * 0.2 - 0.1;//x速度
        this.yd = rand.nextDouble() * 0.1;
        this.zd = rand.nextDouble() * 0.2 - 0.1;

        setColor(color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F);
        this.setAlpha(color.getAlpha());//透明度

        final float PARTICLE_SCALE_FOR_ONE_METRE = 0.5F;//大小
        this.scale(PARTICLE_SCALE_FOR_ONE_METRE * diameter);
        hasPhysics = true;//碰撞
    }

    @Override
    public IParticleRenderType getRenderType() {
   
        return IParticleRenderType.PARTICLE_SHEET_TRANSLUCENT;//渲染方式
    }

}

如果不设置速度,默认是随机速度
继承了SpriteTexturedParticle意思是将使用一张材质作为粒子效果的显示

WindData–使用接口IParticleData存放和处理这些创建例子效果的数据

注意方法名的变化

public class WindData implements IParticleData {
   

    public WindData(Vector3d speed, Color color, float diameter) {
   
        this.speed = speed;
        this.color = color;
        this.diameter = diameter;
    }
    private final Vector3d speed;
    private final Color color;
    private final float diameter;

    public static final IDeserializer<WindData> DESERIALIZER = new IDeserializer<WindData
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值