2021-06-11 14:02:28 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
|
|
|
|
Date: Fri, 3 Jul 2020 11:58:56 -0500
|
|
|
|
Subject: [PATCH] Add PrepareResultEvent
|
|
|
|
|
|
|
|
Adds a new event for all crafting stations that generate a result slot item
|
|
|
|
|
|
|
|
Anvil, Grindstone and Smithing now extend this event
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/inventory/AnvilMenu.java b/src/main/java/net/minecraft/world/inventory/AnvilMenu.java
|
2024-01-21 19:37:09 +01:00
|
|
|
index 878d3c3089635a515fa7f54c956159a1bb6ce29b..cab3e0ba471c93764b5949ad68a0f2cce4d00099 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/inventory/AnvilMenu.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/inventory/AnvilMenu.java
|
2023-06-08 01:20:26 +02:00
|
|
|
@@ -338,6 +338,7 @@ public class AnvilMenu extends ItemCombinerMenu {
|
|
|
|
}
|
2021-06-11 14:02:28 +02:00
|
|
|
|
2023-06-08 01:20:26 +02:00
|
|
|
this.createResult();
|
2024-01-20 23:13:41 +01:00
|
|
|
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareResultEvent(this, RESULT_SLOT); // Paper - Add PrepareResultEvent
|
2023-06-08 01:20:26 +02:00
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
2021-06-11 14:02:28 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/world/inventory/CartographyTableMenu.java b/src/main/java/net/minecraft/world/inventory/CartographyTableMenu.java
|
2024-01-20 23:13:41 +01:00
|
|
|
index fe1ce65b35e83ee0ada77e44b080729346bb3c2d..ca3c8b31967a6efd7b0caacb091ab2151e7c0bee 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/inventory/CartographyTableMenu.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/inventory/CartographyTableMenu.java
|
2021-06-14 11:46:59 +02:00
|
|
|
@@ -150,6 +150,7 @@ public class CartographyTableMenu extends AbstractContainerMenu {
|
2021-06-11 14:02:28 +02:00
|
|
|
this.setupResultSlot(itemstack, itemstack1, itemstack2);
|
|
|
|
}
|
|
|
|
|
2024-01-20 23:13:41 +01:00
|
|
|
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareResultEvent(this, RESULT_SLOT); // Paper - Add PrepareResultEvent
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private void setupResultSlot(ItemStack map, ItemStack item, ItemStack oldResult) {
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/inventory/GrindstoneMenu.java b/src/main/java/net/minecraft/world/inventory/GrindstoneMenu.java
|
2024-01-20 23:13:41 +01:00
|
|
|
index 45242f0ed5a0f98953df5f27fb76874d2d9e3473..1783661f38a6f5fb655ea83953b9467bd91a1302 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/inventory/GrindstoneMenu.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/inventory/GrindstoneMenu.java
|
2021-11-24 16:07:19 +01:00
|
|
|
@@ -159,6 +159,7 @@ public class GrindstoneMenu extends AbstractContainerMenu {
|
2021-06-11 14:02:28 +02:00
|
|
|
super.slotsChanged(inventory);
|
|
|
|
if (inventory == this.repairSlots) {
|
|
|
|
this.createResult();
|
2024-01-20 23:13:41 +01:00
|
|
|
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareResultEvent(this, RESULT_SLOT); // Paper - Add PrepareResultEvent
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/inventory/ItemCombinerMenu.java b/src/main/java/net/minecraft/world/inventory/ItemCombinerMenu.java
|
2024-01-20 23:13:41 +01:00
|
|
|
index 4087e381b2250be387b608d8742f6a6009a52879..eb36a69b8da492aec9609cc9ef80d7d68ff9af03 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/inventory/ItemCombinerMenu.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/inventory/ItemCombinerMenu.java
|
2023-03-14 20:54:57 +01:00
|
|
|
@@ -110,6 +110,7 @@ public abstract class ItemCombinerMenu extends AbstractContainerMenu {
|
2021-06-11 14:02:28 +02:00
|
|
|
super.slotsChanged(inventory);
|
|
|
|
if (inventory == this.inputSlots) {
|
|
|
|
this.createResult();
|
2024-01-20 23:13:41 +01:00
|
|
|
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareResultEvent(this, this instanceof SmithingMenu ? 3 : 2); // Paper - Add PrepareResultEvent
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/inventory/LoomMenu.java b/src/main/java/net/minecraft/world/inventory/LoomMenu.java
|
2024-01-20 23:13:41 +01:00
|
|
|
index 5c209a3d81db5326f63c506077fa0bfd241b4b12..a98157f600837898dd8ef12671c4bb713e30f30c 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/inventory/LoomMenu.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/inventory/LoomMenu.java
|
2022-07-27 22:46:05 +02:00
|
|
|
@@ -248,7 +248,8 @@ public class LoomMenu extends AbstractContainerMenu {
|
2022-06-08 07:46:52 +02:00
|
|
|
this.resultSlot.set(ItemStack.EMPTY);
|
|
|
|
}
|
2021-06-11 14:02:28 +02:00
|
|
|
|
2022-06-08 07:46:52 +02:00
|
|
|
- this.broadcastChanges();
|
2024-01-20 23:13:41 +01:00
|
|
|
+ // this.broadcastChanges(); // Paper - Add PrepareResultEvent; done below
|
|
|
|
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareResultEvent(this, 3); // Paper - Add PrepareResultEvent
|
2022-06-08 07:46:52 +02:00
|
|
|
} else {
|
|
|
|
this.resultSlot.set(ItemStack.EMPTY);
|
|
|
|
this.selectablePatterns = List.of();
|
2021-06-11 14:02:28 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/world/inventory/SmithingMenu.java b/src/main/java/net/minecraft/world/inventory/SmithingMenu.java
|
2024-01-20 23:13:41 +01:00
|
|
|
index 59d9f990a87ab5214fa51e3a6e933bf5ae71b613..1e9e70263996afa294458364aa70e738b5aabea1 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/inventory/SmithingMenu.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/inventory/SmithingMenu.java
|
2023-09-22 06:40:51 +02:00
|
|
|
@@ -115,6 +115,7 @@ public class SmithingMenu extends ItemCombinerMenu {
|
2022-12-07 21:16:54 +01:00
|
|
|
}
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|
|
|
|
|
2024-01-20 23:13:41 +01:00
|
|
|
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareResultEvent(this, RESULT_SLOT); // Paper - Add PrepareResultEvent
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/inventory/StonecutterMenu.java b/src/main/java/net/minecraft/world/inventory/StonecutterMenu.java
|
2024-01-20 23:13:41 +01:00
|
|
|
index 9c2fe69ced7a46bbd8b0fbe10fa67d0a39b0f375..e40d9dbdbe5359c38af6d764d01c9be422654aaa 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/inventory/StonecutterMenu.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/inventory/StonecutterMenu.java
|
2023-09-22 06:40:51 +02:00
|
|
|
@@ -181,6 +181,7 @@ public class StonecutterMenu extends AbstractContainerMenu {
|
2021-06-11 14:02:28 +02:00
|
|
|
this.setupRecipeList(inventory, itemstack);
|
|
|
|
}
|
|
|
|
|
2024-01-20 23:13:41 +01:00
|
|
|
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareResultEvent(this, RESULT_SLOT); // Paper - Add PrepareResultEvent
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private void setupRecipeList(Container input, ItemStack stack) {
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
2024-01-21 19:37:09 +01:00
|
|
|
index 64236f5f126998157bb7bbae40ed0cd1550281e5..8ac093866aec59b4e031b953d4c3c3af66733812 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
Updated Upstream (Bukkit/CraftBukkit) (#10034)
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:
f29cb801 Separate checkstyle-suppressions file is not required
86f99bbe SPIGOT-7540, PR-946: Add ServerTickManager API
d4119585 SPIGOT-6903, PR-945: Add BlockData#getMapColor
b7a2ed41 SPIGOT-7530, PR-947: Add Player#removeResourcePack
9dd56255 SPIGOT-7527, PR-944: Add WindCharge#explode()
994a6163 Attempt upgrade of resolver libraries
CraftBukkit Changes:
b3b43a6ad Add Checkstyle check for unused imports
13fb3358e SPIGOT-7544: Scoreboard#getEntries() doesn't get entries but class names
3dda99c06 SPIGOT-7540, PR-1312: Add ServerTickManager API
2ab4508c0 SPIGOT-6903, PR-1311: Add BlockData#getMapColor
1dbdbbed4 PR-1238: Remove unnecessary sign ticking
659728d2a MC-264285, SPIGOT-7439, PR-1237: Fix unbreakable flint and steel is completely consumed while igniting creeper
e37e29ce0 Increase outdated build delay
c00438b39 SPIGOT-7530, PR-1313: Add Player#removeResourcePack
492dd80ce SPIGOT-7527, PR-1310: Add WindCharge#explode()
e11fbb9d7 Upgrade MySQL driver
9f3a0bd2a Attempt upgrade of resolver libraries
60d16d7ca PR-1306: Centralize Bukkit and Minecraft entity conversion
Spigot Changes:
06d602e7 Rebuild patches
2023-12-17 03:09:28 +01:00
|
|
|
@@ -1714,26 +1714,53 @@ public class CraftEventFactory {
|
2021-06-11 14:02:28 +02:00
|
|
|
return event;
|
|
|
|
}
|
|
|
|
|
|
|
|
- public static PrepareAnvilEvent callPrepareAnvilEvent(InventoryView view, ItemStack item) {
|
|
|
|
- PrepareAnvilEvent event = new PrepareAnvilEvent(view, CraftItemStack.asCraftMirror(item).clone());
|
|
|
|
- event.getView().getPlayer().getServer().getPluginManager().callEvent(event);
|
2024-01-20 23:13:41 +01:00
|
|
|
+ // Paper start - Add PrepareResultEvent; disable this method, handled below
|
2021-06-11 14:02:28 +02:00
|
|
|
+ public static void callPrepareAnvilEvent(InventoryView view, ItemStack item) { // Paper - verify nothing uses return - handled below in PrepareResult
|
|
|
|
+ PrepareAnvilEvent event = new PrepareAnvilEvent(view, CraftItemStack.asCraftMirror(item)); // Paper - remove clone
|
2022-12-14 06:03:57 +01:00
|
|
|
+ //event.getView().getPlayer().getServer().getPluginManager().callEvent(event); // Paper - disable event
|
2021-06-11 14:02:28 +02:00
|
|
|
event.getInventory().setItem(2, event.getResult());
|
|
|
|
- return event;
|
2024-01-20 23:13:41 +01:00
|
|
|
+ //return event;
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|
2024-01-20 23:13:41 +01:00
|
|
|
+ // Paper end - Add PrepareResultEvent
|
2021-06-11 14:02:28 +02:00
|
|
|
|
2022-12-14 06:03:57 +01:00
|
|
|
- public static PrepareGrindstoneEvent callPrepareGrindstoneEvent(InventoryView view, ItemStack item) {
|
|
|
|
- PrepareGrindstoneEvent event = new PrepareGrindstoneEvent(view, CraftItemStack.asCraftMirror(item).clone());
|
|
|
|
- event.getView().getPlayer().getServer().getPluginManager().callEvent(event);
|
2024-01-20 23:13:41 +01:00
|
|
|
+ // Paper start - Add PrepareResultEvent; disable this method, handled below
|
2022-12-14 06:03:57 +01:00
|
|
|
+ public static void callPrepareGrindstoneEvent(InventoryView view, ItemStack item) {
|
|
|
|
+ PrepareGrindstoneEvent event = new PrepareGrindstoneEvent(view, CraftItemStack.asCraftMirror(item)); // Paper - remove clone
|
|
|
|
+ // event.getView().getPlayer().getServer().getPluginManager().callEvent(event); // Paper - disable event
|
|
|
|
event.getInventory().setItem(2, event.getResult());
|
|
|
|
- return event;
|
2024-01-20 23:13:41 +01:00
|
|
|
+ // return event;
|
2022-12-14 06:03:57 +01:00
|
|
|
}
|
2024-01-20 23:13:41 +01:00
|
|
|
+ // Paper end - Add PrepareResultEvent
|
2022-12-14 06:03:57 +01:00
|
|
|
|
2021-06-11 14:02:28 +02:00
|
|
|
- public static PrepareSmithingEvent callPrepareSmithingEvent(InventoryView view, ItemStack item) {
|
|
|
|
- PrepareSmithingEvent event = new PrepareSmithingEvent(view, CraftItemStack.asCraftMirror(item).clone());
|
|
|
|
- event.getView().getPlayer().getServer().getPluginManager().callEvent(event);
|
2024-01-20 23:13:41 +01:00
|
|
|
+ // Paper start - Add PrepareResultEvent; disable this method, handled in callPrepareResultEvent
|
2021-06-11 14:02:28 +02:00
|
|
|
+ public static void callPrepareSmithingEvent(InventoryView view, ItemStack item) { // Paper - verify nothing uses return - handled below in PrepareResult
|
|
|
|
+ PrepareSmithingEvent event = new PrepareSmithingEvent(view, CraftItemStack.asCraftMirror(item)); // Paper - remove clone
|
|
|
|
+ //event.getView().getPlayer().getServer().getPluginManager().callEvent(event); // Paper - disable event
|
2023-03-15 10:33:43 +01:00
|
|
|
event.getInventory().setResult(event.getResult());
|
2021-06-11 14:02:28 +02:00
|
|
|
- return event;
|
|
|
|
+ //return event; // Paper
|
2024-01-20 23:13:41 +01:00
|
|
|
+ }
|
|
|
|
+ // Paper end - Add PrepareResultEvent
|
2021-06-11 14:02:28 +02:00
|
|
|
+
|
2024-01-21 19:37:09 +01:00
|
|
|
+ // Paper start - Add PrepareResultEvent
|
2021-06-11 14:02:28 +02:00
|
|
|
+ public static void callPrepareResultEvent(AbstractContainerMenu container, int resultSlot) {
|
|
|
|
+ com.destroystokyo.paper.event.inventory.PrepareResultEvent event;
|
|
|
|
+ InventoryView view = container.getBukkitView();
|
|
|
|
+ org.bukkit.inventory.ItemStack origItem = view.getTopInventory().getItem(resultSlot);
|
|
|
|
+ CraftItemStack result = origItem != null ? CraftItemStack.asCraftCopy(origItem) : null;
|
|
|
|
+ if (view.getTopInventory() instanceof org.bukkit.inventory.AnvilInventory) {
|
|
|
|
+ event = new PrepareAnvilEvent(view, result);
|
|
|
|
+ } else if (view.getTopInventory() instanceof org.bukkit.inventory.GrindstoneInventory) {
|
2022-12-14 06:03:57 +01:00
|
|
|
+ event = new PrepareGrindstoneEvent(view, result);
|
2021-06-11 14:02:28 +02:00
|
|
|
+ } else if (view.getTopInventory() instanceof org.bukkit.inventory.SmithingInventory) {
|
|
|
|
+ event = new PrepareSmithingEvent(view, result);
|
|
|
|
+ } else {
|
|
|
|
+ event = new com.destroystokyo.paper.event.inventory.PrepareResultEvent(view, result);
|
|
|
|
+ }
|
|
|
|
+ event.callEvent();
|
|
|
|
+ event.getInventory().setItem(resultSlot, event.getResult());
|
2021-06-17 21:37:37 +02:00
|
|
|
+ container.broadcastChanges();;
|
2024-01-20 23:13:41 +01:00
|
|
|
}
|
|
|
|
+ // Paper end - Add PrepareResultEvent
|
2021-06-11 14:02:28 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Mob spawner event.
|