3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-15 11:00:06 +01:00
Paper/Remapped-Spigot-Server-Patches/0698-fix-cancelling-block-falling-causing-client-desync.patch
2021-06-11 13:56:17 +02:00

60 Zeilen
3.5 KiB
Diff

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/FallingBlockEntity.java b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
index 2ba81e7179c7f9e2e1add1ad6bd6b96ee12c5da1..718e20f83a9b510c095d7e12241616cdce33d2d6 100644
--- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
+++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
@@ -13,6 +13,7 @@ import net.minecraft.network.protocol.game.ClientboundAddEntityPacket;
import net.minecraft.network.syncher.EntityDataAccessor;
import net.minecraft.network.syncher.EntityDataSerializers;
import net.minecraft.network.syncher.SynchedEntityData;
+import net.minecraft.server.level.ServerLevel;
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.FluidTags;
import net.minecraft.tags.Tag;
@@ -41,6 +42,7 @@ import net.minecraft.world.level.material.Fluids;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.HitResult;
import net.minecraft.world.phys.Vec3;
+import org.bukkit.craftbukkit.block.CraftBlock;
import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
public class FallingBlockEntity extends Entity {
@@ -114,8 +116,18 @@ public class FallingBlockEntity extends Entity {
if (this.time++ == 0) {
blockposition = this.blockPosition();
- if (this.level.getBlockState(blockposition).is(block) && !CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, Blocks.AIR.defaultBlockState()).isCancelled()) {
- this.level.removeBlock(blockposition, false);
+ // Paper start - fix cancelling block falling causing client desync
+ if (this.level.getBlockState(blockposition).isSameInstance(block)) {
+ if (CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, Blocks.AIR.defaultBlockState()).isCancelled()) {
+ if (this.level.getBlockState(blockposition).isSameInstance(block)) { //if listener didn't update the block
+ ((ServerLevel) level).getChunkSource().blockChanged(blockposition);
+ }
+ this.remove();
+ return;
+ } else {
+ this.level.setAir(blockposition, false);
+ }
+ // Paper end - fix cancelling block falling causing client desync
} else if (!this.level.isClientSide) {
this.remove();
return;
diff --git a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java
index 17baae6b11f191f4738a107c7e62ea5bdac17a3c..32cda8c2e14cf8b218cb006a9b25330f0dab849a 100644
--- a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java
+++ b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java
@@ -682,6 +682,7 @@ public abstract class BlockBehaviour {
return this.getBlock().is(tag) && predicate.test(this);
}
+ public final boolean isSameInstance(Block block) { return is(block); } // Paper - OBFHELPER
public boolean is(Block block) {
return this.getBlock().is(block);
}