PaperMC/patches/api/0297-Add-BlockBreakBlockEvent.patch

70 lines
2 KiB
Diff
Raw Normal View History

2021-08-25 03:42:23 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Sun, 3 Jan 2021 17:58:25 -0800
Subject: [PATCH] Add BlockBreakBlockEvent
diff --git a/src/main/java/io/papermc/paper/event/block/BlockBreakBlockEvent.java b/src/main/java/io/papermc/paper/event/block/BlockBreakBlockEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..3b130d145f54939ad02e30b15c81120aac2078c2
2021-08-25 03:42:23 +02:00
--- /dev/null
+++ b/src/main/java/io/papermc/paper/event/block/BlockBreakBlockEvent.java
@@ -0,0 +1,57 @@
2021-08-25 03:42:23 +02:00
+package io.papermc.paper.event.block;
+
+import java.util.List;
2021-08-25 03:42:23 +02:00
+import org.bukkit.block.Block;
+import org.bukkit.event.HandlerList;
+import org.bukkit.event.block.BlockExpEvent;
2021-08-25 03:42:23 +02:00
+import org.bukkit.inventory.ItemStack;
2024-02-01 10:15:57 +01:00
+import org.jetbrains.annotations.ApiStatus;
+import org.jspecify.annotations.NullMarked;
2021-08-25 03:42:23 +02:00
+
+/**
+ * Called when a block forces another block to break and drop items.
+ * <p>
+ * Currently called for piston's and liquid flows.
+ */
+@NullMarked
+public class BlockBreakBlockEvent extends BlockExpEvent {
2021-08-25 03:42:23 +02:00
+
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ private final Block source;
2024-02-01 10:15:57 +01:00
+ private final List<ItemStack> drops;
2021-08-25 03:42:23 +02:00
+
2024-02-01 10:15:57 +01:00
+ @ApiStatus.Internal
+ public BlockBreakBlockEvent(final Block block, final Block source, final List<ItemStack> drops) {
+ super(block, 0);
2021-08-25 03:42:23 +02:00
+ this.source = source;
+ this.drops = drops;
+ }
+
+ /**
+ * Gets a mutable list of drops for this event
2021-08-25 03:42:23 +02:00
+ *
+ * @return the drops
+ */
+ public List<ItemStack> getDrops() {
2024-02-01 10:15:57 +01:00
+ return this.drops;
2021-08-25 03:42:23 +02:00
+ }
+
+ /**
+ * Gets the block that cause this (e.g. a piston, or adjacent liquid)
+ *
+ * @return the source
+ */
+ public Block getSource() {
2024-02-01 10:15:57 +01:00
+ return this.source;
2021-08-25 03:42:23 +02:00
+ }
+
+ @Override
+ public HandlerList getHandlers() {
+ return HANDLER_LIST;
+ }
+
+ public static HandlerList getHandlerList() {
+ return HANDLER_LIST;
+ }
+}