Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-20 21:40:06 +01:00
45 Zeilen
2.2 KiB
Diff
45 Zeilen
2.2 KiB
Diff
--- a/net/minecraft/server/DispenseBehaviorShulkerBox.java
|
|
+++ b/net/minecraft/server/DispenseBehaviorShulkerBox.java
|
|
@@ -1,5 +1,10 @@
|
|
package net.minecraft.server;
|
|
|
|
+// CraftBukkit start
|
|
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
|
+import org.bukkit.event.block.BlockDispenseEvent;
|
|
+// CraftBukkit end
|
|
+
|
|
public class DispenseBehaviorShulkerBox extends DispenseBehaviorMaybe {
|
|
|
|
public DispenseBehaviorShulkerBox() {}
|
|
@@ -14,6 +19,30 @@
|
|
BlockPosition blockposition = isourceblock.getBlockPosition().shift(enumdirection);
|
|
EnumDirection enumdirection1 = isourceblock.getWorld().isEmpty(blockposition.down()) ? enumdirection : EnumDirection.UP;
|
|
|
|
+ // CraftBukkit start
|
|
+ org.bukkit.block.Block bukkitBlock = isourceblock.getWorld().getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ());
|
|
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack);
|
|
+
|
|
+ BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockposition.getX(), blockposition.getY(), blockposition.getZ()));
|
|
+ if (!BlockDispenser.eventFired) {
|
|
+ isourceblock.getWorld().getServer().getPluginManager().callEvent(event);
|
|
+ }
|
|
+
|
|
+ if (event.isCancelled()) {
|
|
+ return itemstack;
|
|
+ }
|
|
+
|
|
+ if (!event.getItem().equals(craftItem)) {
|
|
+ // Chain to handler for new item
|
|
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
|
|
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem());
|
|
+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) {
|
|
+ idispensebehavior.dispense(isourceblock, eventStack);
|
|
+ return itemstack;
|
|
+ }
|
|
+ }
|
|
+ // CraftBukkit end
|
|
+
|
|
this.a(((ItemBlock) item).a((BlockActionContext) (new BlockActionContextDirectional(isourceblock.getWorld(), blockposition, enumdirection, itemstack, enumdirection1))).a());
|
|
}
|
|
|