Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix event-itemstack for ComplexRecipe #7674

Open
wants to merge 1 commit into
base: dev/patch
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,12 @@ else if (hand == EquipmentSlot.OFF_HAND)
return null;
});
// CraftItemEvent
EventValues.registerEventValue(CraftItemEvent.class, ItemStack.class, event -> event.getRecipe().getResult());
EventValues.registerEventValue(CraftItemEvent.class, ItemStack.class, event -> {
Recipe recipe = event.getRecipe();
if (recipe instanceof ComplexRecipe)
return event.getCurrentItem();
return recipe.getResult();
});
//InventoryOpenEvent
EventValues.registerEventValue(InventoryOpenEvent.class, Player.class, event -> (Player) event.getPlayer());
EventValues.registerEventValue(InventoryOpenEvent.class, Inventory.class, InventoryEvent::getInventory);
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/ch/njol/skript/events/EvtItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerItemConsumeEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.inventory.ComplexRecipe;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.Recipe;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -173,7 +174,12 @@ public boolean check(final Event event) {
} else if (event instanceof EntityDropItemEvent) {
itemStack = ((EntityDropItemEvent) event).getItemDrop().getItemStack();
} else if (event instanceof CraftItemEvent) {
itemStack = ((CraftItemEvent) event).getRecipe().getResult();
Recipe recipe = ((CraftItemEvent) event).getRecipe();
if (recipe instanceof ComplexRecipe) {
itemStack = ((CraftItemEvent) event).getCurrentItem();
} else {
itemStack = ((CraftItemEvent) event).getRecipe().getResult();
}
} else if (hasPrepareCraftEvent && event instanceof PrepareItemCraftEvent) {
Recipe recipe = ((PrepareItemCraftEvent) event).getRecipe();
if (recipe != null) {
Expand Down