2019-07-17 00:09:32 +02:00
|
|
|
From 18fc707d6472cb98f496230b422df1ac47d76b13 Mon Sep 17 00:00:00 2001
|
2019-05-05 19:19:34 +02: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-07-17 00:09:32 +02:00
|
|
|
index 9f9482aa0..fad7f0df3 100644
|
2019-05-05 19:19:34 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
|
2019-06-03 04:19:44 +02:00
|
|
|
@@ -862,9 +862,11 @@ public class PlayerConnection implements PacketListenerPlayIn {
|
2019-05-05 19:19:34 +02:00
|
|
|
itemstack2.a("pages", (NBTBase) nbttaglist);
|
|
|
|
this.player.a(packetplayinbedit.d(), 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();
|
|
|
|
+ newBook.getOrCreateTagAndSet("pages", (NBTBase)itemstack.getTag().getList("pages", 8));
|
|
|
|
+ this.player.setSlot(enumitemslot, CraftEventFactory.handleEditBookEvent(player, enumitemslot, itemstack1, newBook));
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
--
|
2019-06-25 21:18:50 +02:00
|
|
|
2.22.0
|
2019-05-05 19:19:34 +02:00
|
|
|
|