#621: Add HumanEntity#getItemInUse and Material#getSlipperiness

By: konsolas <vincentyntang@gmail.com>
This commit is contained in:
Bukkit/Spigot 2021-06-12 21:07:25 +01:00
parent e1c30137fb
commit b29d02153d
2 changed files with 40 additions and 0 deletions

View File

@ -9652,6 +9652,36 @@ public enum Material implements Keyed {
}
}
/**
* Returns a value that represents how 'slippery' the block is.
*
* Blocks with higher slipperiness, like {@link Material#ICE} can be slid on
* further by the player and other entities.
*
* Most blocks have a default slipperiness of {@code 0.6f}.
*
* Only available when {@link #isBlock()} is true.
*
* @return the slipperiness of this block
*/
public float getSlipperiness() {
Validate.isTrue(isBlock(), "The Material is not a block!");
switch (this) {
// <editor-fold defaultstate="collapsed" desc="getSlipperiness">
default:
return 0.6F;
case SLIME_BLOCK:
return 0.8F;
case FROSTED_ICE:
case ICE:
case PACKED_ICE:
return 0.98F;
case BLUE_ICE:
return 0.989F;
// </editor-fold>
}
}
/**
* Determines the remaining item in a crafting grid after crafting with this
* ingredient.

View File

@ -293,6 +293,16 @@ public interface HumanEntity extends LivingEntity, AnimalTamer, InventoryHolder
*/
public boolean isHandRaised();
/**
* Gets the item that the player is using (eating food, drawing back a bow,
* blocking, etc.)
*
* @return the item being used by the player, or null if they are not using
* an item
*/
@Nullable
public ItemStack getItemInUse();
/**
* Get the total amount of experience required for the player to level
*