mojira.dev
MC-94389

Shulker bullets follow players who changed game mode from survival mode to creative mode

The bug

Shulker bullets shot at a specific player in survival mode continue to follow that player after switching to creative mode.

Linked issues

Attachments

Comments 19

Confirmed in 1.16-pre5. Please, change the reporter to me so I can keep the ticket up-to-date.

You can't change the reporter

Can confirm in 20w48a.

Can confirm in 20w51a.

9 more comments

Can confirm in 1.19.

[media]

Can confirm in 1.19.2.

Can confirm in latest snapshot, 26.1-snapshot-1

Can confirm in 1.21.11.

This issue likely stems from ShulkerBullet.class, where within the tick() method, the code only checks if the target is in spectator (confirmed ingame - Shulker bullets do NOT target the player when initially in Survival, then switching to Spectator).

public void tick() {
        super.tick();
        Entity finalTarget = !this.level().isClientSide() ? EntityReference.getEntity(this.finalTarget, this.level()) : null;
        HitResult hitResult = null;
        if (!this.level().isClientSide()) {
            if (finalTarget == null) {
                this.finalTarget = null;
            }

            if (finalTarget == null || !finalTarget.isAlive() || finalTarget instanceof Player && finalTarget.isSpectator()) {
                this.applyGravity();
            } else {
                // other code
        }

The if statement only checks finalTarget.isSpectator(), whereas Mob.class has a method called asValidTarget, which has checks for both spectator mode and a player.isCreative() check, on line 267 in the deobfuscated code:

protected @Nullable LivingEntity asValidTarget(final @Nullable LivingEntity target) {
        if (target instanceof Player player) {
            if (player.isCreative() || player.isSpectator()) {
                return null;
            }
        }

Swekob

(Unassigned)

Confirmed

Gameplay

Low

Projectiles

AI, attack, creative, gamemode, shulker, shulker_bullet

Minecraft 15w50a, Minecraft 16w06a, Minecraft 1.9 Pre-Release 1, Minecraft 1.10.2, Minecraft 16w36a, ..., 1.20.3 Release Candidate 1, 1.20.4, 1.21.5, 1.21.11, 26.1 Snapshot 1

Retrieved