mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-20 11:45:51 +00:00
Fixed Explosive Tools
This commit is contained in:
parent
b5d9e11bad
commit
4d52b034f1
@ -39,8 +39,9 @@ public class ExplosivePickaxe extends SimpleSlimefunItem<BlockBreakHandler> impl
|
||||
public BlockBreakHandler getItemHandler() {
|
||||
return (e, item, fortune, drops) -> {
|
||||
if (SlimefunManager.isItemSimiliar(item, SlimefunItems.EXPLOSIVE_PICKAXE, true)) {
|
||||
e.setCancelled(true);
|
||||
e.getBlock().getWorld().createExplosion(e.getBlock().getLocation(), 0.0F);
|
||||
e.getBlock().getWorld().playSound(e.getBlock().getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 1F, 1F);
|
||||
e.getBlock().getWorld().playSound(e.getBlock().getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 0.3F, 1F);
|
||||
for (int x = -1; x <= 1; x++) {
|
||||
for (int y = -1; y <= 1; y++) {
|
||||
for (int z = -1; z <= 1; z++) {
|
||||
|
@ -31,8 +31,9 @@ public class ExplosiveShovel extends SimpleSlimefunItem<BlockBreakHandler> imple
|
||||
public BlockBreakHandler getItemHandler() {
|
||||
return (e, item, fortune, drops) -> {
|
||||
if (SlimefunManager.isItemSimiliar(item, SlimefunItems.EXPLOSIVE_SHOVEL, true)) {
|
||||
e.setCancelled(true);
|
||||
e.getBlock().getWorld().createExplosion(e.getBlock().getLocation(), 0.0F);
|
||||
e.getBlock().getWorld().playSound(e.getBlock().getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 1F, 1F);
|
||||
e.getBlock().getWorld().playSound(e.getBlock().getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 0.3F, 1F);
|
||||
|
||||
for (int x = -1; x <= 1; x++) {
|
||||
for (int y = -1; y <= 1; y++) {
|
||||
|
@ -1,13 +1,18 @@
|
||||
package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Lists.SlimefunItems;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineRecipe;
|
||||
import me.mrCookieSlime.Slimefun.utils.RecipeDisplayItem;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public abstract class FoodComposter extends AContainer {
|
||||
public abstract class FoodComposter extends AContainer implements RecipeDisplayItem {
|
||||
|
||||
public FoodComposter(Category category, ItemStack item, String name, RecipeType recipeType, ItemStack[] recipe) {
|
||||
super(category, item, name, recipeType, recipe);
|
||||
@ -24,6 +29,18 @@ public abstract class FoodComposter extends AContainer {
|
||||
registerRecipe(30, new ItemStack[] {SlimefunItems.APPLE_ORGANIC_FOOD}, new ItemStack[] {SlimefunItems.APPLE_FERTILIZER});
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDisplayRecipes() {
|
||||
List<ItemStack> displayRecipes = new ArrayList<>(recipes.size() * 2);
|
||||
|
||||
for (MachineRecipe recipe: recipes) {
|
||||
displayRecipes.add(recipe.getInput()[0]);
|
||||
displayRecipes.add(recipe.getOutput()[0]);
|
||||
}
|
||||
|
||||
return displayRecipes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMachineIdentifier() {
|
||||
return "FOOD_COMPOSTER";
|
||||
|
@ -13,9 +13,8 @@ public interface DamageableItem {
|
||||
boolean isDamageable();
|
||||
|
||||
default void damageItem(Player p, ItemStack item) {
|
||||
if (item != null && item.getType() != null && item.getType() != Material.AIR && item.getAmount() > 0 && isDamageable() && !item.getEnchantments().containsKey(Enchantment.DURABILITY) || Math.random() * 100 <= (60 + Math.floorDiv(40, (item.getEnchantmentLevel(Enchantment.DURABILITY) + 1)))) {
|
||||
if (item != null && item.getType() != null && item.getType() != Material.AIR && item.getAmount() > 0 && isDamageable() && item.getEnchantments().containsKey(Enchantment.DURABILITY) && Math.random() * 100 <= (60 + Math.floorDiv(40, (item.getEnchantmentLevel(Enchantment.DURABILITY) + 1)))) {
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
|
||||
Damageable damageable = (Damageable) meta;
|
||||
|
||||
if (damageable.getDamage() >= item.getType().getMaxDurability()) {
|
||||
|
Loading…
Reference in New Issue
Block a user