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,
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
Can you provide the code analysis of this?