From 150258b7db71309adf642bdb7fb1a227f9178937 Mon Sep 17 00:00:00 2001 From: ybw0014 Date: Sun, 27 Aug 2023 23:44:45 -0400 Subject: [PATCH] feat: allow sword of beheading drop piglin heads --- .../items/weapons/SwordOfBeheading.java | 36 +++++++++++-------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/SwordOfBeheading.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/SwordOfBeheading.java index 42842880c..ef74985c7 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/SwordOfBeheading.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/SwordOfBeheading.java @@ -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 { private final ItemSetting chanceSkeleton = new IntRangeSetting(this, "chance.SKELETON", 0, 40, 100); private final ItemSetting chanceWitherSkeleton = new IntRangeSetting(this, "chance.WITHER_SKELETON", 0, 25, 100); private final ItemSetting chanceCreeper = new IntRangeSetting(this, "chance.CREEPER", 0, 40, 100); + private final ItemSetting chancePiglin = new IntRangeSetting(this, "chance.PIGLIN", 0, 40, 100); private final ItemSetting 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 { 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 { e.getDrops().add(skull); } - break; - default: - break; + } + default -> { + } } }; }