mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-02 04:56:50 +01:00
d8847bc1f3
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: fde5602a PR-927: Add PlayerRecipeBookSettingsChangeEvent 949ff217 PR-930: Add methods to get/set evoker fang attack delay f6f7c79d SPIGOT-7514, PR-929: Add "Enchantment Roll" API to enchant items according to Minecraft mechanics d40e22da PR-712: Add API to get full result of crafting items CraftBukkit Changes: c8feb0629 PR-1291: Improve precondition message in Entity#playEffect 482c56a00 PR-1285: Add PlayerRecipeBookSettingsChangeEvent cdf798800 PR-1290: Add methods to get/set evoker fang attack delay 2c1b5f78f SPIGOT-7514, PR-1289: Add "Enchantment Roll" API to enchant items according to Minecraft mechanics 6aa644ae9 PR-992: Add API to get full result of crafting items ffb1319bc PR-1287: Fix scoreboards not updating in Player#setStatistic
55 lines
3.7 KiB
Diff
55 lines
3.7 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 3f9f2e4b64df72f3f01aed191d57766978c5886c..292a80afecb7a67e5e5900578867612d91ca82a5 100644
|
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
@@ -2959,16 +2959,40 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
|
if (!this.player.containerMenu.stillValid(this.player)) {
|
|
ServerGamePacketListenerImpl.LOGGER.debug("Player {} interacted with invalid menu {}", this.player, this.player.containerMenu);
|
|
} else {
|
|
+ // Paper start
|
|
+ ResourceLocation recipeName = packet.getRecipe();
|
|
+ boolean makeAll = packet.isShiftDown();
|
|
+ com.destroystokyo.paper.event.player.PlayerRecipeBookClickEvent paperEvent = new com.destroystokyo.paper.event.player.PlayerRecipeBookClickEvent(
|
|
+ this.player.getBukkitEntity(), org.bukkit.craftbukkit.util.CraftNamespacedKey.fromMinecraft(recipeName), makeAll
|
|
+ );
|
|
+ if (!paperEvent.callEvent()) {
|
|
+ return;
|
|
+ }
|
|
+ recipeName = CraftNamespacedKey.toMinecraft(paperEvent.getRecipe());
|
|
+ makeAll = paperEvent.isMakeAll();
|
|
+ if (org.bukkit.event.player.PlayerRecipeBookClickEvent.getHandlerList().getRegisteredListeners().length > 0) {
|
|
+ // Paper end
|
|
// CraftBukkit start - implement PlayerRecipeBookClickEvent
|
|
- org.bukkit.inventory.Recipe recipe = this.cserver.getRecipe(CraftNamespacedKey.fromMinecraft(packet.getRecipe()));
|
|
+ org.bukkit.inventory.Recipe recipe = this.cserver.getRecipe(CraftNamespacedKey.fromMinecraft(recipeName)); // Paper
|
|
if (recipe == null) {
|
|
return;
|
|
}
|
|
- org.bukkit.event.player.PlayerRecipeBookClickEvent event = CraftEventFactory.callRecipeBookClickEvent(this.player, recipe, packet.isShiftDown());
|
|
+ // Paper start
|
|
+ org.bukkit.event.player.PlayerRecipeBookClickEvent event = CraftEventFactory.callRecipeBookClickEvent(this.player, recipe, makeAll);
|
|
+ recipeName = CraftNamespacedKey.toMinecraft(((org.bukkit.Keyed) event.getRecipe()).getKey());
|
|
+ makeAll = event.isShiftClick();
|
|
+ }
|
|
+ if (!(this.player.containerMenu instanceof RecipeBookMenu<?> recipeBookMenu)) {
|
|
+ return;
|
|
+ }
|
|
+ // Paper end
|
|
|
|
// Cast to keyed should be safe as the recipe will never be a MerchantRecipe.
|
|
- this.server.getRecipeManager().byKey(CraftNamespacedKey.toMinecraft(((org.bukkit.Keyed) event.getRecipe()).getKey())).ifPresent((recipeholder) -> {
|
|
- ((RecipeBookMenu) this.player.containerMenu).handlePlacement(event.isShiftClick(), recipeholder, this.player);
|
|
+ // Paper start
|
|
+ final boolean finalMakeAll = makeAll;
|
|
+ this.server.getRecipeManager().byKey(recipeName).ifPresent((recipeholder) -> {
|
|
+ recipeBookMenu.handlePlacement(finalMakeAll, recipeholder, this.player);
|
|
+ // Paper end
|
|
});
|
|
// CraftBukkit end
|
|
}
|