-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Correctly check if bucket dispenses will succeed for event (#10109)
- Loading branch information
1 parent
1281f4f
commit 983377b
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
patches/server/1058-Correctly-check-if-bucket-dispenses-will-succeed-for.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: Jake Potrebic <jake.m.potrebic@gmail.com> | ||
Date: Mon, 1 Jan 2024 12:57:19 -0800 | ||
Subject: [PATCH] Correctly check if bucket dispenses will succeed for event | ||
|
||
Upstream incorrectly checks if the bucket place will succeed | ||
in order to fire the BlockDispenseEvent. This patch corrects | ||
that. | ||
|
||
diff --git a/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java b/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java | ||
index e6ac20a38f31bb0cd6b8840b2518f6992ef7f518..175715cd53941b14ec517e4ba7606498b664a369 100644 | ||
--- a/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java | ||
+++ b/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java | ||
@@ -628,7 +628,13 @@ public interface DispenseItemBehavior { | ||
int y = blockposition.getY(); | ||
int z = blockposition.getZ(); | ||
BlockState iblockdata = worldserver.getBlockState(blockposition); | ||
- if (iblockdata.isAir() || iblockdata.canBeReplaced() || (dispensiblecontaineritem instanceof BucketItem && iblockdata.getBlock() instanceof LiquidBlockContainer && ((LiquidBlockContainer) iblockdata.getBlock()).canPlaceLiquid((Player) null, worldserver, blockposition, iblockdata, ((BucketItem) dispensiblecontaineritem).content))) { | ||
+ // Paper start - correctly check if the bucket place will succeed | ||
+ /* Taken from SolidBucketItem#emptyContents */ | ||
+ boolean willEmptyContentsSolidBucketItem = dispensiblecontaineritem instanceof net.minecraft.world.item.SolidBucketItem && worldserver.isInWorldBounds(blockposition) && iblockdata.isAir(); | ||
+ /* Take from BucketItem#emptyContents */ | ||
+ boolean willEmptyBucketItem = dispensiblecontaineritem instanceof final BucketItem bucketItem && bucketItem.content instanceof net.minecraft.world.level.material.FlowingFluid && (iblockdata.isAir() || iblockdata.canBeReplaced(bucketItem.content) || (iblockdata.getBlock() instanceof LiquidBlockContainer liquidBlockContainer && liquidBlockContainer.canPlaceLiquid(null, worldserver, blockposition, iblockdata, bucketItem.content))); | ||
+ if (willEmptyContentsSolidBucketItem || willEmptyBucketItem) { | ||
+ // Paper end - correctly check if the bucket place will succeed | ||
org.bukkit.block.Block block = CraftBlock.at(worldserver, pointer.pos()); | ||
CraftItemStack craftItem = CraftItemStack.asCraftMirror(stack.copyWithCount(1)); // Paper - single item in event | ||
|