Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 12:30:06 +01:00
928bcc8d3a
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 09943450 Update SnakeYAML version 5515734f SPIGOT-7162: Incorrect description for Entity#getVehicle javadoc 6f82b381 PR-788: Add getHand() to all relevant events CraftBukkit Changes: aaf484f6f SPIGOT-7163: CraftMerchantRecipe doesn't copy demand and specialPrice from BukkitMerchantRecipe 5329dd6fd PR-1107: Add getHand() to all relevant events 93061706e SPIGOT-7045: Ocelots never spawn with babies with spawn reason OCELOT_BABY
82 Zeilen
2.7 KiB
Diff
82 Zeilen
2.7 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
|
|
Date: Wed, 25 Nov 2020 23:21:32 -0800
|
|
Subject: [PATCH] Add TargetHitEvent API
|
|
|
|
|
|
diff --git a/src/main/java/io/papermc/paper/event/block/TargetHitEvent.java b/src/main/java/io/papermc/paper/event/block/TargetHitEvent.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..cc067ae118af9957b1b9f5c8d45f63f9154f4942
|
|
--- /dev/null
|
|
+++ b/src/main/java/io/papermc/paper/event/block/TargetHitEvent.java
|
|
@@ -0,0 +1,69 @@
|
|
+package io.papermc.paper.event.block;
|
|
+
|
|
+import org.bukkit.block.Block;
|
|
+import org.bukkit.block.BlockFace;
|
|
+import org.bukkit.entity.Projectile;
|
|
+import org.bukkit.event.Cancellable;
|
|
+import org.bukkit.event.HandlerList;
|
|
+import org.bukkit.event.entity.ProjectileHitEvent;
|
|
+import org.jetbrains.annotations.NotNull;
|
|
+
|
|
+/**
|
|
+ * Called when a Target Block is hit by a projectile.
|
|
+ * <p>
|
|
+ * Cancelling this event will stop the Target from emitting a redstone signal,
|
|
+ * and in the case that the shooter is a player, will stop them from receiving
|
|
+ * advancement criteria.
|
|
+ */
|
|
+public class TargetHitEvent extends ProjectileHitEvent implements Cancellable {
|
|
+ private static final HandlerList handlers = new HandlerList();
|
|
+ private boolean cancelled;
|
|
+ private int signalStrength;
|
|
+
|
|
+ public TargetHitEvent(@NotNull Projectile projectile, @NotNull Block block, @NotNull BlockFace blockFace, int signalStrength) {
|
|
+ super(projectile, null, block, blockFace);
|
|
+ this.signalStrength = signalStrength;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean isCancelled() {
|
|
+ return cancelled;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void setCancelled(boolean cancelled) {
|
|
+ this.cancelled = cancelled;
|
|
+ }
|
|
+
|
|
+ @NotNull
|
|
+ @Override
|
|
+ public HandlerList getHandlers() {
|
|
+ return handlers;
|
|
+ }
|
|
+
|
|
+ @NotNull
|
|
+ public static HandlerList getHandlerList() {
|
|
+ return handlers;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Gets the strength of the redstone signal to be emitted by the Target block
|
|
+ *
|
|
+ * @return the strength of the redstone signal to be emitted
|
|
+ */
|
|
+ public int getSignalStrength() {
|
|
+ return signalStrength;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Sets the strength of the redstone signal to be emitted by the Target block
|
|
+ *
|
|
+ * @param signalStrength the strength of the redstone signal to be emitted
|
|
+ */
|
|
+ public void setSignalStrength(int signalStrength) {
|
|
+ if (signalStrength < 0 || signalStrength > 15) {
|
|
+ throw new IllegalArgumentException("Signal strength out of range (" + signalStrength + "), must be in range [0,15]");
|
|
+ }
|
|
+ this.signalStrength = signalStrength;
|
|
+ }
|
|
+}
|