mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-22 18:45:54 +01:00
2641c02193
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 69fa4695 Add some missing deprecation annotations f850da2e Update Maven plugins/versions 8d8400db Use regular compiler seeing as ECJ doesn't support Java 21 JRE c29e1688 Revert "BUILDTOOLS-676: Downgrade Maven compiler version" 07bce714 SPIGOT-7355: More field renames and fixes 6a8ea764 Fix bad merge in penultimate commit 50a7920c Fix imports in previous commit 83640dd1 PR-995: Add required feature to MinecraftExperimental for easy lookups fc1f96cf BUILDTOOLS-676: Downgrade Maven compiler version CraftBukkit Changes: 90f1059ba Fix item placement 661afb43c SPIGOT-7633: Clearer error message for missing particle data 807b465b3 SPIGOT-7634: Armadillo updates infrequently 590cf09a8 Fix unit tests always seeing Mojang server as unavailable 7c7ac5eb2 SPIGOT-7636: Fix clearing ItemMeta 4a72905cf SPIGOT-7635: Fix Player#transfer and cookie methods ebb50e136 Fix incorrect Vault implementation b33fed8b7 Update Maven plugins/versions 6f00f0608 SPIGOT-7632: Control middle clicking chest does not copy contents db821f405 Use regular compiler seeing as ECJ doesn't support Java 21 JRE 8a2976737 Revert "BUILDTOOLS-676: Downgrade Maven compiler version" 0297f87bb SPIGOT-7355: More field renames and fixes 2d03bdf6a SPIGOT-7629: Fix loading banner patterns e77951fac Fix equality of deserialized display names c66f3e4fd SPIGOT-7631: Fix deserialisation of BlockStateMeta 9c2c7be8d SPIGOT-7630: Fix crash saving unticked leashed entities 8c1e7c841 PR-1384: Disable certain PlayerProfile tests, if Mojang's services or internet are not available ced93d572 SPIGOT-7626: sendSignChange() has no effect c77362cae SPIGOT-7625: ItemStack with lore cannot be serialized in 1.20.5 ff2004387 SPIGOT-7620: Fix server crash when hoppers transfer items to double chests 8b4abeb03 BUILDTOOLS-676: Downgrade Maven compiler version
172 lines
13 KiB
Diff
172 lines
13 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
|
|
Date: Tue, 27 Jun 2023 21:09:11 -0400
|
|
Subject: [PATCH] Dont resend blocks on interactions
|
|
|
|
In general, the client now has an acknowledgment system which will prevent block changes made by the client to be reverted correctly.
|
|
|
|
It should be noted that this system does not yet support block entities, so those still need to resynced when needed.
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
|
|
index cef3a64b5e6c4d34ed079078420078a7adfcd574..3dff328c5e4456aae291a8dec82766681f49af06 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
|
|
@@ -202,7 +202,7 @@ public class ServerPlayerGameMode {
|
|
PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, pos, direction, this.player.getInventory().getSelected(), InteractionHand.MAIN_HAND);
|
|
if (event.isCancelled()) {
|
|
// Let the client know the block still exists
|
|
- this.player.connection.send(new ClientboundBlockUpdatePacket(this.level, pos));
|
|
+ // this.player.connection.send(new ClientboundBlockUpdatePacket(this.level, pos)); // Paper - Don't resync blocks
|
|
// Update any tile entity data for this block
|
|
capturedBlockEntity = true; // Paper - Send block entities after destroy prediction
|
|
return;
|
|
@@ -217,7 +217,7 @@ public class ServerPlayerGameMode {
|
|
// Spigot start - handle debug stick left click for non-creative
|
|
if (this.player.getMainHandItem().is(net.minecraft.world.item.Items.DEBUG_STICK)
|
|
&& ((net.minecraft.world.item.DebugStickItem) net.minecraft.world.item.Items.DEBUG_STICK).handleInteraction(this.player, this.level.getBlockState(pos), this.level, pos, false, this.player.getMainHandItem())) {
|
|
- this.player.connection.send(new ClientboundBlockUpdatePacket(this.level, pos));
|
|
+ // this.player.connection.send(new ClientboundBlockUpdatePacket(this.level, pos)); // Paper - Don't resync block
|
|
return;
|
|
}
|
|
// Spigot end
|
|
@@ -235,15 +235,17 @@ public class ServerPlayerGameMode {
|
|
// CraftBukkit start - Swings at air do *NOT* exist.
|
|
if (event.useInteractedBlock() == Event.Result.DENY) {
|
|
// If we denied a door from opening, we need to send a correcting update to the client, as it already opened the door.
|
|
- BlockState data = this.level.getBlockState(pos);
|
|
- if (data.getBlock() instanceof DoorBlock) {
|
|
- // For some reason *BOTH* the bottom/top part have to be marked updated.
|
|
- boolean bottom = data.getValue(DoorBlock.HALF) == DoubleBlockHalf.LOWER;
|
|
- this.player.connection.send(new ClientboundBlockUpdatePacket(this.level, pos));
|
|
- this.player.connection.send(new ClientboundBlockUpdatePacket(this.level, bottom ? pos.above() : pos.below()));
|
|
- } else if (data.getBlock() instanceof TrapDoorBlock) {
|
|
- this.player.connection.send(new ClientboundBlockUpdatePacket(this.level, pos));
|
|
- }
|
|
+ // Paper start - Don't resync blocks
|
|
+ //BlockState data = this.level.getBlockState(pos);
|
|
+ //if (data.getBlock() instanceof DoorBlock) {
|
|
+ // // For some reason *BOTH* the bottom/top part have to be marked updated.
|
|
+ // boolean bottom = data.getValue(DoorBlock.HALF) == DoubleBlockHalf.LOWER;
|
|
+ // this.player.connection.send(new ClientboundBlockUpdatePacket(this.level, pos));
|
|
+ // this.player.connection.send(new ClientboundBlockUpdatePacket(this.level, bottom ? pos.above() : pos.below()));
|
|
+ //} else if (data.getBlock() instanceof TrapDoorBlock) {
|
|
+ // this.player.connection.send(new ClientboundBlockUpdatePacket(this.level, pos));
|
|
+ //}
|
|
+ // Paper end - Don't resync blocks
|
|
} else if (!iblockdata.isAir()) {
|
|
iblockdata.attack(this.level, pos, this.player);
|
|
f = iblockdata.getDestroyProgress(this.player, this.player.level(), pos);
|
|
@@ -252,7 +254,7 @@ public class ServerPlayerGameMode {
|
|
if (event.useItemInHand() == Event.Result.DENY) {
|
|
// If we 'insta destroyed' then the client needs to be informed.
|
|
if (f > 1.0f) {
|
|
- this.player.connection.send(new ClientboundBlockUpdatePacket(this.level, pos));
|
|
+ // this.player.connection.send(new ClientboundBlockUpdatePacket(this.level, pos)); // Paper - Don't resync blocks
|
|
}
|
|
return;
|
|
}
|
|
@@ -260,7 +262,7 @@ public class ServerPlayerGameMode {
|
|
|
|
if (blockEvent.isCancelled()) {
|
|
// Let the client know the block still exists
|
|
- this.player.connection.send(new ClientboundBlockUpdatePacket(this.level, pos));
|
|
+ // this.player.connection.send(new ClientboundBlockUpdatePacket(this.level, pos)); // Paper - Don't resync block
|
|
return;
|
|
}
|
|
|
|
@@ -351,7 +353,7 @@ public class ServerPlayerGameMode {
|
|
|
|
// Tell client the block is gone immediately then process events
|
|
// Don't tell the client if its a creative sword break because its not broken!
|
|
- if (this.level.getBlockEntity(pos) == null && !isSwordNoBreak) {
|
|
+ if (false && this.level.getBlockEntity(pos) == null && !isSwordNoBreak) { // Paper - Don't resync block
|
|
ClientboundBlockUpdatePacket packet = new ClientboundBlockUpdatePacket(pos, Blocks.AIR.defaultBlockState());
|
|
this.player.connection.send(packet);
|
|
}
|
|
@@ -377,13 +379,15 @@ public class ServerPlayerGameMode {
|
|
if (isSwordNoBreak) {
|
|
return false;
|
|
}
|
|
+ // Paper start - Don't resync blocks
|
|
// Let the client know the block still exists
|
|
- this.player.connection.send(new ClientboundBlockUpdatePacket(this.level, pos));
|
|
+ //this.player.connection.send(new ClientboundBlockUpdatePacket(this.level, pos));
|
|
|
|
// Brute force all possible updates
|
|
- for (Direction dir : Direction.values()) {
|
|
- this.player.connection.send(new ClientboundBlockUpdatePacket(this.level, pos.relative(dir)));
|
|
- }
|
|
+ //for (Direction dir : Direction.values()) {
|
|
+ // this.player.connection.send(new ClientboundBlockUpdatePacket(this.level, pos.relative(dir)));
|
|
+ //}
|
|
+ // Paper end - Don't resync blocks
|
|
|
|
// Update any tile entity data for this block
|
|
if (!captureSentBlockEntities) { // Paper - Send block entities after destroy prediction
|
|
@@ -532,16 +536,18 @@ public class ServerPlayerGameMode {
|
|
if (event.useInteractedBlock() == Event.Result.DENY) {
|
|
// If we denied a door from opening, we need to send a correcting update to the client, as it already opened the door.
|
|
if (iblockdata.getBlock() instanceof DoorBlock) {
|
|
- boolean bottom = iblockdata.getValue(DoorBlock.HALF) == DoubleBlockHalf.LOWER;
|
|
- player.connection.send(new ClientboundBlockUpdatePacket(world, bottom ? blockposition.above() : blockposition.below()));
|
|
+ // Paper start - Don't resync blocks
|
|
+ // boolean bottom = iblockdata.getValue(DoorBlock.HALF) == DoubleBlockHalf.LOWER;
|
|
+ // player.connection.send(new ClientboundBlockUpdatePacket(world, bottom ? blockposition.above() : blockposition.below()));
|
|
+ // Paper end - Don't resync blocks
|
|
} else if (iblockdata.getBlock() instanceof CakeBlock) {
|
|
player.getBukkitEntity().sendHealthUpdate(); // SPIGOT-1341 - reset health for cake
|
|
} else if (this.interactItemStack.getItem() instanceof DoubleHighBlockItem) {
|
|
// send a correcting update to the client, as it already placed the upper half of the bisected item
|
|
- player.connection.send(new ClientboundBlockUpdatePacket(world, blockposition.relative(hitResult.getDirection()).above()));
|
|
+ //player.connection.send(new ClientboundBlockUpdatePacket(world, blockposition.relative(hitResult.getDirection()).above())); // Paper - Don't resync blocks
|
|
|
|
// send a correcting update to the client for the block above as well, this because of replaceable blocks (such as grass, sea grass etc)
|
|
- player.connection.send(new ClientboundBlockUpdatePacket(world, blockposition.above()));
|
|
+ //player.connection.send(new ClientboundBlockUpdatePacket(world, blockposition.above())); // Paper - Don't resync blocks
|
|
// Paper start - extend Player Interact cancellation // TODO: consider merging this into the extracted method
|
|
} else if (iblockdata.is(Blocks.STRUCTURE_BLOCK) || iblockdata.getBlock() instanceof net.minecraft.world.level.block.CommandBlock) {
|
|
player.connection.send(new net.minecraft.network.protocol.game.ClientboundContainerClosePacket(this.player.containerMenu.containerId));
|
|
diff --git a/src/main/java/net/minecraft/world/item/BucketItem.java b/src/main/java/net/minecraft/world/item/BucketItem.java
|
|
index 6d494b80ae002aea00afa44adf83dad1ae5bbbc1..49557d6f22c5725c663a231deab019d4f6fe95fa 100644
|
|
--- a/src/main/java/net/minecraft/world/item/BucketItem.java
|
|
+++ b/src/main/java/net/minecraft/world/item/BucketItem.java
|
|
@@ -78,7 +78,7 @@ public class BucketItem extends Item implements DispensibleContainerItem {
|
|
PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent((ServerLevel) world, user, blockposition, blockposition, movingobjectpositionblock.getDirection(), itemstack, dummyFluid.getItem(), hand);
|
|
|
|
if (event.isCancelled()) {
|
|
- ((ServerPlayer) user).connection.send(new ClientboundBlockUpdatePacket(world, blockposition)); // SPIGOT-5163 (see PlayerInteractManager)
|
|
+ // ((ServerPlayer) user).connection.send(new ClientboundBlockUpdatePacket(world, blockposition)); // SPIGOT-5163 (see PlayerInteractManager) // Paper - Don't resend blocks
|
|
((ServerPlayer) user).getBukkitEntity().updateInventory(); // SPIGOT-4541
|
|
return InteractionResultHolder.fail(itemstack);
|
|
}
|
|
@@ -185,7 +185,7 @@ public class BucketItem extends Item implements DispensibleContainerItem {
|
|
if (flag2 && entityhuman != null) {
|
|
PlayerBucketEmptyEvent event = CraftEventFactory.callPlayerBucketEmptyEvent((ServerLevel) world, entityhuman, blockposition, clicked, enumdirection, itemstack, enumhand);
|
|
if (event.isCancelled()) {
|
|
- ((ServerPlayer) entityhuman).connection.send(new ClientboundBlockUpdatePacket(world, blockposition)); // SPIGOT-4238: needed when looking through entity
|
|
+ // ((ServerPlayer) entityhuman).connection.send(new ClientboundBlockUpdatePacket(world, blockposition)); // SPIGOT-4238: needed when looking through entity // Paper - Don't resend blocks
|
|
((ServerPlayer) entityhuman).getBukkitEntity().updateInventory(); // SPIGOT-4541
|
|
return false;
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java
|
|
index fb85a7da9da8063c2b781377f62e7db34c467859..2d2b436cae5693051df14e5777d385d38d5f4dd6 100644
|
|
--- a/src/main/java/net/minecraft/world/item/ItemStack.java
|
|
+++ b/src/main/java/net/minecraft/world/item/ItemStack.java
|
|
@@ -480,10 +480,12 @@ public final class ItemStack implements DataComponentHolder {
|
|
world.preventPoiUpdated = false;
|
|
|
|
// Brute force all possible updates
|
|
- BlockPos placedPos = ((CraftBlock) placeEvent.getBlock()).getPosition();
|
|
- for (Direction dir : Direction.values()) {
|
|
- ((ServerPlayer) entityhuman).connection.send(new ClientboundBlockUpdatePacket(world, placedPos.relative(dir)));
|
|
- }
|
|
+ // Paper start - Don't resync blocks
|
|
+ // BlockPos placedPos = ((CraftBlock) placeEvent.getBlock()).getPosition();
|
|
+ // for (Direction dir : Direction.values()) {
|
|
+ // ((ServerPlayer) entityhuman).connection.send(new ClientboundBlockUpdatePacket(world, placedPos.relative(dir)));
|
|
+ // }
|
|
+ // Paper end - Don't resync blocks
|
|
SignItem.openSign = null; // SPIGOT-6758 - Reset on early return
|
|
} else {
|
|
// Change the stack to its new contents if it hasn't been tampered with.
|