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
is duplicated by 1
relates to 1
Attachments
Comments 12
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 20w49a.