PaperMC/patches/server-remapped/0638-Implemented-BlockFailedDispenseEvent.patch
Mariell Hoversholm a207d14a0e
Rename all patches to correct numbering scheme
Signed-off-by: Mariell Hoversholm <proximyst@proximyst.com>
2021-06-11 15:46:44 +02:00

63 lines
3.4 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: TheViperShow <29604693+TheViperShow@users.noreply.github.com>
Date: Wed, 22 Apr 2020 09:40:38 +0200
Subject: [PATCH] Implemented BlockFailedDispenseEvent
diff --git a/src/main/java/net/minecraft/world/level/block/DispenserBlock.java b/src/main/java/net/minecraft/world/level/block/DispenserBlock.java
index bfb2e21ccbcc67d6c9b4b329db1949d7d938bd2e..2a4cb76bdfcf55ba222b4976359c1b8efb165009 100644
--- a/src/main/java/net/minecraft/world/level/block/DispenserBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/DispenserBlock.java
@@ -81,6 +81,7 @@ public class DispenserBlock extends BaseEntityBlock {
int i = tileentitydispenser.getRandomSlot();
if (i < 0) {
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFailedDispenseEvent(worldserver, pos)) // Paper - BlockFailedDispenseEvent is called here
worldserver.levelEvent(1001, pos, 0);
} else {
ItemStack itemstack = tileentitydispenser.getItem(i);
diff --git a/src/main/java/net/minecraft/world/level/block/DropperBlock.java b/src/main/java/net/minecraft/world/level/block/DropperBlock.java
index 154ec671e9d741e536464b794783da859e8447c1..492b19b94e2e2439f72ed9478d75641b0f50451a 100644
--- a/src/main/java/net/minecraft/world/level/block/DropperBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/DropperBlock.java
@@ -45,6 +45,7 @@ public class DropperBlock extends DispenserBlock {
int i = tileentitydispenser.getRandomSlot();
if (i < 0) {
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFailedDispenseEvent(worldserver, pos)) // Paper - BlockFailedDispenseEvent is called here
worldserver.levelEvent(1001, pos, 0);
} else {
ItemStack itemstack = tileentitydispenser.getItem(i);
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
index 34c7b1213b3f83ff1a1f2d606a9c25e57fea8ef3..8829ef03d0be16d8317aaf05bcd286b74f20656a 100644
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
@@ -4,6 +4,7 @@ import com.google.common.base.Function;
import com.google.common.base.Functions;
import com.google.common.collect.Lists;
import com.mojang.datafixers.util.Either;
+import io.papermc.paper.event.block.BlockFailedDispenseEvent;
import java.net.InetAddress;
import java.util.ArrayList;
import java.util.Collections;
@@ -111,7 +112,6 @@ import org.bukkit.entity.ThrownPotion;
import org.bukkit.entity.Vehicle;
import org.bukkit.entity.Villager;
import org.bukkit.entity.Villager.Profession;
-import org.bukkit.entity.ExperienceOrb; // Paper
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.Event.Result;
@@ -1784,4 +1784,12 @@ public class CraftEventFactory {
Bukkit.getPluginManager().callEvent(event);
return event;
}
+
+ // Paper start
+ public static boolean handleBlockFailedDispenseEvent(ServerLevel worldserver, BlockPos blockposition) {
+ org.bukkit.block.Block block = worldserver.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
+ BlockFailedDispenseEvent event = new BlockFailedDispenseEvent(block);
+ return event.callEvent();
+ }
+ // Paper end
}