2021-06-11 14:02:28 +02:00
|
|
|
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
|
2022-06-09 10:51:45 +02:00
|
|
|
index 7a9eba48e261b36c1ea0def38bda02fbb46dcdf7..cebd8d590fa8ba823a3df9a5780a4398bab8ed38 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
2022-06-08 07:02:19 +02:00
|
|
|
@@ -2996,9 +2996,14 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
2021-06-11 14:02:28 +02:00
|
|
|
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel());
|
|
|
|
this.player.resetLastActionTime();
|
2021-06-14 10:37:14 +02:00
|
|
|
if (!this.player.isSpectator() && this.player.containerMenu.containerId == packet.getContainerId() && this.player.containerMenu instanceof RecipeBookMenu) {
|
2021-06-11 14:02:28 +02:00
|
|
|
- this.server.getRecipeManager().byKey(packet.getRecipe()).ifPresent((irecipe) -> {
|
|
|
|
- ((RecipeBookMenu) this.player.containerMenu).handlePlacement(packet.isShiftDown(), irecipe, this.player);
|
2022-04-24 03:48:00 +02:00
|
|
|
- });
|
2021-06-11 14:02:28 +02:00
|
|
|
+ // 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());
|
2022-04-24 03:48:00 +02:00
|
|
|
+ if (event.callEvent() && this.player.containerMenu instanceof RecipeBookMenu<?> recipeBookMenu) { // check if inventory changed during event handling
|
2021-06-11 14:02:28 +02:00
|
|
|
+ this.server.getRecipeManager().byKey(org.bukkit.craftbukkit.util.CraftNamespacedKey.toMinecraft(event.getRecipe())).ifPresent((irecipe) -> {
|
2022-04-24 03:48:00 +02:00
|
|
|
+ recipeBookMenu.handlePlacement(event.isMakeAll(), irecipe, this.player);
|
|
|
|
+ });
|
2021-06-14 10:37:14 +02:00
|
|
|
+ } // Paper end
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|