Interface IShearable


public interface IShearable
This interfaces allows shears (modded invalid input: '&' vanilla) and entities (modded invalid input: '&' vanilla) to cooperate without needing advance knowledge of each other.

In the future, this system may function for implementations on Blocks as well. TODO: Implement support for Block or remove default implementations from vanilla block classes.

  • Method Summary

    Modifier and Type
    Method
    Description
    default boolean
    isShearable(@Nullable net.minecraft.world.entity.player.Player player, net.minecraft.world.item.ItemStack item, net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos)
    Checks if this object can be sheared.
    default List<net.minecraft.world.item.ItemStack>
    onSheared(@Nullable net.minecraft.world.entity.player.Player player, net.minecraft.world.item.ItemStack item, net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos)
    Shears this object.
    default void
    spawnShearedDrop(net.minecraft.server.level.ServerLevel level, net.minecraft.core.BlockPos pos, net.minecraft.world.item.ItemStack drop)
    Performs the logic used to drop a shear result into the world at the correct position and with the proper movement.
  • Method Details

    • isShearable

      default boolean isShearable(@Nullable @Nullable net.minecraft.world.entity.player.Player player, net.minecraft.world.item.ItemStack item, net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos)
      Checks if this object can be sheared.

      For example, Sheep return false when they have no wool.

      Parameters:
      item - The shear tool that is being used, may be empty.
      level - The current level.
      pos - The block position of this object (if this is an entity, the value of Entity.blockPosition().
      Returns:
      If this is shearable, and onSheared(net.minecraft.world.entity.player.Player, net.minecraft.world.item.ItemStack, net.minecraft.world.level.Level, net.minecraft.core.BlockPos) may be called.
    • onSheared

      default List<net.minecraft.world.item.ItemStack> onSheared(@Nullable @Nullable net.minecraft.world.entity.player.Player player, net.minecraft.world.item.ItemStack item, net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos)
      Shears this object. This function is called on both sides, and is responsible for performing any and all actions that happen when sheared, except spawning drops.

      Drops that are spawned as a result of being sheared should be returned from this method, and will be spawned on the server using spawnShearedDrop(net.minecraft.server.level.ServerLevel, net.minecraft.core.BlockPos, net.minecraft.world.item.ItemStack).

      Entities may respect their internal position values instead of relying on the pos parameter.

      Parameters:
      item - The shear tool that is being used, may be empty.
      level - The current level.
      pos - The block position of this object (if this is an entity, the value of Entity.blockPosition().
      Returns:
      A list holding all dropped items resulting from the shear operation, or an empty list if nothing dropped.
    • spawnShearedDrop

      default void spawnShearedDrop(net.minecraft.server.level.ServerLevel level, net.minecraft.core.BlockPos pos, net.minecraft.world.item.ItemStack drop)
      Performs the logic used to drop a shear result into the world at the correct position and with the proper movement.
      Entities may respect their internal position values instead of relying on the pos parameter.
      Parameters:
      level - The current level.
      pos - The block position of this object (if this is an entity, the value of Entity.blockPosition().
      drop - The stack to drop, from the list of drops returned by onSheared(net.minecraft.world.entity.player.Player, net.minecraft.world.item.ItemStack, net.minecraft.world.level.Level, net.minecraft.core.BlockPos).