Archiviert
13
0

SPIGOT-697: Force metadata updates when interact events are cancelled

Dieser Commit ist enthalten in:
Thinkofdeath 2015-04-15 17:35:14 +01:00
Ursprung f13d771bb4
Commit ea28011f10

Datei anzeigen

@ -1,5 +1,5 @@
--- /home/matt/mc-dev-private//net/minecraft/server/PlayerConnection.java 2015-04-15 16:28:51.340916968 +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 16:28:51.344916968 +0100 +++ src/main/java/net/minecraft/server/PlayerConnection.java 2015-04-15 17:35:03.692828804 +0100
@@ -17,6 +17,48 @@ @@ -17,6 +17,48 @@
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
@ -899,7 +899,7 @@
PlayerConnectionUtils.ensureMainThread(packetplayinuseentity, this, this.player.u()); PlayerConnectionUtils.ensureMainThread(packetplayinuseentity, this, this.player.u());
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
Entity entity = packetplayinuseentity.a((World) worldserver); Entity entity = packetplayinuseentity.a((World) worldserver);
@@ -654,18 +1203,71 @@ @@ -654,18 +1203,67 @@
} }
if (this.player.h(entity) < d0) { if (this.player.h(entity) < d0) {
@ -908,9 +908,8 @@
+ if (packetplayinuseentity.a() == PacketPlayInUseEntity.EnumEntityUseAction.INTERACT + if (packetplayinuseentity.a() == PacketPlayInUseEntity.EnumEntityUseAction.INTERACT
+ || packetplayinuseentity.a() == PacketPlayInUseEntity.EnumEntityUseAction.INTERACT_AT) { + || packetplayinuseentity.a() == PacketPlayInUseEntity.EnumEntityUseAction.INTERACT_AT) {
+ // CraftBukkit start + // 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; + 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; + PlayerInteractEntityEvent event;
+ if (packetplayinuseentity.a() == PacketPlayInUseEntity.EnumEntityUseAction.INTERACT) { + if (packetplayinuseentity.a() == PacketPlayInUseEntity.EnumEntityUseAction.INTERACT) {
+ event = new PlayerInteractEntityEvent((Player) this.getPlayer(), entity.getBukkitEntity()); + event = new PlayerInteractEntityEvent((Player) this.getPlayer(), entity.getBukkitEntity());
@ -925,13 +924,10 @@
+ this.sendPacket(new PacketPlayOutAttachEntity(1, entity, ((EntityInsentient) entity).getLeashHolder())); + 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 + // Refresh the current entity metadata
+ this.sendPacket(new PacketPlayOutEntityMetadata(entity.getId(), entity.datawatcher, true)); + 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()) { + if (event.isCancelled()) {
+ return; + return;
@ -972,7 +968,7 @@
} }
} }
} }
@@ -680,7 +1282,8 @@ @@ -680,7 +1278,8 @@
switch (PlayerConnection.SyntheticClass_1.c[packetplayinclientcommand_enumclientcommand.ordinal()]) { switch (PlayerConnection.SyntheticClass_1.c[packetplayinclientcommand_enumclientcommand.ordinal()]) {
case 1: case 1:
if (this.player.viewingCredits) { if (this.player.viewingCredits) {
@ -982,7 +978,7 @@
} else if (this.player.u().getWorldData().isHardcore()) { } else if (this.player.u().getWorldData().isHardcore()) {
if (this.minecraftServer.S() && this.player.getName().equals(this.minecraftServer.R())) { 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!"); 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) { public void a(PacketPlayInCloseWindow packetplayinclosewindow) {
@ -1005,7 +1001,7 @@
ArrayList arraylist = Lists.newArrayList(); ArrayList arraylist = Lists.newArrayList();
for (int i = 0; i < this.player.activeContainer.c.size(); ++i) { 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); this.player.a(this.player.activeContainer, (List) arraylist);
} else { } else {
@ -1277,7 +1273,7 @@
if (ItemStack.matches(packetplayinwindowclick.e(), itemstack)) { if (ItemStack.matches(packetplayinwindowclick.e(), itemstack)) {
this.player.playerConnection.sendPacket(new PacketPlayOutTransaction(packetplayinwindowclick.a(), packetplayinwindowclick.d(), true)); 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(); boolean flag1 = packetplayinsetcreativeslot.a() >= 1 && packetplayinsetcreativeslot.a() < 36 + PlayerInventory.getHotbarSize();
@ -1327,7 +1323,7 @@
if (flag1 && flag2 && flag3) { if (flag1 && flag2 && flag3) {
if (itemstack == null) { if (itemstack == null) {
@@ -813,6 +1725,7 @@ @@ -813,6 +1721,7 @@
} }
public void a(PacketPlayInTransaction packetplayintransaction) { public void a(PacketPlayInTransaction packetplayintransaction) {
@ -1335,7 +1331,7 @@
PlayerConnectionUtils.ensureMainThread(packetplayintransaction, this, this.player.u()); PlayerConnectionUtils.ensureMainThread(packetplayintransaction, this, this.player.u());
Short oshort = (Short) this.n.get(this.player.activeContainer.windowId); Short oshort = (Short) this.n.get(this.player.activeContainer.windowId);
@@ -823,6 +1736,7 @@ @@ -823,6 +1732,7 @@
} }
public void a(PacketPlayInUpdateSign packetplayinupdatesign) { public void a(PacketPlayInUpdateSign packetplayinupdatesign) {
@ -1343,7 +1339,7 @@
PlayerConnectionUtils.ensureMainThread(packetplayinupdatesign, this, this.player.u()); PlayerConnectionUtils.ensureMainThread(packetplayinupdatesign, this, this.player.u());
this.player.z(); this.player.z();
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
@@ -839,14 +1753,30 @@ @@ -839,14 +1749,30 @@
if (!tileentitysign.b() || tileentitysign.c() != this.player) { if (!tileentitysign.b() || tileentitysign.c() != this.player) {
this.minecraftServer.warning("Player " + this.player.getName() + " just tried to change non-editable sign"); this.minecraftServer.warning("Player " + this.player.getName() + " just tried to change non-editable sign");
@ -1375,7 +1371,7 @@
tileentitysign.update(); tileentitysign.update();
worldserver.notify(blockposition); worldserver.notify(blockposition);
@@ -869,11 +1799,27 @@ @@ -869,11 +1795,27 @@
public void a(PacketPlayInAbilities packetplayinabilities) { public void a(PacketPlayInAbilities packetplayinabilities) {
PlayerConnectionUtils.ensureMainThread(packetplayinabilities, this, this.player.u()); PlayerConnectionUtils.ensureMainThread(packetplayinabilities, this, this.player.u());
@ -1404,7 +1400,7 @@
ArrayList arraylist = Lists.newArrayList(); ArrayList arraylist = Lists.newArrayList();
Iterator iterator = this.minecraftServer.tabCompleteCommand(this.player, packetplayintabcomplete.a(), packetplayintabcomplete.b()).iterator(); 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(); itemstack1 = this.player.inventory.getItemInHand();
if (itemstack1 != null) { if (itemstack1 != null) {
if (itemstack.getItem() == Items.WRITABLE_BOOK && itemstack.getItem() == itemstack1.getItem()) { if (itemstack.getItem() == Items.WRITABLE_BOOK && itemstack.getItem() == itemstack1.getItem()) {
@ -1421,7 +1417,7 @@
return; return;
} finally { } finally {
packetdataserializer.release(); packetdataserializer.release();
@@ -942,16 +1891,21 @@ @@ -942,16 +1887,21 @@
itemstack1 = this.player.inventory.getItemInHand(); itemstack1 = this.player.inventory.getItemInHand();
if (itemstack1 != null) { if (itemstack1 != null) {
if (itemstack.getItem() == Items.WRITTEN_BOOK && itemstack1.getItem() == Items.WRITABLE_BOOK) { if (itemstack.getItem() == Items.WRITTEN_BOOK && itemstack1.getItem() == Items.WRITABLE_BOOK) {
@ -1443,7 +1439,7 @@
return; return;
} finally { } finally {
packetdataserializer.release(); packetdataserializer.release();
@@ -968,11 +1922,12 @@ @@ -968,11 +1918,12 @@
} }
} catch (Exception exception2) { } catch (Exception exception2) {
PlayerConnection.c.error("Couldn\'t select trade", exception2); PlayerConnection.c.error("Couldn\'t select trade", exception2);
@ -1457,7 +1453,7 @@
packetdataserializer = packetplayincustompayload.b(); packetdataserializer = packetplayincustompayload.b();
try { try {
@@ -1008,6 +1963,7 @@ @@ -1008,6 +1959,7 @@
} }
} catch (Exception exception3) { } catch (Exception exception3) {
PlayerConnection.c.error("Couldn\'t set command block", exception3); PlayerConnection.c.error("Couldn\'t set command block", exception3);
@ -1465,7 +1461,7 @@
} finally { } finally {
packetdataserializer.release(); packetdataserializer.release();
} }
@@ -1033,6 +1989,7 @@ @@ -1033,6 +1985,7 @@
} }
} catch (Exception exception4) { } catch (Exception exception4) {
PlayerConnection.c.error("Couldn\'t set beacon", 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) { } else if ("MC|ItemName".equals(packetplayincustompayload.a()) && this.player.activeContainer instanceof ContainerAnvil) {
@@ -1048,7 +2005,28 @@ @@ -1048,7 +2001,28 @@
containeranvil.a(""); containeranvil.a("");
} }
} }