Interface IShearable

All Known Subinterfaces:
Shearable
All Known Implementing Classes:
Bogged, CherryLeavesBlock, DeadBushBlock, LeavesBlock, MangroveLeavesBlock, MushroomCow, SeagrassBlock, Sheep, SnowGolem, TallGrassBlock, VineBlock, WebBlock

public interface IShearable
This allows for mods to create there own Shear-like items and have them interact with Blocks/Entities without extra work. Also, if your block/entity supports the Shears, this allows you to support mod-shears as well. TODO: reconsider this system, currently it is implemented but not checked for, for blocks.
  • Method Details

    • isShearable

      default boolean isShearable(@Nullable @Nullable Player player, ItemStack item, Level level, BlockPos pos)
      Checks if the object is currently shearable Example: Sheep return false when they have no wool
      Parameters:
      item - The ItemStack that is being used, may be empty.
      level - The current level.
      pos - Block's position in level.
      Returns:
      If this is shearable, and onSheared should be called.
    • onSheared

      default List<ItemStack> onSheared(@Nullable @Nullable Player player, ItemStack item, Level level, BlockPos pos)
      Performs the shear function on this object. This is called for both client, and server. The object should perform all actions related to being sheared, except for dropping of the items, and removal of the block. As those are handled by ItemShears itself.

      For entities, they should trust their internal location information over the values passed into this function.

      Parameters:
      item - The ItemStack that is being used, may be empty.
      level - The current level.
      pos - If this is a block, the block's position in level.
      Returns:
      A List containing all items that resulted from the shearing process. May be empty.
    • spawnShearedDrop

      default void spawnShearedDrop(Level level, BlockPos pos, ItemStack drop)
      Performs the logic used to drop a shear result into the world at the correct position and with the proper movement.
      For entities, they should trust their internal location information over the values passed into this function.
      Parameters:
      level - The current level.
      pos - If this is a block, the block's position in level.
      drop - The ItemStack to drop.