mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-01 16:29:45 +01:00
28 lines
2.0 KiB
Diff
28 lines
2.0 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: JRoy <joshroy126@gmail.com>
|
|
Date: Fri, 5 Jun 2020 18:24:06 -0400
|
|
Subject: [PATCH] Add and implement PlayerRecipeBookClickEvent
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
index 3493fb7f526cb713340475734f176aa52ade2d12..ff0cb2ca36f052c55f2bd37b74c33b2192a03873 100644
|
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
@@ -2778,9 +2778,14 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
|
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel());
|
|
this.player.resetLastActionTime();
|
|
if (!this.player.isSpectator() && this.player.containerMenu.containerId == packet.getContainerId() && this.player.containerMenu instanceof RecipeBookMenu) {
|
|
- this.server.getRecipeManager().byKey(packet.getRecipe()).ifPresent((irecipe) -> {
|
|
- ((RecipeBookMenu) this.player.containerMenu).handlePlacement(packet.isShiftDown(), irecipe, this.player);
|
|
+ // Paper start - fire event for clicking recipes in the recipe book
|
|
+ com.destroystokyo.paper.event.player.PlayerRecipeBookClickEvent event = new com.destroystokyo.paper.event.player.PlayerRecipeBookClickEvent(
|
|
+ player.getBukkitEntity(), org.bukkit.craftbukkit.util.CraftNamespacedKey.fromMinecraft(packet.getRecipe()), packet.isShiftDown());
|
|
+ if (event.callEvent()) {
|
|
+ this.server.getRecipeManager().byKey(org.bukkit.craftbukkit.util.CraftNamespacedKey.toMinecraft(event.getRecipe())).ifPresent((irecipe) -> {
|
|
+ ((RecipeBookMenu) this.player.containerMenu).handlePlacement(event.isMakeAll(), irecipe, this.player);
|
|
});
|
|
+ } // Paper end
|
|
}
|
|
}
|
|
|