mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-30 16:19:03 +01:00
59 lines
3.5 KiB
Diff
59 lines
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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
|
|
@@ -0,0 +0,0 @@ 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;
|
|
@@ -0,0 +0,0 @@ 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 {
|
|
@@ -0,0 +0,0 @@ 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 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
|
|
@@ -0,0 +0,0 @@ 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);
|
|
}
|