2020-11-28 23:38:52 +00:00
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/server/BlockDispenser.java b/src/main/java/net/minecraft/server/BlockDispenser.java
index c239265581972d67c7567d7545d62499ebadd195..063453552b7b6c2395c8f9be27cdb71a15a56ca4 100644
--- a/src/main/java/net/minecraft/server/BlockDispenser.java
+++ b/src/main/java/net/minecraft/server/BlockDispenser.java
@@ -48,6 +48,7 @@ public class BlockDispenser extends BlockTileEntity {
int i = tileentitydispenser.h();
if (i < 0) {
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFailedDispenseEvent(worldserver, blockposition)) // Paper - BlockFailedDispenseEvent is called here
worldserver.triggerEffect(1001, blockposition, 0);
} else {
ItemStack itemstack = tileentitydispenser.getItem(i);
diff --git a/src/main/java/net/minecraft/server/BlockDropper.java b/src/main/java/net/minecraft/server/BlockDropper.java
index 65c212690d8ba7c8ea55d4d3b6af1ba3d9f4a7f6..22ab5a861920e1902c64301c3b06cf95b7afe378 100644
--- a/src/main/java/net/minecraft/server/BlockDropper.java
+++ b/src/main/java/net/minecraft/server/BlockDropper.java
@@ -30,6 +30,7 @@ public class BlockDropper extends BlockDispenser {
int i = tileentitydispenser.h();
if (i < 0) {
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFailedDispenseEvent(worldserver, blockposition)) // Paper - BlockFailedDispenseEvent is called here
worldserver.triggerEffect(1001, blockposition, 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
2021-03-03 22:43:45 +00:00
index 71aead62d776b4241295835510dff17726054ef6..1e00be94d745afd499bd03857d85fd1ae0839538 100644
2020-11-28 23:38:52 +00:00
--- 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;
2021-02-21 20:55:01 +00:00
@@ -117,7 +118,6 @@ import org.bukkit.entity.ThrownPotion;
2020-11-28 23:38:52 +00:00
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;
2021-03-03 22:43:45 +00:00
@@ -1760,4 +1760,12 @@ public class CraftEventFactory {
2020-11-28 23:38:52 +00:00
return event;
}
+
+ // Paper start
+ public static boolean handleBlockFailedDispenseEvent(WorldServer worldserver, BlockPosition 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
}