content: package org.allaymc.server.block.component.grass;
  
  import org.allaymc.api.block.BlockBehavior;
  import org.allaymc.api.block.data.BlockFace;
  import org.allaymc.api.block.dto.Block;
  import org.allaymc.api.block.type.BlockType;
  import org.allaymc.api.entity.Entity;
  import org.allaymc.api.item.ItemStack;
  import org.allaymc.api.item.interfaces.ItemAirStack;
  import org.allaymc.api.item.type.ItemTypes;
  import org.allaymc.server.block.FortuneDropHelper;
  import org.allaymc.server.block.component.BlockBaseComponentImpl;
  
  import java.util.Set;
  
  import static org.allaymc.api.block.type.BlockTypes.*;
  
  /**
   * @author daoge_cmd
   */
  public class BlockShortGrassBaseComponentImpl extends BlockBaseComponentImpl {
      public BlockShortGrassBaseComponentImpl(BlockType<? extends BlockBehavior> blockType) {
          super(blockType);
      }
  
      @Override
      public void onNeighborUpdate(Block block, Block neighbor, BlockFace face) {
          super.onNeighborUpdate(block, neighbor, face);
  
          if (face == BlockFace.DOWN && !canPlaceOn(neighbor.getBlockType())) {
              block.breakBlock();
          }
      }
  
      protected boolean canPlaceOn(BlockType<?> blockType) {
          return blockType == GRASS_BLOCK ||
                 blockType == MYCELIUM ||
                 blockType == PODZOL ||
                 blockType == DIRT ||
                 blockType == DIRT_WITH_ROOTS ||
                 blockType == FARMLAND ||
                 blockType == MUD ||
                 blockType == MUDDY_MANGROVE_ROOTS ||
                 blockType == MOSS_BLOCK;
      }
  
      @Override
      public Set<ItemStack> getDrops(Block block, ItemStack usedItem, Entity entity) {
          if (FortuneDropHelper.bonusChanceDivisor(usedItem, 8, 2)) {
              return Set.of(ItemTypes.WHEAT_SEEDS.createItemStack());
          }
  
          return Set.of(ItemAirStack.AIR_STACK);
      }
  }
  