mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-20 03:35:51 +00:00
Stop unwanted actions from StrangeNetherGoo and Heavy Cream
This commit is contained in:
commit
15884c65aa
@ -0,0 +1,41 @@
|
|||||||
|
package io.github.thebusybiscuit.slimefun4.implementation.items.food;
|
||||||
|
|
||||||
|
import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
|
||||||
|
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||||
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||||
|
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
import javax.annotation.ParametersAreNonnullByDefault;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This {@link SlimefunItem} can be obtained by crafting, it's
|
||||||
|
* used for various foods and recipes
|
||||||
|
*
|
||||||
|
* @author TheSilentPro
|
||||||
|
*/
|
||||||
|
public class HeavyCream extends SimpleSlimefunItem<ItemUseHandler> {
|
||||||
|
|
||||||
|
@ParametersAreNonnullByDefault
|
||||||
|
public HeavyCream(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, ItemStack recipeOutput) {
|
||||||
|
super(category, item, recipeType, recipe, recipeOutput);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
@Override
|
||||||
|
public ItemUseHandler getItemHandler() {
|
||||||
|
return e -> {
|
||||||
|
Optional<Block> block = e.getClickedBlock();
|
||||||
|
|
||||||
|
if (!block.isPresent() || !block.get().getType().isInteractable()) {
|
||||||
|
e.cancel();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,17 +1,24 @@
|
|||||||
package io.github.thebusybiscuit.slimefun4.implementation.items.misc;
|
package io.github.thebusybiscuit.slimefun4.implementation.items.misc;
|
||||||
|
|
||||||
|
import org.bukkit.Tag;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Piglin;
|
import org.bukkit.entity.Piglin;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting;
|
import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting;
|
||||||
import io.github.thebusybiscuit.slimefun4.api.items.settings.IntRangeSetting;
|
import io.github.thebusybiscuit.slimefun4.api.items.settings.IntRangeSetting;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.attributes.PiglinBarterDrop;
|
import io.github.thebusybiscuit.slimefun4.core.attributes.PiglinBarterDrop;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.magical.VillagerRune;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.magical.VillagerRune;
|
||||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This {@link SlimefunItem} can only be obtained via bartering with a {@link Piglin}, its
|
* This {@link SlimefunItem} can only be obtained via bartering with a {@link Piglin}, its
|
||||||
* only current uses is the recipe for crafting the {@link VillagerRune}.
|
* only current uses is the recipe for crafting the {@link VillagerRune}.
|
||||||
@ -22,7 +29,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
|||||||
* @see PiglinBarterDrop
|
* @see PiglinBarterDrop
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class StrangeNetherGoo extends SlimefunItem implements PiglinBarterDrop {
|
public class StrangeNetherGoo extends SimpleSlimefunItem<ItemUseHandler> implements PiglinBarterDrop {
|
||||||
|
|
||||||
private final ItemSetting<Integer> chance = new IntRangeSetting("barter-chance", 0, 7, 100);
|
private final ItemSetting<Integer> chance = new IntRangeSetting("barter-chance", 0, 7, 100);
|
||||||
|
|
||||||
@ -37,4 +44,16 @@ public class StrangeNetherGoo extends SlimefunItem implements PiglinBarterDrop {
|
|||||||
return chance.getValue();
|
return chance.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
@Override
|
||||||
|
public ItemUseHandler getItemHandler() {
|
||||||
|
return e -> {
|
||||||
|
Optional<Block> block = e.getClickedBlock();
|
||||||
|
|
||||||
|
if (block.isPresent() && Tag.SIGNS.isTagged(block.get().getType())) {
|
||||||
|
e.cancel();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -115,6 +115,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.food.Juice;
|
|||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.food.MagicSugar;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.food.MagicSugar;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.food.MeatJerky;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.food.MeatJerky;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.food.MonsterJerky;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.food.MonsterJerky;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.implementation.items.food.HeavyCream;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.geo.GEOMiner;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.geo.GEOMiner;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.geo.GEOScanner;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.geo.GEOScanner;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.geo.OilPump;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.geo.OilPump;
|
||||||
@ -907,7 +908,7 @@ public final class SlimefunItemSetup {
|
|||||||
new ItemStack[] {new ItemStack(Material.SAND, 2), null, null, null, null, null, null, null, null})
|
new ItemStack[] {new ItemStack(Material.SAND, 2), null, null, null, null, null, null, null, null})
|
||||||
.register(plugin);
|
.register(plugin);
|
||||||
|
|
||||||
new SlimefunItem(categories.misc, SlimefunItems.HEAVY_CREAM, RecipeType.ENHANCED_CRAFTING_TABLE,
|
new HeavyCream(categories.misc, SlimefunItems.HEAVY_CREAM, RecipeType.ENHANCED_CRAFTING_TABLE,
|
||||||
new ItemStack[] {new ItemStack(Material.MILK_BUCKET), null, null, null, null, null, null, null, null},
|
new ItemStack[] {new ItemStack(Material.MILK_BUCKET), null, null, null, null, null, null, null, null},
|
||||||
new SlimefunItemStack(SlimefunItems.HEAVY_CREAM, 2))
|
new SlimefunItemStack(SlimefunItems.HEAVY_CREAM, 2))
|
||||||
.register(plugin);
|
.register(plugin);
|
||||||
|
Loading…
Reference in New Issue
Block a user