mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-19 19:25:48 +00:00
Added item break sound to some tools
This commit is contained in:
parent
99de9a6919
commit
c5630791c0
@ -38,6 +38,7 @@
|
||||
* Added Nitwit Rune
|
||||
* Added Synthetic Shulker Shells
|
||||
* Added Climbing Pick
|
||||
* Added item breaking sounds to some slimefun tools
|
||||
|
||||
#### Changes
|
||||
* Performance improvement for Programmable Android rotations
|
||||
|
@ -1,6 +1,10 @@
|
||||
package io.github.thebusybiscuit.slimefun4.core.attributes;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@ -43,7 +47,7 @@ public interface DamageableItem extends ItemAttribute {
|
||||
* @param item
|
||||
* The {@link ItemStack} to damage
|
||||
*/
|
||||
default void damageItem(Player p, ItemStack item) {
|
||||
default void damageItem(@Nonnull Player p, @Nullable ItemStack item) {
|
||||
if (isDamageable() && item != null && item.getType() != Material.AIR && item.getAmount() > 0) {
|
||||
if (item.getEnchantments().containsKey(Enchantment.DURABILITY) && Math.random() * 100 <= (60 + Math.floorDiv(40, (item.getEnchantmentLevel(Enchantment.DURABILITY) + 1)))) {
|
||||
return;
|
||||
@ -53,6 +57,7 @@ public interface DamageableItem extends ItemAttribute {
|
||||
Damageable damageable = (Damageable) meta;
|
||||
|
||||
if (damageable.getDamage() >= item.getType().getMaxDurability()) {
|
||||
p.playSound(p.getEyeLocation(), Sound.ENTITY_ITEM_BREAK, 1, 1);
|
||||
item.setAmount(0);
|
||||
}
|
||||
else {
|
||||
|
Loading…
Reference in New Issue
Block a user