mirror of https://github.com/PaperMC/Paper.git
Merge d9e845b342
into 8f7ac62905
This commit is contained in:
commit
4ffb483aee
|
@ -0,0 +1,91 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: chmodsayshello <chmodsayshello@hotmail.com>
|
||||
Date: Wed, 1 Nov 2023 13:24:22 +0100
|
||||
Subject: [PATCH] add PlayerBrushBlockEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/event/player/PlayerBrushBlockEvent.java b/src/main/java/io/papermc/paper/event/player/PlayerBrushBlockEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..11a46a23e5f82162401698ebd9142170413b4a7b
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/event/player/PlayerBrushBlockEvent.java
|
||||
@@ -0,0 +1,79 @@
|
||||
+package io.papermc.paper.event.player;
|
||||
+
|
||||
+import org.bukkit.Material;
|
||||
+import org.bukkit.block.Block;
|
||||
+import org.bukkit.event.Cancellable;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.bukkit.event.player.PlayerEvent;
|
||||
+import org.bukkit.entity.Player;
|
||||
+import org.bukkit.inventory.ItemStack;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import org.jetbrains.annotations.Nullable;
|
||||
+
|
||||
+public class PlayerBrushBlockEvent extends PlayerEvent implements Cancellable {
|
||||
+ private static final HandlerList handlerList = new HandlerList();
|
||||
+ private boolean isCancelled = false;
|
||||
+ private final Block block;
|
||||
+ private ItemStack drop;
|
||||
+
|
||||
+ public PlayerBrushBlockEvent(final @NotNull Player player, @NotNull final Block block, @NotNull final ItemStack drop){
|
||||
+ super(player);
|
||||
+ this.block = block;
|
||||
+ this.drop = drop;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Get the block the player tries to brush
|
||||
+ *
|
||||
+ * @return The block being brushed
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public Block getBlock() {
|
||||
+ return this.block;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the drop from the block
|
||||
+ *
|
||||
+ * @return The Itemstack of the drop
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public ItemStack getDrop() {
|
||||
+ return this.drop;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the drop for the suspicious block
|
||||
+ *
|
||||
+ * @param drop The Itemstack to be dropped
|
||||
+ */
|
||||
+ public void setDrop(@NotNull final ItemStack drop) {
|
||||
+ this.drop = drop;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isCancelled() {
|
||||
+ return this.isCancelled;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Cancel the Event
|
||||
+ *
|
||||
+ * @param cancel if true, nothing will drop, and suspicious blocks will not turn into normal ones
|
||||
+ */
|
||||
+ @Override
|
||||
+ public void setCancelled(final boolean cancel) {
|
||||
+ this.isCancelled = cancel;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ @NotNull
|
||||
+ public HandlerList getHandlers() {
|
||||
+ return getHandlerList();
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ public static HandlerList getHandlerList() {
|
||||
+ return handlerList;
|
||||
+ }
|
||||
+}
|
|
@ -0,0 +1,29 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: chmodsayshello <chmodsayshello@hotmail.com>
|
||||
Date: Wed, 1 Nov 2023 14:01:08 +0100
|
||||
Subject: [PATCH] add PlayerBrushBlockEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/BrushableBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BrushableBlockEntity.java
|
||||
index 0425151e688966442340ea1cf892aff34ffe0791..bd21dc53ab35d9665c9687e71e4cf048f18b6807 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/BrushableBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/BrushableBlockEntity.java
|
||||
@@ -125,6 +125,18 @@ public class BrushableBlockEntity extends BlockEntity {
|
||||
|
||||
private void brushingCompleted(Player player) {
|
||||
if (this.level != null && this.level.getServer() != null) {
|
||||
+ // Paper start - PlayerBrushBlockEvent
|
||||
+ io.papermc.paper.event.player.PlayerBrushBlockEvent event = new io.papermc.paper.event.player.PlayerBrushBlockEvent(
|
||||
+ (org.bukkit.entity.Player) player.getBukkitEntity(),
|
||||
+ org.bukkit.craftbukkit.block.CraftBlock.at(this.getLevel(), this.getBlockPos()),
|
||||
+ item.asBukkitCopy()
|
||||
+ );
|
||||
+ event.callEvent();
|
||||
+ if(event.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ this.item = org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getDrop()); // Event allows to modify
|
||||
+ // Paper end
|
||||
this.dropContent(player);
|
||||
BlockState iblockdata = this.getBlockState();
|
||||
|
Loading…
Reference in New Issue