summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThinkofdeath <thinkofdeath@spigotmc.org>2015-04-15 17:35:14 +0100
committerThinkofdeath <thinkofdeath@spigotmc.org>2015-04-15 17:35:14 +0100
commitea28011f10cd60584fc0abd6d394b725c19fd041 (patch)
tree8bb4eca65b2971fbf6c33525f2c1cadac7fc8958
parentf13d771bb4c502335b1a57e7acef020bdd409450 (diff)
downloadcraftbukkit-ea28011f10cd60584fc0abd6d394b725c19fd041.tar
craftbukkit-ea28011f10cd60584fc0abd6d394b725c19fd041.tar.gz
craftbukkit-ea28011f10cd60584fc0abd6d394b725c19fd041.tar.lz
craftbukkit-ea28011f10cd60584fc0abd6d394b725c19fd041.tar.xz
craftbukkit-ea28011f10cd60584fc0abd6d394b725c19fd041.zip
SPIGOT-697: Force metadata updates when interact events are cancelled
-rw-r--r--nms-patches/PlayerConnection.patch42
1 files changed, 19 insertions, 23 deletions
diff --git a/nms-patches/PlayerConnection.patch b/nms-patches/PlayerConnection.patch
index 5c143f81..977fca9c 100644
--- a/nms-patches/PlayerConnection.patch
+++ b/nms-patches/PlayerConnection.patch
@@ -1,5 +1,5 @@
---- /home/matt/mc-dev-private//net/minecraft/server/PlayerConnection.java 2015-04-15 16:28:51.340916968 +0100
-+++ src/main/java/net/minecraft/server/PlayerConnection.java 2015-04-15 16:28:51.344916968 +0100
+--- /home/matt/mc-dev-private//net/minecraft/server/PlayerConnection.java 2015-04-15 17:35:03.688828804 +0100
++++ src/main/java/net/minecraft/server/PlayerConnection.java 2015-04-15 17:35:03.692828804 +0100
@@ -17,6 +17,48 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -899,7 +899,7 @@
PlayerConnectionUtils.ensureMainThread(packetplayinuseentity, this, this.player.u());
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
Entity entity = packetplayinuseentity.a((World) worldserver);
-@@ -654,18 +1203,71 @@
+@@ -654,18 +1203,67 @@
}
if (this.player.h(entity) < d0) {
@@ -908,9 +908,8 @@
+ if (packetplayinuseentity.a() == PacketPlayInUseEntity.EnumEntityUseAction.INTERACT
+ || packetplayinuseentity.a() == PacketPlayInUseEntity.EnumEntityUseAction.INTERACT_AT) {
+ // CraftBukkit start
-+ boolean triggerTagUpdate = itemInHand != null && itemInHand.getItem() == Items.NAME_TAG && entity instanceof EntityInsentient;
-+ boolean triggerChestUpdate = itemInHand != null && itemInHand.getItem() == Item.getItemOf(Blocks.CHEST) && entity instanceof EntityHorse;
+ boolean triggerLeashUpdate = itemInHand != null && itemInHand.getItem() == Items.LEAD && entity instanceof EntityInsentient;
++ Item origItem = this.player.inventory.getItemInHand() == null ? null : this.player.inventory.getItemInHand().getItem();
+ PlayerInteractEntityEvent event;
+ if (packetplayinuseentity.a() == PacketPlayInUseEntity.EnumEntityUseAction.INTERACT) {
+ event = new PlayerInteractEntityEvent((Player) this.getPlayer(), entity.getBukkitEntity());
@@ -925,13 +924,10 @@
+ this.sendPacket(new PacketPlayOutAttachEntity(1, entity, ((EntityInsentient) entity).getLeashHolder()));
+ }
+
-+ if (triggerTagUpdate && (event.isCancelled() || this.player.inventory.getItemInHand() == null || this.player.inventory.getItemInHand().getItem() != Items.NAME_TAG)) {
++ if (event.isCancelled() || this.player.inventory.getItemInHand() == null || this.player.inventory.getItemInHand().getItem() != origItem) {
+ // Refresh the current entity metadata
+ this.sendPacket(new PacketPlayOutEntityMetadata(entity.getId(), entity.datawatcher, true));
+ }
-+ if (triggerChestUpdate && (event.isCancelled() || this.player.inventory.getItemInHand() == null || this.player.inventory.getItemInHand().getItem() != Item.getItemOf(Blocks.CHEST))) {
-+ this.sendPacket(new PacketPlayOutEntityMetadata(entity.getId(), entity.datawatcher, true));
-+ }
+
+ if (event.isCancelled()) {
+ return;
@@ -972,7 +968,7 @@
}
}
}
-@@ -680,7 +1282,8 @@
+@@ -680,7 +1278,8 @@
switch (PlayerConnection.SyntheticClass_1.c[packetplayinclientcommand_enumclientcommand.ordinal()]) {
case 1:
if (this.player.viewingCredits) {
@@ -982,7 +978,7 @@
} else if (this.player.u().getWorldData().isHardcore()) {
if (this.minecraftServer.S() && this.player.getName().equals(this.minecraftServer.R())) {
this.player.playerConnection.disconnect("You have died. Game over, man, it\'s game over!");
-@@ -711,15 +1314,21 @@
+@@ -711,15 +1310,21 @@
}
public void a(PacketPlayInCloseWindow packetplayinclosewindow) {
@@ -1005,7 +1001,7 @@
ArrayList arraylist = Lists.newArrayList();
for (int i = 0; i < this.player.activeContainer.c.size(); ++i) {
-@@ -728,7 +1337,270 @@
+@@ -728,7 +1333,270 @@
this.player.a(this.player.activeContainer, (List) arraylist);
} else {
@@ -1277,7 +1273,7 @@
if (ItemStack.matches(packetplayinwindowclick.e(), itemstack)) {
this.player.playerConnection.sendPacket(new PacketPlayOutTransaction(packetplayinwindowclick.a(), packetplayinwindowclick.d(), true));
-@@ -789,8 +1661,48 @@
+@@ -789,8 +1657,48 @@
}
boolean flag1 = packetplayinsetcreativeslot.a() >= 1 && packetplayinsetcreativeslot.a() < 36 + PlayerInventory.getHotbarSize();
@@ -1327,7 +1323,7 @@
if (flag1 && flag2 && flag3) {
if (itemstack == null) {
-@@ -813,6 +1725,7 @@
+@@ -813,6 +1721,7 @@
}
public void a(PacketPlayInTransaction packetplayintransaction) {
@@ -1335,7 +1331,7 @@
PlayerConnectionUtils.ensureMainThread(packetplayintransaction, this, this.player.u());
Short oshort = (Short) this.n.get(this.player.activeContainer.windowId);
-@@ -823,6 +1736,7 @@
+@@ -823,6 +1732,7 @@
}
public void a(PacketPlayInUpdateSign packetplayinupdatesign) {
@@ -1343,7 +1339,7 @@
PlayerConnectionUtils.ensureMainThread(packetplayinupdatesign, this, this.player.u());
this.player.z();
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
-@@ -839,14 +1753,30 @@
+@@ -839,14 +1749,30 @@
if (!tileentitysign.b() || tileentitysign.c() != this.player) {
this.minecraftServer.warning("Player " + this.player.getName() + " just tried to change non-editable sign");
@@ -1375,7 +1371,7 @@
tileentitysign.update();
worldserver.notify(blockposition);
-@@ -869,11 +1799,27 @@
+@@ -869,11 +1795,27 @@
public void a(PacketPlayInAbilities packetplayinabilities) {
PlayerConnectionUtils.ensureMainThread(packetplayinabilities, this, this.player.u());
@@ -1404,7 +1400,7 @@
ArrayList arraylist = Lists.newArrayList();
Iterator iterator = this.minecraftServer.tabCompleteCommand(this.player, packetplayintabcomplete.a(), packetplayintabcomplete.b()).iterator();
-@@ -913,13 +1859,16 @@
+@@ -913,13 +1855,16 @@
itemstack1 = this.player.inventory.getItemInHand();
if (itemstack1 != null) {
if (itemstack.getItem() == Items.WRITABLE_BOOK && itemstack.getItem() == itemstack1.getItem()) {
@@ -1421,7 +1417,7 @@
return;
} finally {
packetdataserializer.release();
-@@ -942,16 +1891,21 @@
+@@ -942,16 +1887,21 @@
itemstack1 = this.player.inventory.getItemInHand();
if (itemstack1 != null) {
if (itemstack.getItem() == Items.WRITTEN_BOOK && itemstack1.getItem() == Items.WRITABLE_BOOK) {
@@ -1443,7 +1439,7 @@
return;
} finally {
packetdataserializer.release();
-@@ -968,11 +1922,12 @@
+@@ -968,11 +1918,12 @@
}
} catch (Exception exception2) {
PlayerConnection.c.error("Couldn\'t select trade", exception2);
@@ -1457,7 +1453,7 @@
packetdataserializer = packetplayincustompayload.b();
try {
-@@ -1008,6 +1963,7 @@
+@@ -1008,6 +1959,7 @@
}
} catch (Exception exception3) {
PlayerConnection.c.error("Couldn\'t set command block", exception3);
@@ -1465,7 +1461,7 @@
} finally {
packetdataserializer.release();
}
-@@ -1033,6 +1989,7 @@
+@@ -1033,6 +1985,7 @@
}
} catch (Exception exception4) {
PlayerConnection.c.error("Couldn\'t set beacon", exception4);
@@ -1473,7 +1469,7 @@
}
}
} else if ("MC|ItemName".equals(packetplayincustompayload.a()) && this.player.activeContainer instanceof ContainerAnvil) {
-@@ -1048,7 +2005,28 @@
+@@ -1048,7 +2001,28 @@
containeranvil.a("");
}
}