2019-04-22 23:36:14 +02:00
|
|
|
From a5eec7e0b987b7adeeb8a9ec29aaa09b003b8860 Mon Sep 17 00:00:00 2001
|
2019-01-02 04:45:52 +01:00
|
|
|
From: Michael Himing <mhiming@gmail.com>
|
|
|
|
Date: Sun, 16 Dec 2018 13:07:33 +1100
|
|
|
|
Subject: [PATCH] Fix PlayerEditBookEvent
|
|
|
|
|
|
|
|
- Updating book writing (not signing) mutated the original item, making
|
|
|
|
it impossible to properly cancel the event or modify the book meta
|
|
|
|
|
|
|
|
- When the event was cancelled, the client's book would keep the
|
|
|
|
cancelled writing
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
|
2019-04-22 23:36:14 +02:00
|
|
|
index 5c041c48fa..f63943f29f 100644
|
2019-01-02 04:45:52 +01:00
|
|
|
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
|
2019-02-05 04:39:00 +01:00
|
|
|
@@ -823,10 +823,13 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
|
2019-01-02 04:45:52 +01:00
|
|
|
|
|
|
|
this.player.setSlot(enumitemslot, CraftEventFactory.handleEditBookEvent(player, enumitemslot, itemstack1, itemstack2)); // CraftBukkit
|
|
|
|
} else {
|
|
|
|
- ItemStack old = itemstack1.cloneItemStack(); // CraftBukkit
|
|
|
|
- itemstack1.a("pages", (NBTBase) itemstack.getTag().getList("pages", 8));
|
|
|
|
- CraftEventFactory.handleEditBookEvent(player, enumitemslot, old, itemstack1); // CraftBukkit
|
|
|
|
+ // Paper start - dont mutate players current item, set it from the event
|
|
|
|
+ ItemStack newBook = itemstack1.cloneItemStack();
|
2019-01-06 18:48:24 +01:00
|
|
|
+ newBook.getOrCreateTagAndSet("pages", (NBTBase) itemstack.getTag().getList("pages", 8));
|
2019-01-02 04:45:52 +01:00
|
|
|
+ this.player.setSlot(enumitemslot, CraftEventFactory.handleEditBookEvent(player, enumitemslot, itemstack1, newBook));
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
+ player.getBukkitEntity().updateInventory(); // Paper - fix client desync when event is cancelled
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
--
|
2019-03-20 01:28:15 +01:00
|
|
|
2.21.0
|
2019-01-02 04:45:52 +01:00
|
|
|
|