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() {
|
public BlockBreakHandler getItemHandler() {
|
||||||
return (e, item, fortune, drops) -> {
|
return (e, item, fortune, drops) -> {
|
||||||
if (SlimefunManager.isItemSimiliar(item, SlimefunItems.EXPLOSIVE_PICKAXE, true)) {
|
if (SlimefunManager.isItemSimiliar(item, SlimefunItems.EXPLOSIVE_PICKAXE, true)) {
|
||||||
|
e.setCancelled(true);
|
||||||
e.getBlock().getWorld().createExplosion(e.getBlock().getLocation(), 0.0F);
|
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 x = -1; x <= 1; x++) {
|
||||||
for (int y = -1; y <= 1; y++) {
|
for (int y = -1; y <= 1; y++) {
|
||||||
for (int z = -1; z <= 1; z++) {
|
for (int z = -1; z <= 1; z++) {
|
||||||
|
@ -31,8 +31,9 @@ public class ExplosiveShovel extends SimpleSlimefunItem<BlockBreakHandler> imple
|
|||||||
public BlockBreakHandler getItemHandler() {
|
public BlockBreakHandler getItemHandler() {
|
||||||
return (e, item, fortune, drops) -> {
|
return (e, item, fortune, drops) -> {
|
||||||
if (SlimefunManager.isItemSimiliar(item, SlimefunItems.EXPLOSIVE_SHOVEL, true)) {
|
if (SlimefunManager.isItemSimiliar(item, SlimefunItems.EXPLOSIVE_SHOVEL, true)) {
|
||||||
|
e.setCancelled(true);
|
||||||
e.getBlock().getWorld().createExplosion(e.getBlock().getLocation(), 0.0F);
|
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 x = -1; x <= 1; x++) {
|
||||||
for (int y = -1; y <= 1; y++) {
|
for (int y = -1; y <= 1; y++) {
|
||||||
|
@ -1,13 +1,18 @@
|
|||||||
package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric;
|
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.RecipeType;
|
||||||
import me.mrCookieSlime.Slimefun.Lists.SlimefunItems;
|
import me.mrCookieSlime.Slimefun.Lists.SlimefunItems;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer;
|
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 implements RecipeDisplayItem {
|
||||||
|
|
||||||
public abstract class FoodComposter extends AContainer {
|
|
||||||
|
|
||||||
public FoodComposter(Category category, ItemStack item, String name, RecipeType recipeType, ItemStack[] recipe) {
|
public FoodComposter(Category category, ItemStack item, String name, RecipeType recipeType, ItemStack[] recipe) {
|
||||||
super(category, item, name, recipeType, 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});
|
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
|
@Override
|
||||||
public String getMachineIdentifier() {
|
public String getMachineIdentifier() {
|
||||||
return "FOOD_COMPOSTER";
|
return "FOOD_COMPOSTER";
|
||||||
|
@ -13,9 +13,8 @@ public interface DamageableItem {
|
|||||||
boolean isDamageable();
|
boolean isDamageable();
|
||||||
|
|
||||||
default void damageItem(Player p, ItemStack item) {
|
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();
|
ItemMeta meta = item.getItemMeta();
|
||||||
|
|
||||||
Damageable damageable = (Damageable) meta;
|
Damageable damageable = (Damageable) meta;
|
||||||
|
|
||||||
if (damageable.getDamage() >= item.getType().getMaxDurability()) {
|
if (damageable.getDamage() >= item.getType().getMaxDurability()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user