content: package org.allaymc.server.block.component;
  
  import org.allaymc.api.block.BlockBehavior;
  import org.allaymc.api.block.dto.PlayerInteractInfo;
  import org.allaymc.api.block.type.BlockType;
  import org.allaymc.api.container.ContainerTypes;
  import org.allaymc.api.item.ItemStack;
  import org.allaymc.api.math.position.Position3i;
  import org.allaymc.api.world.Dimension;
  
  /**
   * @author daoge_cmd
   */
  public class BlockBeaconBaseComponentImpl extends BlockBaseComponentImpl {
      public BlockBeaconBaseComponentImpl(BlockType<? extends BlockBehavior> blockType) {
          super(blockType);
      }
  
      @Override
      public boolean onInteract(ItemStack itemStack, Dimension dimension, PlayerInteractInfo interactInfo) {
          if (super.onInteract(itemStack, dimension, interactInfo)) {
              return true;
          }
  
          var player = interactInfo.player();
          if (player.isSneaking()) {
              return false;
          }
  
          var beaconContainer = player.getContainer(ContainerTypes.BEACON);
          beaconContainer.setBlockPos(new Position3i(interactInfo.clickedBlockPos(), interactInfo.player().getDimension()));
          beaconContainer.addViewer(player);
          return true;
      }
  }
  