Skip to content

Commit 5b85ee3

Browse files
Fire CauldronLevelChange on initial fill (#7678)
1 parent fbbc03a commit 5b85ee3

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: Jake Potrebic <jake.m.potrebic@gmail.com>
3+
Date: Tue, 29 Mar 2022 13:46:23 -0700
4+
Subject: [PATCH] Fire CauldronLevelChange on initial fill
5+
6+
Also don't fire level events or game events if stalactite
7+
drip is cancelled
8+
9+
diff --git a/src/main/java/net/minecraft/world/level/block/CauldronBlock.java b/src/main/java/net/minecraft/world/level/block/CauldronBlock.java
10+
index dbae4f3b56d0290c6d28b9beaaa3b459754d43e3..18f4c422e8277b2f673202a598d81eabf5eea712 100644
11+
--- a/src/main/java/net/minecraft/world/level/block/CauldronBlock.java
12+
+++ b/src/main/java/net/minecraft/world/level/block/CauldronBlock.java
13+
@@ -36,10 +36,18 @@ public class CauldronBlock extends AbstractCauldronBlock {
14+
public void handlePrecipitation(BlockState state, Level world, BlockPos pos, Biome.Precipitation precipitation) {
15+
if (CauldronBlock.shouldHandlePrecipitation(world, precipitation)) {
16+
if (precipitation == Biome.Precipitation.RAIN) {
17+
- world.setBlockAndUpdate(pos, Blocks.WATER_CAULDRON.defaultBlockState());
18+
+ // Paper start - call event for initial fill
19+
+ if (!LayeredCauldronBlock.changeLevel(state, world, pos, Blocks.WATER_CAULDRON.defaultBlockState(), null, CauldronLevelChangeEvent.ChangeReason.NATURAL_FILL)) {
20+
+ return;
21+
+ }
22+
+ // Paper end
23+
world.gameEvent((Entity) null, GameEvent.FLUID_PLACE, pos);
24+
} else if (precipitation == Biome.Precipitation.SNOW) {
25+
- world.setBlockAndUpdate(pos, Blocks.POWDER_SNOW_CAULDRON.defaultBlockState());
26+
+ // Paper start - call event for initial fill
27+
+ if (!LayeredCauldronBlock.changeLevel(state, world, pos, Blocks.POWDER_SNOW_CAULDRON.defaultBlockState(), null, CauldronLevelChangeEvent.ChangeReason.NATURAL_FILL)) {
28+
+ return;
29+
+ }
30+
+ // Paper end
31+
world.gameEvent((Entity) null, GameEvent.FLUID_PLACE, pos);
32+
}
33+
34+
@@ -54,11 +62,19 @@ public class CauldronBlock extends AbstractCauldronBlock {
35+
@Override
36+
protected void receiveStalactiteDrip(BlockState state, Level world, BlockPos pos, Fluid fluid) {
37+
if (fluid == Fluids.WATER) {
38+
- LayeredCauldronBlock.changeLevel(state, world, pos, Blocks.WATER_CAULDRON.defaultBlockState(), null, CauldronLevelChangeEvent.ChangeReason.NATURAL_FILL); // CraftBukkit
39+
+ // Paper start - don't send level event or game event if cancelled
40+
+ if (!LayeredCauldronBlock.changeLevel(state, world, pos, Blocks.WATER_CAULDRON.defaultBlockState(), null, CauldronLevelChangeEvent.ChangeReason.NATURAL_FILL)) { // CraftBukkit
41+
+ return;
42+
+ }
43+
+ // Paper end
44+
world.levelEvent(1047, pos, 0);
45+
world.gameEvent((Entity) null, GameEvent.FLUID_PLACE, pos);
46+
} else if (fluid == Fluids.LAVA) {
47+
- LayeredCauldronBlock.changeLevel(state, world, pos, Blocks.LAVA_CAULDRON.defaultBlockState(), null, CauldronLevelChangeEvent.ChangeReason.NATURAL_FILL); // CraftBukkit
48+
+ // Paper start - don't send level event or game event if cancelled
49+
+ if (!LayeredCauldronBlock.changeLevel(state, world, pos, Blocks.LAVA_CAULDRON.defaultBlockState(), null, CauldronLevelChangeEvent.ChangeReason.NATURAL_FILL)) { // CraftBukkit
50+
+ return;
51+
+ }
52+
+ // Paper end
53+
world.levelEvent(1046, pos, 0);
54+
world.gameEvent((Entity) null, GameEvent.FLUID_PLACE, pos);
55+
}
56+
diff --git a/src/main/java/net/minecraft/world/level/block/LayeredCauldronBlock.java b/src/main/java/net/minecraft/world/level/block/LayeredCauldronBlock.java
57+
index e6ea389350cf391a87c4c388ed9a6325bdceb90d..c21b0e7265488f26179810ddb6a8a6992a2a4807 100644
58+
--- a/src/main/java/net/minecraft/world/level/block/LayeredCauldronBlock.java
59+
+++ b/src/main/java/net/minecraft/world/level/block/LayeredCauldronBlock.java
60+
@@ -89,7 +89,7 @@ public class LayeredCauldronBlock extends AbstractCauldronBlock {
61+
}
62+
63+
// CraftBukkit start
64+
- public static boolean changeLevel(BlockState iblockdata, Level world, BlockPos blockposition, BlockState newBlock, Entity entity, CauldronLevelChangeEvent.ChangeReason reason) {
65+
+ public static boolean changeLevel(BlockState iblockdata, Level world, BlockPos blockposition, BlockState newBlock, @javax.annotation.Nullable Entity entity, CauldronLevelChangeEvent.ChangeReason reason) { // Paper - entity is nullable
66+
CraftBlockState newState = CraftBlockStates.getBlockState(world, blockposition);
67+
newState.setData(newBlock);
68+

0 commit comments

Comments
 (0)