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

Markers and display entities obstruct placement of armor stands and end crystals

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • None
    • 1.20.4
    • Unconfirmed
    • (Unassigned)

      The bug

      You can't place armor stands or end crystals if a marker or display entity occupies the block. This bug relates to MC-267260.

      Steps to reproduce

      1. Place a block of obsidian.
      2. Run one of these commands on the block:
        summon marker ~ ~0.1 ~

        or

        summon block_display ~ ~0.1 ~
      3. Try to place an armor stand or end crystal on top of the block.

      Observed result

      The armor stand / end crystal can't be placed on top of the block.

      Expected result

      The armor stand / end crystal can be placed on top of the block because markers and display entities also don't obstruct the placement of blocks.

      Code analysis

      The code for placing armor stands and end crystals both use EntityGetter.getEntities(Entity, AABB) which supplies the default entity predicate EntitySelector.NO_SPECTATORS. This entity predicate only accounts for spectators and not for markers or display entities. Therefore if a marker or display entity is in the provided bounding box, it causes the check to fail.

      net.minecraft.world.item.ArmorStandItem
      public InteractionResult useOn(UseOnContext context) {
          // ...
          if (!level.noCollision(null, boundingBox) || !level.getEntities(null, boundingBox).isEmpty()) {
              return InteractionResult.FAIL;
          }
          // ...
      }
      
      net.minecraft.world.item.EndCrystalItem
      public InteractionResult useOn(UseOnContext context) {
          // ...
          List<Entity> entities = level.getEntities(null, new AABB(x, y, z, x + 1, y + 1, z + 1));
          if (!entities.isEmpty()) {
              return InteractionResult.FAIL;
          }
          // ...
      }
      
      net.minecraft.world.level.EntityGetter
      public List<Entity> getEntities(Entity exclude, AABB boundingBox) {
          return getEntities(exclude, boundingBox, EntitySelector.NO_SPECTATORS);
      }
      
      net.minecraft.world.entity.EntitySelector
      public static final Predicate<Entity> NO_SPECTATORS = e -> !e.isSpectator();
      

      Potential fix

      Replace the default entity predicate for EntityGetter.getEntities(Entity, AABB) with one that also accounts for markers and display entities.

            Unassigned Unassigned
            Rob23 Rob23
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: