2023-07-03 01:12:07 +02:00
|
|
|
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
|
2024-01-24 15:57:53 +01:00
|
|
|
index b83af374a33a66a6ceeca119b961eea883bba41c..175b965c92b8b8be9c671e1ee478afa9a2f7bf82 100644
|
2023-07-03 01:12:07 +02:00
|
|
|
--- a/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java
|
|
|
|
+++ b/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java
|
2024-01-24 15:57:53 +01:00
|
|
|
@@ -1112,6 +1112,13 @@ public interface DispenseItemBehavior {
|
2023-07-03 01:12:07 +02:00
|
|
|
this.setSuccess(true);
|
|
|
|
if (iblockdata.is(Blocks.RESPAWN_ANCHOR)) {
|
|
|
|
if ((Integer) iblockdata.getValue(RespawnAnchorBlock.CHARGE) != 4) {
|
2024-01-15 12:38:39 +01:00
|
|
|
+ // Paper start - Call missing BlockDispenseEvent
|
2023-07-03 01:12:07 +02:00
|
|
|
+ ItemStack result = org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockDispenseEvent(pointer, blockposition, stack, this);
|
|
|
|
+ if (result != null) {
|
|
|
|
+ this.setSuccess(false);
|
|
|
|
+ return result;
|
|
|
|
+ }
|
2024-01-15 12:38:39 +01:00
|
|
|
+ // Paper end - Call missing BlockDispenseEvent
|
2023-07-03 01:12:07 +02:00
|
|
|
RespawnAnchorBlock.charge((Entity) null, worldserver, blockposition, iblockdata);
|
|
|
|
stack.shrink(1);
|
|
|
|
} else {
|
2024-01-24 15:57:53 +01:00
|
|
|
@@ -1134,6 +1141,13 @@ public interface DispenseItemBehavior {
|
2023-07-03 01:12:07 +02:00
|
|
|
Optional<BlockState> optional = HoneycombItem.getWaxed(iblockdata);
|
|
|
|
|
|
|
|
if (optional.isPresent()) {
|
2024-01-15 12:38:39 +01:00
|
|
|
+ // Paper start - Call missing BlockDispenseEvent
|
2023-07-03 01:12:07 +02:00
|
|
|
+ ItemStack result = org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockDispenseEvent(pointer, blockposition, stack, this);
|
|
|
|
+ if (result != null) {
|
|
|
|
+ this.setSuccess(false);
|
|
|
|
+ return result;
|
|
|
|
+ }
|
2024-01-15 12:38:39 +01:00
|
|
|
+ // Paper end - Call missing BlockDispenseEvent
|
2023-07-03 01:12:07 +02:00
|
|
|
worldserver.setBlockAndUpdate(blockposition, (BlockState) optional.get());
|
|
|
|
worldserver.levelEvent(3003, blockposition, 0);
|
|
|
|
stack.shrink(1);
|
2024-01-24 15:57:53 +01:00
|
|
|
@@ -1159,6 +1173,12 @@ public interface DispenseItemBehavior {
|
2023-07-03 01:12:07 +02:00
|
|
|
if (!worldserver.getBlockState(blockposition1).is(BlockTags.CONVERTABLE_TO_MUD)) {
|
|
|
|
return this.defaultDispenseItemBehavior.dispense(pointer, stack);
|
|
|
|
} else {
|
2024-01-15 12:38:39 +01:00
|
|
|
+ // Paper start - Call missing BlockDispenseEvent
|
2023-07-03 01:12:07 +02:00
|
|
|
+ ItemStack result = org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockDispenseEvent(pointer, blockposition1, stack, this);
|
|
|
|
+ if (result != null) {
|
|
|
|
+ return result;
|
|
|
|
+ }
|
2024-01-15 12:38:39 +01:00
|
|
|
+ // Paper end - Call missing BlockDispenseEvent
|
2023-07-03 01:12:07 +02:00
|
|
|
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
|
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#10277)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing
Bukkit Changes:
9a80d38c SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-722: Add EntityRemoveEvent
258086d9 SPIGOT-7417, PR-967: Add Sign#getTargetSide and Sign#getAllowedEditor
ffaba051 SPIGOT-7584: Add missing Tag.ITEMS_NON_FLAMMABLE_WOOD
CraftBukkit Changes:
98b6c1ac7 SPIGOT-7589 Fix NullPointerException when bans expire
a2736ddb0 SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-1008: Add EntityRemoveEvent
5bf12cb89 SPIGOT-7565: Throw a more descriptive error message when a developer tries to spawn an entity from a CraftBukkit class
76d95fe7e SPIGOT-7417, PR-1343: Add Sign#getTargetSide and Sign#getAllowedEditor
Spigot Changes:
e9ec5485 Rebuild patches
f1b62e0c Rebuild patches
2024-02-23 14:37:33 +01:00
|
|
|
index 52c1d39f494ba441bc93382d895679bcd15fcbde..cd6ee371910328d4ab6f4a018fa0e4a48dbc7982 100644
|
2023-07-03 01:12:07 +02:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#10277)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing
Bukkit Changes:
9a80d38c SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-722: Add EntityRemoveEvent
258086d9 SPIGOT-7417, PR-967: Add Sign#getTargetSide and Sign#getAllowedEditor
ffaba051 SPIGOT-7584: Add missing Tag.ITEMS_NON_FLAMMABLE_WOOD
CraftBukkit Changes:
98b6c1ac7 SPIGOT-7589 Fix NullPointerException when bans expire
a2736ddb0 SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-1008: Add EntityRemoveEvent
5bf12cb89 SPIGOT-7565: Throw a more descriptive error message when a developer tries to spawn an entity from a CraftBukkit class
76d95fe7e SPIGOT-7417, PR-1343: Add Sign#getTargetSide and Sign#getAllowedEditor
Spigot Changes:
e9ec5485 Rebuild patches
f1b62e0c Rebuild patches
2024-02-23 14:37:33 +01:00
|
|
|
@@ -2109,6 +2109,32 @@ public class CraftEventFactory {
|
2023-07-03 01:12:07 +02:00
|
|
|
}
|
|
|
|
// Paper end
|
|
|
|
|
2024-01-15 12:38:39 +01:00
|
|
|
+ // Paper start - Call missing BlockDispenseEvent
|
2023-07-03 01:12:07 +02:00
|
|
|
+ @Nullable
|
2023-09-22 19:31:02 +02:00
|
|
|
+ public static ItemStack handleBlockDispenseEvent(net.minecraft.core.dispenser.BlockSource pointer, BlockPos to, ItemStack itemStack, net.minecraft.core.dispenser.DispenseItemBehavior instance) {
|
2024-02-01 10:15:57 +01:00
|
|
|
+ org.bukkit.block.Block bukkitBlock = CraftBlock.at(pointer.level(), pointer.pos());
|
2023-07-03 01:12:07 +02:00
|
|
|
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemStack.copyWithCount(1));
|
|
|
|
+
|
2024-02-01 10:15:57 +01:00
|
|
|
+ org.bukkit.event.block.BlockDispenseEvent event = new org.bukkit.event.block.BlockDispenseEvent(bukkitBlock, craftItem.clone(), CraftVector.toBukkit(to));
|
2023-07-03 01:12:07 +02:00
|
|
|
+ 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());
|
2024-02-01 10:15:57 +01:00
|
|
|
+ net.minecraft.core.dispenser.DispenseItemBehavior itemBehavior = net.minecraft.world.level.block.DispenserBlock.DISPENSER_REGISTRY.get(eventStack.getItem());
|
|
|
|
+ if (itemBehavior != net.minecraft.core.dispenser.DispenseItemBehavior.NOOP && itemBehavior != instance) {
|
|
|
|
+ itemBehavior.dispense(pointer, eventStack);
|
2023-07-03 01:12:07 +02:00
|
|
|
+ return itemStack;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return null;
|
|
|
|
+ }
|
2024-01-15 12:38:39 +01:00
|
|
|
+ // Paper end - Call missing BlockDispenseEvent
|
2023-07-03 01:12:07 +02:00
|
|
|
+
|
|
|
|
// Paper start - add EntityFertilizeEggEvent
|
|
|
|
/**
|
2024-02-01 10:15:57 +01:00
|
|
|
* Calls the {@link io.papermc.paper.event.entity.EntityFertilizeEggEvent}.
|