gpt4 book ai didi

java - 寻求在 1.14 Minecraft 中设置粒子的帮助

转载 作者:行者123 更新时间:2023-12-02 02:13:16 25 4
gpt4 key购买 nike

我已经为此工作了一段时间了,

我正在尝试制作自己的粒子,但我在弄清楚一切如何注册以及如何让我的粒子被称为 modid:粒子时遇到问题,因此本质上是将其注册到我的 mod 中。

此外,如果有人可以帮助我进行数学计算,我希望让我的粒子慢慢地从 block 内向上移动到原始 block 上方约 0.5 个 block 。

我已经尝试了很多,将其全部列出来会很疯狂。然而,我确实设法让熔岩粒子出现,我尝试了不同的数学、不同的生成粒子的选项、我修改后在 1.14 中工作的旧方法,但不管它说什么“名称我的世界:魔法黑输入太晚了”

https://github.com/drizzs/GrassWorld-1.14/tree/master/src/main/java/com/drizzs/grassworld/api/particle <---我的模组

https://github.com/minecraftabnormals/Upgrade-Aquatic/tree/master/src/main/java/com/teamabnormals/upgrade_aquatic/client/particle <---工作粒子

做他所做的事是不可能的!我必须找到自己的方法来做同样的事情。因为我的粒子不一样。

我希望粒子以不同的大小出现,使方 block 看起来就像是神奇的。

当我尝试阻止时游戏立即崩溃

https://pastebin.com/TTA7p9iu

如果您要求,我会添加任何信息!如果您愿意解释我如何做数学或向我推荐数学资源,我会很乐意接受这些!任何我能做的以取得进步的事情,我并不特别需要你为我做。我只是想要一些指导自己的帮助!

protected EnchantedBlack(World world, double x, double y, double z) {
super(world, x, y, z, 0.0D, 0.0D, 0.0D);
this.motionX *= 0;
this.motionY *= 0.800000011920929D;
this.motionZ *= 0;
this.motionY = (double) (this.rand.nextFloat() * 0.4F + 0.05F);
this.particleScale *= this.rand.nextFloat() * 2.0F + 0.2F;
this.maxAge = (int) (16.0D / (Math.random() * 0.8D + 0.2D));
}

public void tick() {
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
float f = (float)this.age / (float)this.maxAge;

if (this.age++ >= this.maxAge) {
this.setExpired();
} else {
this.motionY -= 0.03D;
this.move(this.motionX, this.motionY, this.motionZ);
this.motionX *= 0.1D;
this.motionY *= 0.9990000128746033D;
this.motionZ *= 0.1D;
if (this.onGround) {
this.motionX *= 0.699999988079071D;
this.motionZ *= 0.699999988079071D;
}
}

}
public IParticleRenderType getRenderType() {
return IParticleRenderType.PARTICLE_SHEET_OPAQUE;
}

public float getScale(float float1) {
float f = ((float)this.age + float1) / (float)this.maxAge;
return this.particleScale * (1.0F - f * f);
}

@OnlyIn(Dist.CLIENT)
public static class Factory implements IParticleFactory<BasicParticleType> {
private final IAnimatedSprite spriteSet;

public Factory(IAnimatedSprite p_i50495_1_) {
this.spriteSet = p_i50495_1_;
}

public Particle makeParticle(BasicParticleType typeIn, World worldIn, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) {
EnchantedBlack enchantedblack = new EnchantedBlack(worldIn, x, y, z);
enchantedblack.selectSpriteRandomly(this.spriteSet);
return enchantedblack;
}
}

}

最佳答案

首先,如果您还没有,您现在应该更新到 1.14.4。

无论如何。我无法确切地说出你所拥有的东西出了什么问题,但希望我前几天这样做的经验会有所帮助。

您遇到的崩溃发生在 line 84并且是一个 ExceptionInInitializerError: null ,这意味着在将类加载到 JVM 的阶段但在创建任何实例之前的阶段遇到了问题。这一行唯一可以做到的就是对 GWParticleTypes.ENCHANTEDBLACK 的引用。

我的猜测是 this line那就是抛出一个空值。我没有这样的东西,也没有使用自己添加粒子的方法。要么注册表返回空值,要么发生我们没有注意到的进一步情况。由于 ParticleTypes 不是 IForgeRegistryEntry 类型,并且注册表完全由 Vanilla 控制,因此我怀疑使用此方法不起作用。

由于您仅使用客户端粒子(用 @OnlyIn(Dist.CLIENT) 标记的 animateTick 方法),您应该能够使用 Minecraft.getInstance().articles.addEffect(article); 相反,就像我一样 here .

我的粒子是在服务器端生成的,将数据包发送到正确的玩家客户端,并在客户端上构造实际的粒子实例,因此涉及一些重定向。您仍然需要通过侧面代理路由事物,因为您无法在公共(public)代码中引用仅限客户端的类(@OnlyIn(Dist.CLIENT) 并不妨碍您编写代码服务器可以验证!),但是 addEffect 应该可以大大简化事情。

为了获得正确的视觉效果(粒子从 block 中升起),您的主要问题可能在于这一行:

this.motionY -= 0.03D;

你让它们向下移动,而不是向上移动。同样这一行:

this.motionY *= 0.9990000128746033D;

由于“空气阻力”,会让它们每帧移动得更慢(在没有其他因素的情况下),因为您复制的粒子代码( block 破坏或浮沙粒子)代表了一个精细的粒子。从上方落下并落在地面上的类似灰尘的物体。您也不需要 this.onGround 或任何依赖于它的东西。

关于java - 寻求在 1.14 Minecraft 中设置粒子的帮助,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57317697/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com