Skip to content

Commit 7e789e8

Browse files
authored
Prevent duplicate/superfluous BlockPhysicsEvent (PaperMC#11609)
1 parent f4741f2 commit 7e789e8

File tree

2 files changed

+42
-32
lines changed

2 files changed

+42
-32
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: Lulu13022002 <[email protected]>
3+
Date: Sun, 7 Aug 2022 22:16:36 +0200
4+
Subject: [PATCH] Add source block to BlockPhysicsEvent
5+
6+
7+
diff --git a/src/main/java/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java b/src/main/java/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java
8+
index 5821c802ec880501df025fcd3fbbd98242ed952c..3a95e3236eafd14baed035e53503b58c2e21b68a 100644
9+
--- a/src/main/java/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java
10+
+++ b/src/main/java/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java
11+
@@ -135,7 +135,7 @@ public class CollectingNeighborUpdater implements NeighborUpdater {
12+
orientation = this.orientation.withFront(direction);
13+
}
14+
15+
- NeighborUpdater.executeUpdate(world, blockState, blockPos, this.sourceBlock, orientation, false);
16+
+ NeighborUpdater.executeUpdate(world, blockState, blockPos, this.sourceBlock, orientation, false, this.sourcePos); // Paper - Add source block to BlockPhysicsEvent
17+
if (this.idx < NeighborUpdater.UPDATE_ORDER.length && NeighborUpdater.UPDATE_ORDER[this.idx] == this.skipDirection) {
18+
this.idx++;
19+
}
20+
diff --git a/src/main/java/net/minecraft/world/level/redstone/NeighborUpdater.java b/src/main/java/net/minecraft/world/level/redstone/NeighborUpdater.java
21+
index be8f34dd222e43b2db7f05e5e5839df8446e1b02..e414da8a51bb9b49c28a74eca166046cbee44835 100644
22+
--- a/src/main/java/net/minecraft/world/level/redstone/NeighborUpdater.java
23+
+++ b/src/main/java/net/minecraft/world/level/redstone/NeighborUpdater.java
24+
@@ -55,11 +55,17 @@ public interface NeighborUpdater {
25+
}
26+
27+
static void executeUpdate(Level world, BlockState state, BlockPos pos, Block sourceBlock, @Nullable Orientation orientation, boolean notify) {
28+
+ // Paper start - Add source block to BlockPhysicsEvent
29+
+ executeUpdate(world, state, pos, sourceBlock, orientation, notify, pos);
30+
+ }
31+
+
32+
+ static void executeUpdate(Level world, BlockState state, BlockPos pos, Block sourceBlock, @Nullable Orientation orientation, boolean notify, BlockPos sourcePos) {
33+
+ // Paper end - Add source block to BlockPhysicsEvent
34+
try {
35+
// CraftBukkit start
36+
CraftWorld cworld = ((ServerLevel) world).getWorld();
37+
if (cworld != null) {
38+
- BlockPhysicsEvent event = new BlockPhysicsEvent(CraftBlock.at(world, pos), CraftBlockData.fromData(state));
39+
+ BlockPhysicsEvent event = new BlockPhysicsEvent(CraftBlock.at(world, pos), CraftBlockData.fromData(state), CraftBlock.at(world, sourcePos)); // Paper - Add source block to BlockPhysicsEvent
40+
((ServerLevel) world).getCraftServer().getPluginManager().callEvent(event);
41+
42+
if (event.isCancelled()) {

patches/server/0732-Call-BlockPhysicsEvent-more-often.patch

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)