1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-19 19:25:48 +00:00

Merge pull request #2435 from TheSilentPro/master fixes #2420 fixes #2422

Stop unwanted actions from StrangeNetherGoo and Heavy Cream
This commit is contained in:
TheBusyBiscuit 2020-10-11 13:46:40 +02:00 committed by GitHub
commit 15884c65aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 63 additions and 2 deletions

View File

@ -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();
}
};
}
}

View File

@ -1,17 +1,24 @@
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.inventory.ItemStack;
import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting;
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.implementation.items.SimpleSlimefunItem;
import io.github.thebusybiscuit.slimefun4.implementation.items.magical.VillagerRune;
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 javax.annotation.Nonnull;
import java.util.Optional;
/**
* 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}.
@ -22,7 +29,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
* @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);
@ -37,4 +44,16 @@ public class StrangeNetherGoo extends SlimefunItem implements PiglinBarterDrop {
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();
}
};
}
}

View File

@ -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.MeatJerky;
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.GEOScanner;
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})
.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 SlimefunItemStack(SlimefunItems.HEAVY_CREAM, 2))
.register(plugin);