mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-01 00:10:32 +01:00
89 lines
5.5 KiB
Diff
89 lines
5.5 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com>
|
|
Date: Sat, 29 Oct 2022 15:41:56 +0200
|
|
Subject: [PATCH] Call missing BlockDispenseEvent
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java b/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java
|
|
index 21bba99bf1f06a95cc6834de2886b03ebeb9562f..97cff1d1c92f3c06897c7ef5da612eca0ee49b2f 100644
|
|
--- a/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java
|
|
+++ b/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java
|
|
@@ -1106,6 +1106,13 @@ public interface DispenseItemBehavior {
|
|
this.setSuccess(true);
|
|
if (iblockdata.is(Blocks.RESPAWN_ANCHOR)) {
|
|
if ((Integer) iblockdata.getValue(RespawnAnchorBlock.CHARGE) != 4) {
|
|
+ // Paper start - Call missing BlockDispenseEvent
|
|
+ ItemStack result = org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockDispenseEvent(pointer, blockposition, stack, this);
|
|
+ if (result != null) {
|
|
+ this.setSuccess(false);
|
|
+ return result;
|
|
+ }
|
|
+ // Paper end - Call missing BlockDispenseEvent
|
|
RespawnAnchorBlock.charge((Entity) null, worldserver, blockposition, iblockdata);
|
|
stack.shrink(1);
|
|
} else {
|
|
@@ -1128,6 +1135,13 @@ public interface DispenseItemBehavior {
|
|
Optional<BlockState> optional = HoneycombItem.getWaxed(iblockdata);
|
|
|
|
if (optional.isPresent()) {
|
|
+ // Paper start - Call missing BlockDispenseEvent
|
|
+ ItemStack result = org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockDispenseEvent(pointer, blockposition, stack, this);
|
|
+ if (result != null) {
|
|
+ this.setSuccess(false);
|
|
+ return result;
|
|
+ }
|
|
+ // Paper end - Call missing BlockDispenseEvent
|
|
worldserver.setBlockAndUpdate(blockposition, (BlockState) optional.get());
|
|
worldserver.levelEvent(3003, blockposition, 0);
|
|
stack.shrink(1);
|
|
@@ -1153,6 +1167,12 @@ public interface DispenseItemBehavior {
|
|
if (!worldserver.getBlockState(blockposition1).is(BlockTags.CONVERTABLE_TO_MUD)) {
|
|
return this.defaultDispenseItemBehavior.dispense(pointer, stack);
|
|
} else {
|
|
+ // Paper start - Call missing BlockDispenseEvent
|
|
+ ItemStack result = org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockDispenseEvent(pointer, blockposition1, stack, this);
|
|
+ if (result != null) {
|
|
+ return result;
|
|
+ }
|
|
+ // Paper end - Call missing BlockDispenseEvent
|
|
if (!worldserver.isClientSide) {
|
|
for (int k = 0; k < 5; ++k) {
|
|
worldserver.sendParticles(ParticleTypes.SPLASH, (double) blockposition.getX() + worldserver.random.nextDouble(), (double) (blockposition.getY() + 1), (double) blockposition.getZ() + worldserver.random.nextDouble(), 1, 0.0D, 0.0D, 0.0D, 1.0D);
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
index 8e3799f0c778ae15169fadced83a84e6553a7bc0..3f8195475fbad4d517d5417ece9555831377d1cc 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
@@ -2098,6 +2098,32 @@ public class CraftEventFactory {
|
|
}
|
|
// Paper end
|
|
|
|
+ // Paper start - Call missing BlockDispenseEvent
|
|
+ @Nullable
|
|
+ public static ItemStack handleBlockDispenseEvent(net.minecraft.core.dispenser.BlockSource pointer, BlockPos to, ItemStack itemStack, net.minecraft.core.dispenser.DispenseItemBehavior instance) {
|
|
+ org.bukkit.block.Block bukkitBlock = pointer.level().getWorld().getBlockAt(pointer.pos().getX(), pointer.pos().getY(), pointer.pos().getZ());
|
|
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemStack.copyWithCount(1));
|
|
+
|
|
+ org.bukkit.event.block.BlockDispenseEvent event = new org.bukkit.event.block.BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(to.getX(), to.getY(), to.getZ()));
|
|
+ if (!net.minecraft.world.level.block.DispenserBlock.eventFired) {
|
|
+ if (!event.callEvent()) {
|
|
+ return itemStack;
|
|
+ }
|
|
+ }
|
|
+
|
|
+ if (!event.getItem().equals(craftItem)) {
|
|
+ // Chain to handler for new item
|
|
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
|
|
+ net.minecraft.core.dispenser.DispenseItemBehavior idispensebehavior = net.minecraft.world.level.block.DispenserBlock.DISPENSER_REGISTRY.get(eventStack.getItem());
|
|
+ if (idispensebehavior != net.minecraft.core.dispenser.DispenseItemBehavior.NOOP && idispensebehavior != instance) {
|
|
+ idispensebehavior.dispense(pointer, eventStack);
|
|
+ return itemStack;
|
|
+ }
|
|
+ }
|
|
+ return null;
|
|
+ }
|
|
+ // Paper end - Call missing BlockDispenseEvent
|
|
+
|
|
// Paper start - add EntityFertilizeEggEvent
|
|
/**
|
|
* Calls the io.papermc.paper.event.entity.EntityFertilizeEggEvent.
|