DarthSharkie / Apel-Mod

Apel is a library that brings particle animations to the table with flexible behaviour and a clean developer interface. It promises also lots of predefined shapes & paths to help the developer on their particle scene
Other
0 stars 0 forks source link

`ParticleBezierCurve` threw a NPE rendering on client-side #19

Closed DarthSharkie closed 4 months ago

DarthSharkie commented 4 months ago

Stacktrace:

Error executing task on Client
 java.lang.NullPointerException: Cannot invoke "net.minecraft.particle.ParticleEffect.getType()" because "parameters" is null
at net.minecraft.client.particle.ParticleManager.createParticle(ParticleManager.java:356)
at net.minecraft.client.particle.ParticleManager.addParticle(ParticleManager.java:345)
at net.mcbrincie.apel.client.ApelClient.drawParticle(ApelClient.java:50) ~[main/:?]
at net.mcbrincie.apel.client.ApelClient.lambda$onInitializeClient$0(ApelClient.java:28) ~[main/:?]

BezierCurve animation:

ParticleBezierCurve curve = new ParticleBezierCurve(
    ParticleTypes.END_ROD,
    new CubicBezierCurve[]{
        new CubicBezierCurve(
           new Vector3f(), new Vector3f(0.0f, 5.0f, 0.0f),
           new Vector3f(2.0f, 0.0f, 2.0f), new Vector3f(2.0f, -1.0f, 8.0f)
        ),
        new CubicBezierCurve(
          new Vector3f(), new Vector3f(0.0f, 5.0f, 0.0f),
          new Vector3f(2.0f, 0.0f, 2.0f), new Vector3f(-2.0f, 1.0f, -8.0f)
        )
  },
  new int[]{100, 100}
);
PointAnimator pointAnimator = new PointAnimator(1, curve, new Vector3f(0, 0, 0), 100);
pointAnimator.beginAnimation(ApelRenderer.client(world));
DarthSharkie commented 4 months ago

Tracked this down to a problem in ApelNetworkRenderer where the ParticleType is only sent on change. If successive frames don't change the ParticleType, the subsequent payload handling invocation on the client side doesn't have a particleEffect set. Fix is to force send a PType instruction on every payload.

Also, fixed a offset bug in ParticleBezierCurve. This bug probably exists more broadly, but that needs to be verified.

Fix pushed in https://github.com/DarthSharkie/Apel-Mod/commit/676fcae6acda066cbab4ec593c953e9f581a6aef.