2023-12-03 04:41:35 +01:00
|
|
|
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
|
2024-02-01 10:15:57 +01:00
|
|
|
index d0ca98c3f9ea5c8cb1053da6b17e9a90c86b3ae7..5063eb6d4a24600262c32d2c9eb5fb5bf8fa354e 100644
|
2023-12-03 04:41:35 +01:00
|
|
|
--- a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
|
|
|
|
@@ -199,7 +199,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
|
2024-01-18 15:56:25 +01:00
|
|
|
capturedBlockEntity = true; // Paper - Send block entities after destroy prediction
|
2023-12-03 04:41:35 +01:00
|
|
|
return;
|
|
|
|
@@ -214,7 +214,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
|
|
|
|
@@ -232,15 +232,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));
|
|
|
|
+ //}
|
2024-01-13 16:35:59 +01:00
|
|
|
+ // Paper end - Don't resync blocks
|
2023-12-03 04:41:35 +01:00
|
|
|
} else if (!iblockdata.isAir()) {
|
|
|
|
iblockdata.attack(this.level, pos, this.player);
|
|
|
|
f = iblockdata.getDestroyProgress(this.player, this.player.level(), pos);
|
|
|
|
@@ -249,7 +251,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;
|
|
|
|
}
|
|
|
|
@@ -257,7 +259,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;
|
|
|
|
}
|
|
|
|
|
2024-01-23 15:43:48 +01:00
|
|
|
@@ -348,7 +350,7 @@ public class ServerPlayerGameMode {
|
2023-12-03 04:41:35 +01:00
|
|
|
|
|
|
|
// 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);
|
|
|
|
}
|
2024-01-23 15:43:48 +01:00
|
|
|
@@ -374,13 +376,15 @@ public class ServerPlayerGameMode {
|
2023-12-03 04:41:35 +01:00
|
|
|
if (isSwordNoBreak) {
|
|
|
|
return false;
|
|
|
|
}
|
2024-01-13 16:35:59 +01:00
|
|
|
+ // Paper start - Don't resync blocks
|
2023-12-03 04:41:35 +01:00
|
|
|
// 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)));
|
|
|
|
+ //}
|
2024-01-13 16:35:59 +01:00
|
|
|
+ // Paper end - Don't resync blocks
|
2023-12-03 04:41:35 +01:00
|
|
|
|
|
|
|
// Update any tile entity data for this block
|
2024-01-18 15:56:25 +01:00
|
|
|
if (!captureSentBlockEntities) { // Paper - Send block entities after destroy prediction
|
2024-01-23 15:43:48 +01:00
|
|
|
@@ -537,16 +541,18 @@ public class ServerPlayerGameMode {
|
2023-12-03 04:41:35 +01:00
|
|
|
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()));
|
2024-01-13 16:35:59 +01:00
|
|
|
+ // Paper end - Don't resync blocks
|
2023-12-03 04:41:35 +01:00
|
|
|
} 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()));
|
2024-01-13 16:35:59 +01:00
|
|
|
+ //player.connection.send(new ClientboundBlockUpdatePacket(world, blockposition.relative(hitResult.getDirection()).above())); // Paper - Don't resync blocks
|
2023-12-03 04:41:35 +01:00
|
|
|
|
|
|
|
// 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()));
|
2024-01-13 16:35:59 +01:00
|
|
|
+ //player.connection.send(new ClientboundBlockUpdatePacket(world, blockposition.above())); // Paper - Don't resync blocks
|
2024-01-22 18:04:55 +01:00
|
|
|
// Paper start - extend Player Interact cancellation // TODO: consider merging this into the extracted method
|
2024-02-01 10:15:57 +01:00
|
|
|
} else if (iblockdata.is(Blocks.STRUCTURE_BLOCK) || iblockdata.getBlock() instanceof net.minecraft.world.level.block.CommandBlock) {
|
2023-12-03 04:41:35 +01:00
|
|
|
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
|
2024-01-19 17:54:05 +01:00
|
|
|
index 4b9e726e6ac255e743479d5c2e0cdb98464399a4..6371f326fc86cfc53e39bf8ed13b646f7705fbbc 100644
|
2023-12-03 04:41:35 +01:00
|
|
|
--- a/src/main/java/net/minecraft/world/item/BucketItem.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/item/BucketItem.java
|
|
|
|
@@ -77,7 +77,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);
|
|
|
|
}
|
|
|
|
@@ -186,7 +186,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
|
Updated Upstream (Bukkit/CraftBukkit) (#10242)
* Updated Upstream (Bukkit/CraftBukkit)
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:
a6a9d2a4 Remove some old ApiStatus.Experimental annotations
be72314c SPIGOT-7300, PR-829: Add new DamageSource API providing enhanced information about entity damage
b252cf05 SPIGOT-7576, PR-970: Add methods in MushroomCow to change stew effects
b1c689bd PR-902: Add Server#isLoggingIPs to get log-ips configuration
08f86d1c PR-971: Add Player methods for client-side potion effects
2e3024a9 PR-963: Add API for in-world structures
a23292a7 SPIGOT-7530, PR-948: Improve Resource Pack API with new 1.20.3 functionality
1851857b SPIGOT-3071, PR-969: Add entity spawn method with spawn reason
cde4c52a SPIGOT-5553, PR-964: Add EntityKnockbackEvent
CraftBukkit Changes:
38fd4bd50 Fix accidentally renamed internal damage method
80f0ce4be SPIGOT-7300, PR-1180: Add new DamageSource API providing enhanced information about entity damage
7e43f3b16 SPIGOT-7581: Fix typo in BlockMushroom
ea14b7d90 SPIGOT-7576, PR-1347: Add methods in MushroomCow to change stew effects
4c687f243 PR-1259: Add Server#isLoggingIPs to get log-ips configuration
22a541a29 Improve support for per-world game rules
cb7dccce2 PR-1348: Add Player methods for client-side potion effects
b8d6109f0 PR-1335: Add API for in-world structures
4398a1b5b SPIGOT-7577: Make CraftWindCharge#explode discard the entity
e74107678 Fix Crafter maximum stack size
0bb0f4f6a SPIGOT-7530, PR-1314: Improve Resource Pack API with new 1.20.3 functionality
4949f556d SPIGOT-3071, PR-1345: Add entity spawn method with spawn reason
20ac73ca2 PR-1353: Fix Structure#place not working as documented with 0 palette
3c1b77871 SPIGOT-6911, PR-1349: Change max book length in CraftMetaBook
333701839 SPIGOT-7572: Bee nests generated without bees
f48f4174c SPIGOT-5553, PR-1336: Add EntityKnockbackEvent
2024-02-11 22:28:00 +01:00
|
|
|
index 9b4e20d4bfba2de08084f1d69cb2ebfff7455c14..06dc04a1fbb91a5a20d662aeee168b6a319551d0 100644
|
2023-12-03 04:41:35 +01:00
|
|
|
--- a/src/main/java/net/minecraft/world/item/ItemStack.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/item/ItemStack.java
|
Updated Upstream (Bukkit/CraftBukkit) (#10242)
* Updated Upstream (Bukkit/CraftBukkit)
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:
a6a9d2a4 Remove some old ApiStatus.Experimental annotations
be72314c SPIGOT-7300, PR-829: Add new DamageSource API providing enhanced information about entity damage
b252cf05 SPIGOT-7576, PR-970: Add methods in MushroomCow to change stew effects
b1c689bd PR-902: Add Server#isLoggingIPs to get log-ips configuration
08f86d1c PR-971: Add Player methods for client-side potion effects
2e3024a9 PR-963: Add API for in-world structures
a23292a7 SPIGOT-7530, PR-948: Improve Resource Pack API with new 1.20.3 functionality
1851857b SPIGOT-3071, PR-969: Add entity spawn method with spawn reason
cde4c52a SPIGOT-5553, PR-964: Add EntityKnockbackEvent
CraftBukkit Changes:
38fd4bd50 Fix accidentally renamed internal damage method
80f0ce4be SPIGOT-7300, PR-1180: Add new DamageSource API providing enhanced information about entity damage
7e43f3b16 SPIGOT-7581: Fix typo in BlockMushroom
ea14b7d90 SPIGOT-7576, PR-1347: Add methods in MushroomCow to change stew effects
4c687f243 PR-1259: Add Server#isLoggingIPs to get log-ips configuration
22a541a29 Improve support for per-world game rules
cb7dccce2 PR-1348: Add Player methods for client-side potion effects
b8d6109f0 PR-1335: Add API for in-world structures
4398a1b5b SPIGOT-7577: Make CraftWindCharge#explode discard the entity
e74107678 Fix Crafter maximum stack size
0bb0f4f6a SPIGOT-7530, PR-1314: Improve Resource Pack API with new 1.20.3 functionality
4949f556d SPIGOT-3071, PR-1345: Add entity spawn method with spawn reason
20ac73ca2 PR-1353: Fix Structure#place not working as documented with 0 palette
3c1b77871 SPIGOT-6911, PR-1349: Change max book length in CraftMetaBook
333701839 SPIGOT-7572: Bee nests generated without bees
f48f4174c SPIGOT-5553, PR-1336: Add EntityKnockbackEvent
2024-02-11 22:28:00 +01:00
|
|
|
@@ -458,10 +458,12 @@ public final class ItemStack {
|
2023-12-03 04:41:35 +01:00
|
|
|
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)));
|
|
|
|
- }
|
2024-01-13 16:35:59 +01:00
|
|
|
+ // Paper start - Don't resync blocks
|
2023-12-03 04:41:35 +01:00
|
|
|
+ // BlockPos placedPos = ((CraftBlock) placeEvent.getBlock()).getPosition();
|
|
|
|
+ // for (Direction dir : Direction.values()) {
|
|
|
|
+ // ((ServerPlayer) entityhuman).connection.send(new ClientboundBlockUpdatePacket(world, placedPos.relative(dir)));
|
|
|
|
+ // }
|
2024-01-13 16:35:59 +01:00
|
|
|
+ // Paper end - Don't resync blocks
|
2023-12-03 04:41:35 +01:00
|
|
|
SignItem.openSign = null; // SPIGOT-6758 - Reset on early return
|
|
|
|
} else {
|
|
|
|
// Change the stack to its new contents if it hasn't been tampered with.
|