mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-19 19:25:48 +00:00
Added an item setting to configure the Wind Staff velocity
This commit is contained in:
parent
a18317295a
commit
64fd5a54c3
@ -31,6 +31,7 @@
|
||||
* Added a config option to disable network visualizations
|
||||
* (API) Added CoolerFeedPlayerEvent
|
||||
* Added a config option to delete excess cargo network items
|
||||
* Added an item setting to configure the Wind Staff velocity
|
||||
|
||||
#### Changes
|
||||
* Removed 1.13 support
|
||||
|
@ -8,6 +8,8 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||
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.implementation.SlimefunPlugin;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
|
||||
@ -15,10 +17,20 @@ import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
|
||||
/**
|
||||
* The {@link WindStaff} is a powerful staff which launches the {@link Player} forward when right clicked.
|
||||
*
|
||||
* @author TheBusyBiscuit
|
||||
*
|
||||
*/
|
||||
public class WindStaff extends SimpleSlimefunItem<ItemUseHandler> {
|
||||
|
||||
private final ItemSetting<Integer> multiplier = new IntRangeSetting("power", 1, 4, Integer.MAX_VALUE);
|
||||
|
||||
public WindStaff(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||
super(category, item, recipeType, recipe);
|
||||
|
||||
addItemSetting(multiplier);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -27,6 +39,7 @@ public class WindStaff extends SimpleSlimefunItem<ItemUseHandler> {
|
||||
Player p = e.getPlayer();
|
||||
|
||||
if (p.getFoodLevel() >= 2) {
|
||||
// The isItem() check is here to prevent the MultiTool from consuming hunger
|
||||
if (isItem(e.getItem()) && p.getGameMode() != GameMode.CREATIVE) {
|
||||
FoodLevelChangeEvent event = new FoodLevelChangeEvent(p, p.getFoodLevel() - 2);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
@ -36,7 +49,7 @@ public class WindStaff extends SimpleSlimefunItem<ItemUseHandler> {
|
||||
}
|
||||
}
|
||||
|
||||
p.setVelocity(p.getEyeLocation().getDirection().multiply(4));
|
||||
p.setVelocity(p.getEyeLocation().getDirection().multiply(multiplier.getValue()));
|
||||
p.getWorld().playSound(p.getLocation(), Sound.ENTITY_TNT_PRIMED, 1, 1);
|
||||
p.getWorld().playEffect(p.getLocation(), Effect.SMOKE, 1);
|
||||
p.setFallDistance(0F);
|
||||
|
Loading…
Reference in New Issue
Block a user