mojira.dev
MC-163503

Witch and cat are spawned at same position in swamp huts

The bug

Witch and cat in a swamp hut are spawned at the same position with same rotation.

Expected result

Witch and cat would be spawned at different positions within the swamp hut.

Code analysis

Code analysis can be found in this comment.

Linked issues

Attachments

Comments 12

Can confirm in 20w49a.

Can confirm in 20w51a.

Can confirm in 21w06a. This can be seen in almost every swamp hut.

Can confirm in 1.16.5 and 21w08b.

Can confirm in 1.17.1.

2 more comments

Code analysis (1.18.1, using Mojang mappings): in net.minecraft.world.level.levelgen.structure.SwamplandHutPiece, both the witch and the cat use the same block position within the structure piece as a reference, this.getWorldPos(2, 2, 5):

...
    @Override
    public void postProcess(...) {
        BlockPos.MutableBlockPos $$13;
        ...
        if (!this.spawnedWitch && $$4.isInside($$13 = this.getWorldPos(2, 2, 5))) {
            this.spawnedWitch = true;
            Witch $$14 = EntityType.WITCH.create($$0.getLevel());
            ...
            $$14.moveTo((double)$$13.getX() + 0.5, $$13.getY(), (double)$$13.getZ() + 0.5, 0.0f, 0.0f);
            $$14.finalizeSpawn($$0, $$0.getCurrentDifficultyAt($$13), MobSpawnType.STRUCTURE, null, null);
            $$0.addFreshEntityWithPassengers($$14);
        }
        this.spawnCat($$0, $$4);
    }

    private void spawnCat(ServerLevelAccessor $$0, BoundingBox $$1) {
        BlockPos.MutableBlockPos $$2;
        if (!this.spawnedCat && $$1.isInside($$2 = this.getWorldPos(2, 2, 5))) {
            this.spawnedCat = true;
            Cat $$3 = EntityType.CAT.create($$0.getLevel());
            ...
            $$3.moveTo((double)$$2.getX() + 0.5, $$2.getY(), (double)$$2.getZ() + 0.5, 0.0f, 0.0f);
            $$3.finalizeSpawn($$0, $$0.getCurrentDifficultyAt($$2), MobSpawnType.STRUCTURE, null, null);
            $$0.addFreshEntityWithPassengers($$3);
        }
    }
...

I can also confirm this behavior in 22w18a. This can now be more easily reproduced by using the "/place" command.

/place structure minecraft:swamp_hut ~ ~ ~

Can confirm in 1.19.

Can confirm in 1.19.2.

Affects 1.21:

[media]

One note is that this can now be more easily reproduced using the /tick command.

Christian Patzl

(Unassigned)

Confirmed

Mob spawning, Structures, World generation

19w41a, 1.16.1, 20w49a, 20w51a, 1.16.5, ..., 1.19.2, 22w44a, 1.21, 1.21.1, 24w38a

Retrieved