Skip to content

Commit 6e88e46

Browse files
authored
Fix possible CME race conditions for post effects (PaperMC#14335)
1 parent 371c96a commit 6e88e46

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

‎paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -694,10 +694,15 @@
694694
}
695695

696696
public boolean isReceivingWaypoints() {
697-
@@ -1057,6 +_,19 @@
698-
this.connection.send(new ClientboundPostEffectsPacket(this.postEffects));
699-
}
697+
@@ -1054,8 +_,21 @@
700698

699+
public void sendPostEffects() {
700+
this.postEffectsDirty = false;
701+
- this.connection.send(new ClientboundPostEffectsPacket(this.postEffects));
702+
- }
703+
+ this.connection.send(new ClientboundPostEffectsPacket(List.copyOf(this.postEffects))); // Paper - Prevent CME race conditions
704+
+ }
705+
+
701706
+ // Paper start - Post effects API
702707
+ public boolean setPostEffects(final Collection<Identifier> postEffects) {
703708
+ if (com.google.common.collect.Iterables.elementsEqual(this.postEffects, postEffects)) {
@@ -710,10 +715,9 @@
710715
+ return true;
711716
+ }
712717
+ // Paper end - Post effects API
713-
+
718+
714719
public boolean addPostEffect(final Identifier postEffect) {
715720
if (this.postEffects.contains(postEffect)) {
716-
return false;
717721
@@ -1103,15 +_,17 @@
718722
if (block instanceof RespawnAnchorBlock && (forced || blockState.getValue(RespawnAnchorBlock.CHARGE) > 0) && RespawnAnchorBlock.canSetSpawn(level, pos)
719723
)

0 commit comments

Comments
 (0)