接口 IShearable
- 所有已知子接口:
Shearable
- 所有已知实现类:
Bogged
,LeavesBlock
,MangroveLeavesBlock
,MushroomCow
,SeagrassBlock
,Sheep
,SnowGolem
,TallGrassBlock
,TintedParticleLeavesBlock
,UntintedParticleLeavesBlock
,VineBlock
,WebBlock
public interface IShearable
This interfaces allows shears (modded 无效输入:'&' vanilla) and entities (modded 无效输入:'&' vanilla) to cooperate
without needing advance knowledge of each other.
In the future, this system may function for implementations on Block
s as well.
TODO: Implement support for Block
or remove default implementations from vanilla block classes.
-
方法概要
修饰符和类型方法说明default boolean
isShearable
(@Nullable Player player, ItemStack item, Level level, BlockPos pos) Checks if this object can be sheared.Shears this object.default void
spawnShearedDrop
(ServerLevel 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.
-
方法详细资料
-
isShearable
default boolean isShearable(@Nullable @Nullable Player player, ItemStack item, Level level, BlockPos pos) Checks if this object can be sheared.For example, Sheep return false when they have no wool.
- 参数:
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 ofEntity.blockPosition()
.- 返回:
- 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<ItemStack> onSheared(@Nullable @Nullable Player player, ItemStack item, Level level, 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.- 参数:
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 ofEntity.blockPosition()
.- 返回:
- A list holding all dropped items resulting from the shear operation, or an empty list if nothing dropped.
-
spawnShearedDrop
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 thepos
parameter.- 参数:
level
- The current level.pos
- The block position of this object (if this is an entity, the value ofEntity.blockPosition()
.drop
- The stack to drop, from the list of drops returned byonSheared(net.minecraft.world.entity.player.Player, net.minecraft.world.item.ItemStack, net.minecraft.world.level.Level, net.minecraft.core.BlockPos)
.
-