Files
Lophine/lophine-server/minecraft-patches/features/0127-PCA-sync-protocol.patch
T
Bacteriawa a9f3c2c291 Fix PCA sync protocol for async portal transfers #166
Update the PCA sync protocol patch to use getHandleRaw() instead of getHandle() when syncing entities to clients. This ensures proper ownership checking when the owner is a destination-world clone being restored during an async portal transfer.
2026-08-10 18:09:24 +08:00

79 lines
4.2 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Bacteriawa <A3167717663@hotmail.com>
Date: Tue, 23 Jun 2026 02:32:14 +0800
Subject: [PATCH] PCA sync protocol
Co-authored by: violetc <58360096+s-yh-china@users.noreply.github.com>
As a part of : Leaves (https://github.com/LeavesMC/Leaves/blob/252a16955f6e1e31aac85d222b093b0797d392f8/leaves-server/minecraft-patches/features/0027-PCA-sync-protocol.patch)
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
diff --git a/net/minecraft/world/SimpleContainer.java b/net/minecraft/world/SimpleContainer.java
index 0f412551685a8ea76be3b389e0782e57d22bb87c..b6154f677943e22ecb6dfdd6f9b8f867f1c7f09a 100644
--- a/net/minecraft/world/SimpleContainer.java
+++ b/net/minecraft/world/SimpleContainer.java
@@ -199,6 +199,13 @@ public class SimpleContainer implements Container, StackedContentsCompatible {
@Override
public void setChanged() {
+ // Leaves start - PCA sync protocol
+ if (fun.bm.lophine.config.modules.function.protocol.PcaSyncProtocolConfig.enabled && this.getOwner() instanceof org.bukkit.craftbukkit.entity.CraftEntity entity) {
+ // The owner can be a destination-world clone while it is being restored during an async portal transfer.
+ // syncEntityToClient() performs the ownership check and must receive the raw handle to reach it.
+ org.leavesmc.leaves.protocol.PcaSyncProtocol.syncEntityToClient(entity.getHandleRaw());
+ }
+ // Leaves end - PCA sync protocol
}
@Override
diff --git a/net/minecraft/world/entity/vehicle/boat/AbstractChestBoat.java b/net/minecraft/world/entity/vehicle/boat/AbstractChestBoat.java
index 58b99596b16e1dd8b0c9bcde5d465c6df52cc28b..3bb07698d1908f310ea7a1bb7a0da531f4040999 100644
--- a/net/minecraft/world/entity/vehicle/boat/AbstractChestBoat.java
+++ b/net/minecraft/world/entity/vehicle/boat/AbstractChestBoat.java
@@ -142,6 +142,11 @@ public abstract class AbstractChestBoat extends AbstractBoat implements HasCusto
@Override
public void setChanged() {
+ // Leaves start - PCA sync protocol
+ if (fun.bm.lophine.config.modules.function.protocol.PcaSyncProtocolConfig.enabled) {
+ org.leavesmc.leaves.protocol.PcaSyncProtocol.syncEntityToClient(this);
+ }
+ // Leaves end - PCA sync protocol
}
@Override
diff --git a/net/minecraft/world/entity/vehicle/minecart/AbstractMinecartContainer.java b/net/minecraft/world/entity/vehicle/minecart/AbstractMinecartContainer.java
index d87dcb72fd5d2b22eafc1a444d4fc3807595b6a5..bd92576ec323befd4bc0aaf36cf3c1d03826668a 100644
--- a/net/minecraft/world/entity/vehicle/minecart/AbstractMinecartContainer.java
+++ b/net/minecraft/world/entity/vehicle/minecart/AbstractMinecartContainer.java
@@ -66,6 +66,11 @@ public abstract class AbstractMinecartContainer extends AbstractMinecart impleme
@Override
public void setChanged() {
+ // Leaves start - PCA sync protocol
+ if (fun.bm.lophine.config.modules.function.protocol.PcaSyncProtocolConfig.enabled) {
+ org.leavesmc.leaves.protocol.PcaSyncProtocol.syncEntityToClient(this);
+ }
+ // Leaves end - PCA sync protocol
}
@Override
diff --git a/net/minecraft/world/level/block/entity/BlockEntity.java b/net/minecraft/world/level/block/entity/BlockEntity.java
index f8a6f3d4d6593ec416ce25a72871a5d40352480a..b677a8fec91968ea777b1f38ca00596e9072de92 100644
--- a/net/minecraft/world/level/block/entity/BlockEntity.java
+++ b/net/minecraft/world/level/block/entity/BlockEntity.java
@@ -236,6 +236,14 @@ public abstract class BlockEntity implements DebugValueSource, TypedInstance<Blo
if (!blockState.isAir()) {
level.updateNeighbourForOutputSignal(worldPosition, blockState.getBlock());
}
+ // Leaves start - PCA sync protocol
+ if (fun.bm.lophine.config.modules.function.protocol.PcaSyncProtocolConfig.enabled && !level.isClientSide()) {
+ BlockEntity blockEntity = level.getBlockEntity(worldPosition);
+ if (blockEntity != null) {
+ org.leavesmc.leaves.protocol.PcaSyncProtocol.syncBlockEntityToClient(blockEntity);
+ }
+ }
+ // Leaves end - PCA sync protocol
}
public BlockPos getBlockPos() {