mojira.dev
MC-189857

Potion particles spread always from the center of a block, regardless of impact

Would have expected them to emanate from the position of the thrown potion entity itself, as this is what happens with other thrown entities (snowballs, eggs, ...). Having it always appear at the center of a block would end up having them be generated at weird places when hitting entities.

Remember to make sure to not use floats!

Code analysis

Code analysis can be found in this comment.

Linked issues

Attachments

Comments

gaspoweredpick

This can cause potion particles to sink into the ground when thrown onto farmland, grass paths, bottom slabs, and other blocks without a solid top face.

migrated

affects 20w27a

Avoma

Can confirm in 20w46a.

Avoma

Can confirm in 21w05b.

Avoma

Can confirm in 21w06a.

Avoma

Can confirm in 1.16.5 and 21w08b. Video attached.

Avoma

Can confirm in 21w15a.

Avoma

Can confirm in 21w16a.

Avoma

Can confirm in 1.17.

Avoma

Can confirm in 1.17.1.

Avoma

Can confirm in 1.18.1.

Avoma

Can confirm in 1.18.2.

ampolive

Code analysis (Mojang mappings, 22w15a): ThrownPotion#onHit() creates a level event when the potion hits something, using the block position instead of the entity position (LevelAccessor#levelEvent(...) requires a BlockPos):

...
int $$5 = $$2.hasInstantEffects() ? 2007 : 2002;
this.level.levelEvent($$5, this.blockPosition(), PotionUtils.getColor($$1));
...

In LevelRenderer#levelEvent(...):

...
                Vec3 $$25 = Vec3.atBottomCenterOf($$2);
                ...
                SimpleParticleType $$30 = $$1 == 2007 ? ParticleTypes.INSTANT_EFFECT : ParticleTypes.EFFECT;
                for (int $$31 = 0; $$31 < 100; ++$$31) {
                    double $$32 = $$4.nextDouble() * 4.0;
                    double $$33 = $$4.nextDouble() * Math.PI * 2.0;
                    double $$34 = Math.cos($$33) * $$32;
                    double $$35 = 0.01 + $$4.nextDouble() * 0.5;
                    double $$36 = Math.sin($$33) * $$32;
                    Particle $$37 = this.addParticleInternal($$30, $$30.getType().getOverrideLimiter(), $$25.x + $$34 * 0.1, $$25.y + 0.3, $$25.z + $$36 * 0.1, $$34, $$35, $$36);
                    ...
                }
...

This uses Vec3.atBottomCenterOf(BlockPos) as the "reference" position to spawn the particles, which is (x + 0.5, y, z + 0.5), so the particles are spawned around the bottom center of the block.

NBG-bootmgr

Confirm in 1.19.1-pre2

Avoma

Can confirm in 1.19.

muzikbike

(Unassigned)

Confirmed

Gameplay

Low

Particles

incorrect-particle-generation

1.16 Pre-release 6, 1.16 Pre-release 7, 1.16 Release Candidate 1, 1.16, 20w27a, ..., 23w51b, 24w11a, 1.21.1, 24w44a, 1.21.3

Retrieved