diff --git a/patches/api/0007-Add-PreEntityShootBowEvent.patch b/patches/api/0007-Add-PreEntityShootBowEvent.patch new file mode 100644 index 0000000..86a55fb --- /dev/null +++ b/patches/api/0007-Add-PreEntityShootBowEvent.patch @@ -0,0 +1,94 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: MrPowerGamerBR +Date: Sun, 12 Jan 2025 23:27:00 -0300 +Subject: [PATCH] Add PreEntityShootBowEvent + + +diff --git a/src/main/java/net/sparklypower/sparklypaper/event/entity/PreEntityShootBowEvent.java b/src/main/java/net/sparklypower/sparklypaper/event/entity/PreEntityShootBowEvent.java +new file mode 100644 +index 0000000000000000000000000000000000000000..1438ad2444db2b19fd84f5147f0b68b5df7f13dc +--- /dev/null ++++ b/src/main/java/net/sparklypower/sparklypaper/event/entity/PreEntityShootBowEvent.java +@@ -0,0 +1,82 @@ ++package net.sparklypower.sparklypaper.event.entity; ++ ++import org.bukkit.entity.HumanEntity; ++import org.bukkit.event.Cancellable; ++import org.bukkit.event.HandlerList; ++import org.bukkit.event.entity.EntityEvent; ++import org.bukkit.inventory.EquipmentSlot; ++import org.bukkit.inventory.ItemStack; ++import org.jetbrains.annotations.NotNull; ++import org.jetbrains.annotations.Nullable; ++ ++/** ++ * Called when a entity releases a bow, before the projectile is spawned ++ *

++ * Compared to EntityShootBowEvent, this event is called before the projectile is spawned, before the force check is done, and before the bow release sound is played. ++ *

++ * Currently this event is only called for players! To be more specific, it is only called for HumanEntity!! ++ */ ++public class PreEntityShootBowEvent extends EntityEvent implements Cancellable { ++ private static final HandlerList handlers = new HandlerList(); ++ private final ItemStack bow; ++ private final EquipmentSlot hand; ++ private final float force; ++ private boolean cancelled; ++ ++ public PreEntityShootBowEvent(@NotNull final HumanEntity shooter, @Nullable final ItemStack bow, @NotNull final EquipmentSlot hand, final float force) { ++ super(shooter); ++ this.bow = bow; ++ this.hand = hand; ++ this.force = force; ++ } ++ ++ /** ++ * Gets the bow ItemStack used to fire the arrow. ++ * ++ * @return the bow involved in this event ++ */ ++ @Nullable ++ public ItemStack getBow() { ++ return bow; ++ } ++ ++ /** ++ * Get the hand from which the bow was shot. ++ * ++ * @return the hand ++ */ ++ @NotNull ++ public EquipmentSlot getHand() { ++ return hand; ++ } ++ ++ /** ++ * Gets the force the arrow was launched with ++ * ++ * @return bow shooting force, up to 1.0 ++ */ ++ public float getForce() { ++ return force; ++ } ++ ++ @Override ++ public boolean isCancelled() { ++ return cancelled; ++ } ++ ++ @Override ++ public void setCancelled(boolean cancel) { ++ cancelled = cancel; ++ } ++ ++ @NotNull ++ @Override ++ public HandlerList getHandlers() { ++ return handlers; ++ } ++ ++ @NotNull ++ public static HandlerList getHandlerList() { ++ return handlers; ++ } ++} diff --git a/patches/api/0006-SPARKLYPOWER-Add-custom-blocks.patch b/patches/api/0008-SPARKLYPOWER-Add-custom-blocks.patch similarity index 100% rename from patches/api/0006-SPARKLYPOWER-Add-custom-blocks.patch rename to patches/api/0008-SPARKLYPOWER-Add-custom-blocks.patch diff --git a/patches/server/0025-Add-PreEntityShootBowEvent.patch b/patches/server/0025-Add-PreEntityShootBowEvent.patch new file mode 100644 index 0000000..b7603f6 --- /dev/null +++ b/patches/server/0025-Add-PreEntityShootBowEvent.patch @@ -0,0 +1,22 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: MrPowerGamerBR +Date: Sun, 12 Jan 2025 23:26:44 -0300 +Subject: [PATCH] Add PreEntityShootBowEvent + + +diff --git a/src/main/java/net/minecraft/world/item/BowItem.java b/src/main/java/net/minecraft/world/item/BowItem.java +index bb593209c95c9cf1f9c5d52d52fab4a33ddbabcf..776c37284e9cff50fae6b937cb707e7ba7edc624 100644 +--- a/src/main/java/net/minecraft/world/item/BowItem.java ++++ b/src/main/java/net/minecraft/world/item/BowItem.java +@@ -33,6 +33,11 @@ public class BowItem extends ProjectileWeaponItem { + } else { + int i = this.getUseDuration(stack, user) - remainingUseTicks; + float f = getPowerForTime(i); ++ // SparklyPaper start - Add PreEntityShootBowEvent ++ net.sparklypower.sparklypaper.event.entity.PreEntityShootBowEvent event = new net.sparklypower.sparklypaper.event.entity.PreEntityShootBowEvent(player.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(stack), player.getUsedItemHand() == InteractionHand.MAIN_HAND ? org.bukkit.inventory.EquipmentSlot.HAND : org.bukkit.inventory.EquipmentSlot.OFF_HAND, f); ++ if (!event.callEvent()) ++ return false; ++ // SparklyPaper end + if ((double)f < 0.1) { + return false; + } else { diff --git a/patches/server/0025-Parallel-world-ticking.patch b/patches/server/0026-Parallel-world-ticking.patch similarity index 100% rename from patches/server/0025-Parallel-world-ticking.patch rename to patches/server/0026-Parallel-world-ticking.patch diff --git a/patches/server/0026-SPARKLYPOWER-Remap-SparklyPower-hacky-legacy-NBT-tag.patch b/patches/server/0027-SPARKLYPOWER-Remap-SparklyPower-hacky-legacy-NBT-tag.patch similarity index 100% rename from patches/server/0026-SPARKLYPOWER-Remap-SparklyPower-hacky-legacy-NBT-tag.patch rename to patches/server/0027-SPARKLYPOWER-Remap-SparklyPower-hacky-legacy-NBT-tag.patch diff --git a/patches/server/0027-SPARKLYPOWER-Add-custom-blocks.patch b/patches/server/0028-SPARKLYPOWER-Add-custom-blocks.patch similarity index 100% rename from patches/server/0027-SPARKLYPOWER-Add-custom-blocks.patch rename to patches/server/0028-SPARKLYPOWER-Add-custom-blocks.patch