mojira.dev
MC-32110

SpawnerMinecart with a SpawnRange of 0 not working properly.

So I spawned a spawner minecart with a command block. The command was the following:

/summon spawner_minecart ~ ~6 ~.1 {SpawnRange:0,MinSpawnDelay:3,MaxSpawnDelay:3,SpawnData:{id:"minecraft:falling_block",Block:redstone_block,Time:1,DropItem:0},SpawnCount:1}

This creates a spawner minecart with a SpawnRange of 0 that spawns redstone blocks, so I expected it to spawn redstone block in the block the spawner minecart is in.

However, the spawner minecart spawns the blocks in the block it is in as well as the block above that, and also the block underneath the block the spawner minecart is standing on.

From 14w06a on, some of the spawned blocks are invisible. They become visible again after relogging.

The weird thing though is, that the spawner minecart doesn't drop blocks below the floor when it is at an exact coordinate. (In the command it said: ~ ~6 ~.1 If you replace the .1 with a 1 it doesn't spawn blocks below the floor, but it still does spawn above the block the spawner minecart is in.)

How to reproduce

  1. Use the following command

    /setblock ~ ~4 ~ spawner{SpawnRange:0s,MinSpawnDelay:3s,MaxSpawnDelay:3s,SpawnData:{entity: {id: "minecraft:armor_stand", NoGravity:1b}},SpawnCount:1s} destroy

    → All armor stands are spawned at the same x and y position because SpawnRange is 0, but their y position varies

Code analysis

Code analysis by @unknown can be found in this comment.

Linked issues

Attachments

Comments

Ezekiel

Is this still a concern in the latest Minecraft version 13w48b? If so, please update the affected versions in order to best aid Mojang ensuring bugs are still valid in the latest releases/pre-releases.

Chris

Yes, this bug does still occur in version 13w48b.

Ezekiel

Is this still a concern in the latest Minecraft version 14w03b? If so, please update the affected versions in order to best aid Mojang ensuring bugs are still valid in the latest releases/pre-releases.

Chris

Yes, in fact, the bug become worse, besides a spawnerminecart, the commandblock now also summons a fake Pig.

Chris

As you can see, redstoneblocks were spawned underneath the platform. They also got spawned in and above the minecart but you can't see those, because of another bug causing the spawned blocks to be invisible. As well as that, you can also see a fake pig, it will disappear after relogging. Reloggin will also make the other redstoneblocks visible, and it will fix the fake hole that the minecart created.

ben

Spawners are supposed to spawn entities in range you gave, SpawnRange only affects the x and z range. This works as intended, Not sure about the pig though.

Chris

Can you change the up- and downwards spawnrange of spawners? And if so, how?

Chris

There is a new bug that prevents this bug from being tested; if you spawn in the spawnerminecart, minecraft crashes.

marcono1234

Confirmed for

  • 1.8.6

marcono1234

Confirmed for

  • 15w40b

The reason for that is that the height is not affected by the SpawnRange:

MobSpawnerBaseLogic.class (1.8)

double var8 = (double)(var1.getY() + this.getSpawnerWorld().rand.nextInt(3) - 1);

(I hope it is alright that I added this code snippet)

var8 seems to be the y coordinate for the entity to spawn, var1 is the position of the mob spawner.
.rand.nextInt(3) means a random integer between 0 and 2 (see Java - Random)
This means that is always spawns the entity either one block above, at the same position or one block below the spawner.

Possible fix (1.8)

double var8 = (double)(var1.getY() + (this.getSpawnerWorld().rand.nextDouble() - this.getSpawnerWorld().rand.nextDouble()) * Math.min((double)this.spawnRange, 1) + 0.5D);

Where 1 represents the random value between -1 and 1

marcono1234

Confirmed for

  • 1.9-pre2

j_p_smith

Confirmed in 1.15.2 and 20w22a.

Avoma

Can confirm in 20w51a.

Avoma

Can confirm in 21w03a.

Avoma

Can confirm in 21w05b.

Avoma

Can confirm in 21w06a.

Avoma

Can confirm in 21w07a.

Avoma

Video attached.

Marty McFly

Affects 21w18a

Neliz_

I can reproduce this in 1.20.4 and 24w07a with the following command:

/setblock ~ ~4 ~ spawner{SpawnRange:0s,MinSpawnDelay:3s,MaxSpawnDelay:3s,SpawnData:{entity: {id: "minecraft:armor_stand", NoGravity:1b}},SpawnCount:1s} destroy

Chris

(Unassigned)

Confirmed

Platform

Low

Minecart, Mob spawning

minecart, range, spawner

Minecraft 13w38c, Minecraft 13w48b, Minecraft 13w49a, Minecraft 1.7.4, Minecraft 14w02c, ..., 21w06a, 21w07a, 21w18a, 1.20.4, 24w07a

Retrieved