mojira.dev
MC-247645

Spawning an entity on wool creates game event

Spawning an entity on wool should not create a game event.

Currently, this bug is harder to notice due to this bug, which does not offset the game event location. Although a game event is still made.

Steps to recreate:
1. Place a wool block on the floor
2. Place a block 1 higher and to the side
3. Use a spawn egg against that block, notice it does not occlude
Basically,

[media]

 but in reverse

Also, it's obvious that there is no occlusion check in the code...

Code Analysis - Yarn 22w05a
SpawnEggItem.java

public ActionResult useOnBlock(ItemUsageContext context) {
   World world = context.getWorld();
   if (!(world instanceof ServerWorld)) return ActionResult.SUCCESS;
   ItemStack itemStack = context.getStack();
   BlockPos blockPos = context.getBlockPos();
   Direction direction = context.getSide();
   //...
   EntityType<?> entityType2 = this.getEntityType(itemStack.getNbt());
   if (entityType2.spawnFromItemStack(
         (ServerWorld)world,
         itemStack,
         context.getPlayer(),
         blockPos2,
         SpawnReason.SPAWN_EGG,
         true,
         !Objects.equals(blockPos, blockPos2) && direction == Direction.UP
      ) != null) {
      itemStack.decrement(1);
      world.emitGameEvent(context.getPlayer(), GameEvent.ENTITY_PLACE, blockPos); //Game Event called here
   }
   return ActionResult.CONSUME;
}

As you can see in the code analysis, the game event is called without first checking the block below to see if its occluding

Comments 2

Can you provide the code analysis of this?

While sculk sensors have a concept of occlusion, game events are a generic system and events are supposed to be emitted regardless. If there are in-game problems with the sensors. please post a bug about the player-facing effects.

PR0CESS

(Unassigned)

Plausible

(Unassigned)

1.18.1

Retrieved