Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-247645

Spawning an entity on wool creates game event

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Works As Intended
    • None
    • 1.18.1
    • None
    • Plausible
    • (Unassigned)

      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, [^2022-01-03 17-23-48.mp4] 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

            Unassigned Unassigned
            PR0CESS FX - PR0CESS
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: