3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-21 05:50:05 +01:00

SPIGOT-162: Fix cancelling RIGHT_CLICK_BLOCK not cancelling used items

Dieser Commit ist enthalten in:
Thinkofdeath 2014-12-09 09:38:52 +00:00
Ursprung a6465002bf
Commit cf5a502fd4
2 geänderte Dateien mit 41 neuen und 34 gelöschten Zeilen

Datei anzeigen

@ -1,5 +1,5 @@
--- ../work/decompile-8eb82bde//net/minecraft/server/PlayerConnection.java 2014-12-07 11:03:59.465024903 +0000 --- ../work/decompile-8eb82bde//net/minecraft/server/PlayerConnection.java 2014-12-09 09:37:59.263833851 +0000
+++ src/main/java/net/minecraft/server/PlayerConnection.java 2014-12-07 11:03:41.193025101 +0000 +++ src/main/java/net/minecraft/server/PlayerConnection.java 2014-12-09 09:37:19.499834734 +0000
@@ -16,6 +16,48 @@ @@ -16,6 +16,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;
@ -390,7 +390,7 @@
ItemStack itemstack = this.player.inventory.getItemInHand(); ItemStack itemstack = this.player.inventory.getItemInHand();
boolean flag = false; boolean flag = false;
BlockPosition blockposition = packetplayinblockplace.a(); BlockPosition blockposition = packetplayinblockplace.a();
@@ -390,7 +627,40 @@ @@ -390,7 +627,42 @@
return; return;
} }
@ -420,9 +420,11 @@
+ if (movingobjectposition == null || movingobjectposition.type != EnumMovingObjectType.BLOCK) { + if (movingobjectposition == null || movingobjectposition.type != EnumMovingObjectType.BLOCK) {
+ event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.RIGHT_CLICK_AIR, itemstack); + event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.RIGHT_CLICK_AIR, itemstack);
+ } + }
+ if (event == null || event.useItemInHand() != Event.Result.DENY) { +
+ if (player.playerInteractManager.interactResult && (event == null || event.useItemInHand() != Event.Result.DENY)) {
+ this.player.playerInteractManager.useItem(this.player, this.player.world, itemstack); + this.player.playerInteractManager.useItem(this.player, this.player.world, itemstack);
+ } + }
+ player.playerInteractManager.interactResult = true;
+ +
+ // CraftBukkit - notch decrements the counter by 1 in the above method with food, + // CraftBukkit - notch decrements the counter by 1 in the above method with food,
+ // snowballs and so forth, but he does it in a place that doesn't cause the + // snowballs and so forth, but he does it in a place that doesn't cause the
@ -432,7 +434,7 @@
} else if (blockposition.getY() >= this.minecraftServer.getMaxBuildHeight() - 1 && (enumdirection == EnumDirection.UP || blockposition.getY() >= this.minecraftServer.getMaxBuildHeight())) { } else if (blockposition.getY() >= this.minecraftServer.getMaxBuildHeight() - 1 && (enumdirection == EnumDirection.UP || blockposition.getY() >= this.minecraftServer.getMaxBuildHeight())) {
ChatMessage chatmessage = new ChatMessage("build.tooHigh", new Object[] { Integer.valueOf(this.minecraftServer.getMaxBuildHeight())}); ChatMessage chatmessage = new ChatMessage("build.tooHigh", new Object[] { Integer.valueOf(this.minecraftServer.getMaxBuildHeight())});
@@ -398,9 +668,21 @@ @@ -398,9 +670,21 @@
this.player.playerConnection.sendPacket(new PacketPlayOutChat(chatmessage)); this.player.playerConnection.sendPacket(new PacketPlayOutChat(chatmessage));
flag = true; flag = true;
} else { } else {
@ -455,7 +457,7 @@
flag = true; flag = true;
} }
@@ -423,7 +705,8 @@ @@ -423,7 +707,8 @@
this.player.activeContainer.b(); this.player.activeContainer.b();
this.player.g = false; this.player.g = false;
@ -465,7 +467,7 @@
this.sendPacket(new PacketPlayOutSetSlot(this.player.activeContainer.windowId, slot.rawSlotIndex, this.player.inventory.getItemInHand())); this.sendPacket(new PacketPlayOutSetSlot(this.player.activeContainer.windowId, slot.rawSlotIndex, this.player.inventory.getItemInHand()));
} }
} }
@@ -437,8 +720,8 @@ @@ -437,8 +722,8 @@
WorldServer[] aworldserver = this.minecraftServer.worldServer; WorldServer[] aworldserver = this.minecraftServer.worldServer;
int i = aworldserver.length; int i = aworldserver.length;
@ -476,7 +478,7 @@
if (worldserver != null) { if (worldserver != null) {
entity = packetplayinspectate.a(worldserver); entity = packetplayinspectate.a(worldserver);
@@ -455,6 +738,7 @@ @@ -455,6 +740,7 @@
WorldServer worldserver1 = this.player.u(); WorldServer worldserver1 = this.player.u();
WorldServer worldserver2 = (WorldServer) entity.world; WorldServer worldserver2 = (WorldServer) entity.world;
@ -484,7 +486,7 @@
this.player.dimension = entity.dimension; this.player.dimension = entity.dimension;
this.sendPacket(new PacketPlayOutRespawn(this.player.dimension, worldserver1.getDifficulty(), worldserver1.getWorldData().getType(), this.player.playerInteractManager.getGameMode())); this.sendPacket(new PacketPlayOutRespawn(this.player.dimension, worldserver1.getDifficulty(), worldserver1.getWorldData().getType(), this.player.playerInteractManager.getGameMode()));
worldserver1.removeEntity(this.player); worldserver1.removeEntity(this.player);
@@ -472,6 +756,9 @@ @@ -472,6 +758,9 @@
this.player.playerInteractManager.a(worldserver2); this.player.playerInteractManager.a(worldserver2);
this.minecraftServer.getPlayerList().b(this.player, worldserver2); this.minecraftServer.getPlayerList().b(this.player, worldserver2);
this.minecraftServer.getPlayerList().updateClient(this.player); this.minecraftServer.getPlayerList().updateClient(this.player);
@ -494,7 +496,7 @@
} else { } else {
this.player.enderTeleportTo(entity.locX, entity.locY, entity.locZ); this.player.enderTeleportTo(entity.locX, entity.locY, entity.locZ);
} }
@@ -483,14 +770,29 @@ @@ -483,14 +772,29 @@
public void a(PacketPlayInResourcePackStatus packetplayinresourcepackstatus) {} public void a(PacketPlayInResourcePackStatus packetplayinresourcepackstatus) {}
public void a(IChatBaseComponent ichatbasecomponent) { public void a(IChatBaseComponent ichatbasecomponent) {
@ -526,7 +528,7 @@
if (this.minecraftServer.S() && this.player.getName().equals(this.minecraftServer.R())) { if (this.minecraftServer.S() && this.player.getName().equals(this.minecraftServer.R())) {
PlayerConnection.c.info("Stopping singleplayer server as player logged out"); PlayerConnection.c.info("Stopping singleplayer server as player logged out");
this.minecraftServer.safeShutdown(); this.minecraftServer.safeShutdown();
@@ -511,6 +813,15 @@ @@ -511,6 +815,15 @@
return; return;
} }
} }
@ -542,7 +544,7 @@
try { try {
this.networkManager.handle(packet); this.networkManager.handle(packet);
@@ -524,18 +835,34 @@ @@ -524,18 +837,34 @@
} }
public void a(PacketPlayInHeldItemSlot packetplayinhelditemslot) { public void a(PacketPlayInHeldItemSlot packetplayinhelditemslot) {
@ -579,7 +581,7 @@
ChatMessage chatmessage = new ChatMessage("chat.cannotSend", new Object[0]); ChatMessage chatmessage = new ChatMessage("chat.cannotSend", new Object[0]);
chatmessage.getChatModifier().setColor(EnumChatFormat.RED); chatmessage.getChatModifier().setColor(EnumChatFormat.RED);
@@ -548,39 +875,247 @@ @@ -548,39 +877,247 @@
for (int i = 0; i < s.length(); ++i) { for (int i = 0; i < s.length(); ++i) {
if (!SharedConstants.isAllowedChatCharacter(s.charAt(i))) { if (!SharedConstants.isAllowedChatCharacter(s.charAt(i))) {
@ -835,7 +837,7 @@
this.player.z(); this.player.z();
switch (SwitchHelperCommandActionType.b[packetplayinentityaction.b().ordinal()]) { switch (SwitchHelperCommandActionType.b[packetplayinentityaction.b().ordinal()]) {
case 1: case 1:
@@ -601,7 +1136,7 @@ @@ -601,7 +1138,7 @@
case 5: case 5:
this.player.a(false, true, true); this.player.a(false, true, true);
@ -844,7 +846,7 @@
break; break;
case 6: case 6:
@@ -623,6 +1158,7 @@ @@ -623,6 +1160,7 @@
} }
public void a(PacketPlayInUseEntity packetplayinuseentity) { public void a(PacketPlayInUseEntity packetplayinuseentity) {
@ -852,7 +854,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);
@@ -637,18 +1173,72 @@ @@ -637,18 +1175,72 @@
} }
if (this.player.h(entity) < d0) { if (this.player.h(entity) < d0) {
@ -926,7 +928,7 @@
} }
} }
} }
@@ -663,7 +1253,8 @@ @@ -663,7 +1255,8 @@
switch (SwitchHelperCommandActionType.c[enumclientcommand.ordinal()]) { switch (SwitchHelperCommandActionType.c[enumclientcommand.ordinal()]) {
case 1: case 1:
if (this.player.viewingCredits) { if (this.player.viewingCredits) {
@ -936,7 +938,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!");
@@ -694,11 +1285,17 @@ @@ -694,11 +1287,17 @@
} }
public void a(PacketPlayInCloseWindow packetplayinclosewindow) { public void a(PacketPlayInCloseWindow packetplayinclosewindow) {
@ -954,7 +956,7 @@
PlayerConnectionUtils.ensureMainThread(packetplayinwindowclick, this, this.player.u()); PlayerConnectionUtils.ensureMainThread(packetplayinwindowclick, this, this.player.u());
this.player.z(); this.player.z();
if (this.player.activeContainer.windowId == packetplayinwindowclick.a() && this.player.activeContainer.c(this.player)) { if (this.player.activeContainer.windowId == packetplayinwindowclick.a() && this.player.activeContainer.c(this.player)) {
@@ -711,7 +1308,269 @@ @@ -711,7 +1310,269 @@
this.player.a(this.player.activeContainer, (List) arraylist); this.player.a(this.player.activeContainer, (List) arraylist);
} else { } else {
@ -1225,7 +1227,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));
@@ -772,8 +1631,50 @@ @@ -772,8 +1633,50 @@
} }
boolean flag1 = packetplayinsetcreativeslot.a() >= 1 && packetplayinsetcreativeslot.a() < 36 + PlayerInventory.getHotbarSize(); boolean flag1 = packetplayinsetcreativeslot.a() >= 1 && packetplayinsetcreativeslot.a() < 36 + PlayerInventory.getHotbarSize();
@ -1277,7 +1279,7 @@
if (flag1 && flag2 && flag3) { if (flag1 && flag2 && flag3) {
if (itemstack == null) { if (itemstack == null) {
@@ -796,6 +1697,7 @@ @@ -796,6 +1699,7 @@
} }
public void a(PacketPlayInTransaction packetplayintransaction) { public void a(PacketPlayInTransaction packetplayintransaction) {
@ -1285,7 +1287,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);
@@ -806,6 +1708,7 @@ @@ -806,6 +1710,7 @@
} }
public void a(PacketPlayInUpdateSign packetplayinupdatesign) { public void a(PacketPlayInUpdateSign packetplayinupdatesign) {
@ -1293,7 +1295,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);
@@ -822,10 +1725,24 @@ @@ -822,10 +1727,24 @@
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");
@ -1319,7 +1321,7 @@
tileentitysign.update(); tileentitysign.update();
worldserver.notify(blockposition); worldserver.notify(blockposition);
} }
@@ -847,11 +1764,28 @@ @@ -847,11 +1766,28 @@
public void a(PacketPlayInAbilities packetplayinabilities) { public void a(PacketPlayInAbilities packetplayinabilities) {
PlayerConnectionUtils.ensureMainThread(packetplayinabilities, this, this.player.u()); PlayerConnectionUtils.ensureMainThread(packetplayinabilities, this, this.player.u());
@ -1349,7 +1351,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();
@@ -891,13 +1825,15 @@ @@ -891,13 +1827,15 @@
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()) {
@ -1366,7 +1368,7 @@
return; return;
} finally { } finally {
packetdataserializer.release(); packetdataserializer.release();
@@ -909,27 +1845,31 @@ @@ -909,27 +1847,31 @@
try { try {
itemstack = packetdataserializer.i(); itemstack = packetdataserializer.i();
@ -1410,7 +1412,7 @@
return; return;
} finally { } finally {
packetdataserializer.release(); packetdataserializer.release();
@@ -946,6 +1886,7 @@ @@ -946,6 +1888,7 @@
} }
} catch (Exception exception2) { } catch (Exception exception2) {
PlayerConnection.c.error("Couldn\'t select trade", exception2); PlayerConnection.c.error("Couldn\'t select trade", exception2);
@ -1418,7 +1420,7 @@
} }
} else if ("MC|AdvCdm".equals(packetplayincustompayload.a())) { } else if ("MC|AdvCdm".equals(packetplayincustompayload.a())) {
if (!this.minecraftServer.getEnableCommandBlock()) { if (!this.minecraftServer.getEnableCommandBlock()) {
@@ -986,6 +1927,7 @@ @@ -986,6 +1929,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);
@ -1426,7 +1428,7 @@
} finally { } finally {
packetdataserializer.release(); packetdataserializer.release();
} }
@@ -1011,6 +1953,7 @@ @@ -1011,6 +1955,7 @@
} }
} catch (Exception exception4) { } catch (Exception exception4) {
PlayerConnection.c.error("Couldn\'t set beacon", exception4); PlayerConnection.c.error("Couldn\'t set beacon", exception4);
@ -1434,7 +1436,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) {
@@ -1026,6 +1969,27 @@ @@ -1026,6 +1971,27 @@
containeranvil.a(""); containeranvil.a("");
} }
} }

Datei anzeigen

@ -1,5 +1,5 @@
--- ../work/decompile-8eb82bde//net/minecraft/server/PlayerInteractManager.java 2014-11-28 23:05:41.725278672 +0000 --- ../work/decompile-8eb82bde//net/minecraft/server/PlayerInteractManager.java 2014-12-09 09:38:37.363833006 +0000
+++ src/main/java/net/minecraft/server/PlayerInteractManager.java 2014-11-28 22:57:12.389289000 +0000 +++ src/main/java/net/minecraft/server/PlayerInteractManager.java 2014-12-09 09:38:31.515833135 +0000
@@ -1,5 +1,13 @@ @@ -1,5 +1,13 @@
package net.minecraft.server; package net.minecraft.server;
@ -202,15 +202,19 @@
return flag; return flag;
} }
@@ -268,6 +394,7 @@ @@ -266,8 +392,11 @@
} }
}
}
+
+ public boolean interactResult = true; // CraftBukkit
public boolean interact(EntityHuman entityhuman, World world, ItemStack itemstack, BlockPosition blockposition, EnumDirection enumdirection, float f, float f1, float f2) { public boolean interact(EntityHuman entityhuman, World world, ItemStack itemstack, BlockPosition blockposition, EnumDirection enumdirection, float f, float f1, float f2) {
+ /* CraftBukkit start - whole method + /* CraftBukkit start - whole method
if (this.gamemode == EnumGamemode.SPECTATOR) { if (this.gamemode == EnumGamemode.SPECTATOR) {
TileEntity tileentity = world.getTileEntity(blockposition); TileEntity tileentity = world.getTileEntity(blockposition);
@@ -312,6 +439,66 @@ @@ -312,6 +441,67 @@
return itemstack.placeItem(entityhuman, world, blockposition, enumdirection, f, f1, f2); return itemstack.placeItem(entityhuman, world, blockposition, enumdirection, f, f1, f2);
} }
} }
@ -259,6 +263,7 @@
+ result = blockdata.getBlock().interact(world, blockposition, blockdata, entityhuman, enumdirection, f, f1, f2); + result = blockdata.getBlock().interact(world, blockposition, blockdata, entityhuman, enumdirection, f, f1, f2);
+ } + }
+ +
+ interactResult = event.useItemInHand() != Event.Result.DENY;
+ if (itemstack != null && !result) { + if (itemstack != null && !result) {
+ int j1 = itemstack.getData(); + int j1 = itemstack.getData();
+ int k1 = itemstack.count; + int k1 = itemstack.count;