3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-15 04:20:04 +01:00

fix cancelling block falling causing client desync (fixes #5386) (#5419)

Dieser Commit ist enthalten in:
Gergely Sarkozi 2021-05-09 22:40:50 +02:00 committet von GitHub
Ursprung 8ed45920cf
Commit b0a4f353b9
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23

Datei anzeigen

@ -0,0 +1,59 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Trigary <trigary0@gmail.com>
Date: Sat, 27 Mar 2021 11:13:30 +0100
Subject: [PATCH] fix cancelling block falling causing client desync
diff --git a/src/main/java/net/minecraft/world/entity/item/EntityFallingBlock.java b/src/main/java/net/minecraft/world/entity/item/EntityFallingBlock.java
index 62d8b53c024888aa43b8fddf8a475dfb8284a4cc..2a61c24dd26edf4c72e977c6024fe233bab08a2f 100644
--- a/src/main/java/net/minecraft/world/entity/item/EntityFallingBlock.java
+++ b/src/main/java/net/minecraft/world/entity/item/EntityFallingBlock.java
@@ -14,6 +14,7 @@ import net.minecraft.network.protocol.game.PacketPlayOutSpawnEntity;
import net.minecraft.network.syncher.DataWatcher;
import net.minecraft.network.syncher.DataWatcherObject;
import net.minecraft.network.syncher.DataWatcherRegistry;
+import net.minecraft.server.level.WorldServer;
import net.minecraft.tags.Tag;
import net.minecraft.tags.TagsBlock;
import net.minecraft.tags.TagsFluid;
@@ -43,6 +44,7 @@ import net.minecraft.world.phys.MovingObjectPosition;
import net.minecraft.world.phys.MovingObjectPositionBlock;
import net.minecraft.world.phys.Vec3D;
+import org.bukkit.craftbukkit.block.CraftBlock;
import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
public class EntityFallingBlock extends Entity {
@@ -116,8 +118,18 @@ public class EntityFallingBlock extends Entity {
if (this.ticksLived++ == 0) {
blockposition = this.getChunkCoordinates();
- if (this.world.getType(blockposition).a(block) && !CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, Blocks.AIR.getBlockData()).isCancelled()) {
- this.world.a(blockposition, false);
+ // Paper start - fix cancelling block falling causing client desync
+ if (this.world.getType(blockposition).isSameInstance(block)) {
+ if (CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, Blocks.AIR.getBlockData()).isCancelled()) {
+ if (this.world.getType(blockposition).isSameInstance(block)) { //if listener didn't update the block
+ ((WorldServer) world).getChunkProvider().flagDirty(blockposition);
+ }
+ this.die();
+ return;
+ } else {
+ this.world.setAir(blockposition, false);
+ }
+ // Paper end - fix cancelling block falling causing client desync
} else if (!this.world.isClientSide) {
this.die();
return;
diff --git a/src/main/java/net/minecraft/world/level/block/state/BlockBase.java b/src/main/java/net/minecraft/world/level/block/state/BlockBase.java
index ac3709c8158d42ccafd457cfa44a16dc8c9eb949..d9765da72c614260fdba47e7d1add4145991f97c 100644
--- a/src/main/java/net/minecraft/world/level/block/state/BlockBase.java
+++ b/src/main/java/net/minecraft/world/level/block/state/BlockBase.java
@@ -682,6 +682,7 @@ public abstract class BlockBase {
return this.getBlock().a(tag) && predicate.test(this);
}
+ public final boolean isSameInstance(Block block) { return a(block); } // Paper - OBFHELPER
public boolean a(Block block) {
return this.getBlock().a(block);
}