mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-09 09:47:40 +01:00
SPIGOT-6435: send correcting "PacketPlayOutBlockChange" packet on interact for bisected items
By: Julian van den Berkmortel <julianvdberkmortel@outlook.com>
This commit is contained in:
parent
4d865daa32
commit
c5af0704d0
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/server/level/PlayerInteractManager.java
|
||||
+++ b/net/minecraft/server/level/PlayerInteractManager.java
|
||||
@@ -26,6 +26,24 @@
|
||||
@@ -26,6 +26,25 @@
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@ -9,6 +9,7 @@
|
||||
+import net.minecraft.network.protocol.game.PacketPlayOutBlockChange;
|
||||
+import net.minecraft.server.MinecraftServer;
|
||||
+import net.minecraft.world.entity.EnumItemSlot;
|
||||
+import net.minecraft.world.item.ItemBisected;
|
||||
+import net.minecraft.world.level.block.BlockCake;
|
||||
+import net.minecraft.world.level.block.BlockDoor;
|
||||
+import net.minecraft.world.level.block.BlockTrapdoor;
|
||||
@ -25,7 +26,7 @@
|
||||
public class PlayerInteractManager {
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
@@ -60,7 +78,7 @@
|
||||
@@ -60,7 +79,7 @@
|
||||
this.gamemode = enumgamemode;
|
||||
enumgamemode.a(this.player.abilities);
|
||||
this.player.updateAbilities();
|
||||
@ -34,7 +35,7 @@
|
||||
this.world.everyoneSleeping();
|
||||
}
|
||||
|
||||
@@ -89,7 +107,7 @@
|
||||
@@ -89,7 +108,7 @@
|
||||
}
|
||||
|
||||
public void a() {
|
||||
@ -43,7 +44,7 @@
|
||||
IBlockData iblockdata;
|
||||
|
||||
if (this.j) {
|
||||
@@ -145,9 +163,31 @@
|
||||
@@ -145,9 +164,31 @@
|
||||
|
||||
if (packetplayinblockdig_enumplayerdigtype == PacketPlayInBlockDig.EnumPlayerDigType.START_DESTROY_BLOCK) {
|
||||
if (!this.world.a((EntityHuman) this.player, blockposition)) {
|
||||
@ -75,7 +76,7 @@
|
||||
|
||||
if (this.isCreative()) {
|
||||
this.a(blockposition, packetplayinblockdig_enumplayerdigtype, "creative destroy");
|
||||
@@ -163,11 +203,43 @@
|
||||
@@ -163,11 +204,43 @@
|
||||
float f = 1.0F;
|
||||
|
||||
iblockdata = this.world.getType(blockposition);
|
||||
@ -120,7 +121,7 @@
|
||||
if (!iblockdata.isAir() && f >= 1.0F) {
|
||||
this.a(blockposition, packetplayinblockdig_enumplayerdigtype, "insta mine");
|
||||
} else {
|
||||
@@ -211,7 +283,7 @@
|
||||
@@ -211,7 +284,7 @@
|
||||
} else if (packetplayinblockdig_enumplayerdigtype == PacketPlayInBlockDig.EnumPlayerDigType.ABORT_DESTROY_BLOCK) {
|
||||
this.f = false;
|
||||
if (!Objects.equals(this.h, blockposition)) {
|
||||
@ -129,7 +130,7 @@
|
||||
this.world.a(this.player.getId(), this.h, -1);
|
||||
this.player.playerConnection.sendPacket(new PacketPlayOutBlockBreak(this.h, this.world.getType(this.h), packetplayinblockdig_enumplayerdigtype, true, "aborted mismatched destroying"));
|
||||
}
|
||||
@@ -227,17 +299,73 @@
|
||||
@@ -227,17 +300,73 @@
|
||||
if (this.breakBlock(blockposition)) {
|
||||
this.player.playerConnection.sendPacket(new PacketPlayOutBlockBreak(blockposition, this.world.getType(blockposition), packetplayinblockdig_enumplayerdigtype, true, s));
|
||||
} else {
|
||||
@ -205,7 +206,7 @@
|
||||
TileEntity tileentity = this.world.getTileEntity(blockposition);
|
||||
Block block = iblockdata.getBlock();
|
||||
|
||||
@@ -247,6 +375,10 @@
|
||||
@@ -247,6 +376,10 @@
|
||||
} else if (this.player.a((World) this.world, blockposition, this.gamemode)) {
|
||||
return false;
|
||||
} else {
|
||||
@ -216,7 +217,7 @@
|
||||
block.a((World) this.world, blockposition, iblockdata, (EntityHuman) this.player);
|
||||
boolean flag = this.world.a(blockposition, false);
|
||||
|
||||
@@ -255,19 +387,32 @@
|
||||
@@ -255,19 +388,32 @@
|
||||
}
|
||||
|
||||
if (this.isCreative()) {
|
||||
@ -239,20 +240,20 @@
|
||||
+ // CraftBukkit start
|
||||
+ if (event.isDropItems()) {
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockDropItemEvent(bblock, state, this.player, world.captureDrops);
|
||||
+ }
|
||||
}
|
||||
+ world.captureDrops = null;
|
||||
+
|
||||
+ // Drop event experience
|
||||
+ if (flag && event != null) {
|
||||
+ iblockdata.getBlock().dropExperience(this.world, blockposition, event.getExpToDrop());
|
||||
}
|
||||
+ }
|
||||
+
|
||||
+ return true;
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -309,12 +454,46 @@
|
||||
@@ -309,12 +455,52 @@
|
||||
}
|
||||
}
|
||||
|
||||
@ -291,6 +292,12 @@
|
||||
+ entityplayer.playerConnection.sendPacket(new PacketPlayOutBlockChange(world, bottom ? blockposition.up() : blockposition.down()));
|
||||
+ } else if (iblockdata.getBlock() instanceof BlockCake) {
|
||||
+ entityplayer.getBukkitEntity().sendHealthUpdate(); // SPIGOT-1341 - reset health for cake
|
||||
+ } else if (interactItemStack.getItem() instanceof ItemBisected) {
|
||||
+ // send a correcting update to the client, as it already placed the upper half of the bisected item
|
||||
+ entityplayer.playerConnection.sendPacket(new PacketPlayOutBlockChange(world, blockposition.shift(movingobjectpositionblock.getDirection()).up()));
|
||||
+
|
||||
+ // send a correcting update to the client for the block above as well, this because of replaceable blocks (such as grass, sea grass etc)
|
||||
+ entityplayer.playerConnection.sendPacket(new PacketPlayOutBlockChange(world, blockposition.up()));
|
||||
+ }
|
||||
+ entityplayer.getBukkitEntity().updateInventory(); // SPIGOT-2867
|
||||
+ enuminteractionresult = (event.useItemInHand() != Event.Result.ALLOW) ? EnumInteractionResult.SUCCESS : EnumInteractionResult.PASS;
|
||||
@ -299,7 +306,7 @@
|
||||
|
||||
if (itileinventory != null) {
|
||||
entityplayer.openContainer(itileinventory);
|
||||
@@ -328,7 +507,7 @@
|
||||
@@ -328,7 +514,7 @@
|
||||
ItemStack itemstack1 = itemstack.cloneItemStack();
|
||||
|
||||
if (!flag1) {
|
||||
@ -308,7 +315,7 @@
|
||||
|
||||
if (enuminteractionresult.a()) {
|
||||
CriterionTriggers.M.a(entityplayer, blockposition, itemstack1);
|
||||
@@ -336,17 +515,17 @@
|
||||
@@ -336,17 +522,17 @@
|
||||
}
|
||||
}
|
||||
|
||||
@ -329,7 +336,7 @@
|
||||
}
|
||||
|
||||
if (enuminteractionresult1.a()) {
|
||||
@@ -354,10 +533,10 @@
|
||||
@@ -354,10 +540,10 @@
|
||||
}
|
||||
|
||||
return enuminteractionresult1;
|
||||
|
Loading…
Reference in New Issue
Block a user