-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fa1fd9d
commit 3e8eff8
Showing
6 changed files
with
116 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: MrPowerGamerBR <[email protected]> | ||
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 | ||
+ * <p> | ||
+ * 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. | ||
+ * <p> | ||
+ * 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; | ||
+ } | ||
+} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: MrPowerGamerBR <[email protected]> | ||
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 { |
File renamed without changes.
File renamed without changes.
File renamed without changes.