mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-19 19:25:48 +00:00
feat: allow sword of beheading drop piglin heads
This commit is contained in:
parent
baef038179
commit
150258b7db
@ -8,6 +8,7 @@ import javax.annotation.ParametersAreNonnullByDefault;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Creeper;
|
||||
import org.bukkit.entity.Monster;
|
||||
import org.bukkit.entity.Piglin;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Skeleton;
|
||||
import org.bukkit.entity.WitherSkeleton;
|
||||
@ -26,7 +27,8 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunIte
|
||||
|
||||
/**
|
||||
* The {@link SwordOfBeheading} is a special kind of sword which allows you to obtain
|
||||
* {@link Zombie}, {@link Skeleton} and {@link Creeper} skulls when killing the respective {@link Monster}.
|
||||
* {@link Zombie}, {@link Skeleton}, {@link Creeper} and {@link Piglin} skulls when killing the respective
|
||||
* {@link Monster}.
|
||||
* Additionally, you can also obtain the head of a {@link Player} by killing them too.
|
||||
* This sword also allows you to have a higher chance of getting the skull of a {@link WitherSkeleton} too.
|
||||
*
|
||||
@ -41,13 +43,14 @@ public class SwordOfBeheading extends SimpleSlimefunItem<EntityKillHandler> {
|
||||
private final ItemSetting<Integer> chanceSkeleton = new IntRangeSetting(this, "chance.SKELETON", 0, 40, 100);
|
||||
private final ItemSetting<Integer> chanceWitherSkeleton = new IntRangeSetting(this, "chance.WITHER_SKELETON", 0, 25, 100);
|
||||
private final ItemSetting<Integer> chanceCreeper = new IntRangeSetting(this, "chance.CREEPER", 0, 40, 100);
|
||||
private final ItemSetting<Integer> chancePiglin = new IntRangeSetting(this, "chance.PIGLIN", 0, 40, 100);
|
||||
private final ItemSetting<Integer> chancePlayer = new IntRangeSetting(this, "chance.PLAYER", 0, 70, 100);
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
public SwordOfBeheading(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||
super(itemGroup, item, recipeType, recipe);
|
||||
|
||||
addItemSetting(chanceZombie, chanceSkeleton, chanceWitherSkeleton, chanceCreeper, chancePlayer);
|
||||
addItemSetting(chanceZombie, chanceSkeleton, chanceWitherSkeleton, chanceCreeper, chancePiglin, chancePlayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -56,27 +59,32 @@ public class SwordOfBeheading extends SimpleSlimefunItem<EntityKillHandler> {
|
||||
Random random = ThreadLocalRandom.current();
|
||||
|
||||
switch (e.getEntityType()) {
|
||||
case ZOMBIE:
|
||||
case ZOMBIE -> {
|
||||
if (random.nextInt(100) < chanceZombie.getValue()) {
|
||||
e.getDrops().add(new ItemStack(Material.ZOMBIE_HEAD));
|
||||
}
|
||||
break;
|
||||
case SKELETON:
|
||||
}
|
||||
case SKELETON -> {
|
||||
if (random.nextInt(100) < chanceSkeleton.getValue()) {
|
||||
e.getDrops().add(new ItemStack(Material.SKELETON_SKULL));
|
||||
}
|
||||
break;
|
||||
case CREEPER:
|
||||
}
|
||||
case CREEPER -> {
|
||||
if (random.nextInt(100) < chanceCreeper.getValue()) {
|
||||
e.getDrops().add(new ItemStack(Material.CREEPER_HEAD));
|
||||
}
|
||||
break;
|
||||
case WITHER_SKELETON:
|
||||
}
|
||||
case WITHER_SKELETON -> {
|
||||
if (random.nextInt(100) < chanceWitherSkeleton.getValue()) {
|
||||
e.getDrops().add(new ItemStack(Material.WITHER_SKELETON_SKULL));
|
||||
}
|
||||
break;
|
||||
case PLAYER:
|
||||
}
|
||||
case PIGLIN -> {
|
||||
if (random.nextInt(100) < chancePiglin.getValue()) {
|
||||
e.getDrops().add(new ItemStack(Material.PIGLIN_HEAD));
|
||||
}
|
||||
}
|
||||
case PLAYER -> {
|
||||
if (random.nextInt(100) < chancePlayer.getValue()) {
|
||||
ItemStack skull = new ItemStack(Material.PLAYER_HEAD);
|
||||
|
||||
@ -86,9 +94,9 @@ public class SwordOfBeheading extends SimpleSlimefunItem<EntityKillHandler> {
|
||||
|
||||
e.getDrops().add(skull);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
default -> {
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user