Fix shiftcrafting using player (#2564)
This commit is contained in:
@@ -15,6 +15,7 @@ import net.minecraft.inventory.InventoryHelper;
|
|||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.crafting.ICraftingRecipe;
|
import net.minecraft.item.crafting.ICraftingRecipe;
|
||||||
import net.minecraft.util.NonNullList;
|
import net.minecraft.util.NonNullList;
|
||||||
|
import net.minecraftforge.common.ForgeHooks;
|
||||||
import net.minecraftforge.fml.hooks.BasicEventHooks;
|
import net.minecraftforge.fml.hooks.BasicEventHooks;
|
||||||
import net.minecraftforge.items.ItemHandlerHelper;
|
import net.minecraftforge.items.ItemHandlerHelper;
|
||||||
|
|
||||||
@@ -74,6 +75,7 @@ public class CraftingGridBehavior implements ICraftingGridBehavior {
|
|||||||
int amountCrafted = 0;
|
int amountCrafted = 0;
|
||||||
ItemStack crafted = grid.getCraftingResult().getStackInSlot(0);
|
ItemStack crafted = grid.getCraftingResult().getStackInSlot(0);
|
||||||
|
|
||||||
|
ForgeHooks.setCraftingPlayer(player);
|
||||||
// Do while the item is still craftable (aka is the result slot still the same as the original item?) and we don't exceed the max stack size.
|
// Do while the item is still craftable (aka is the result slot still the same as the original item?) and we don't exceed the max stack size.
|
||||||
do {
|
do {
|
||||||
grid.onCrafted(player);
|
grid.onCrafted(player);
|
||||||
@@ -100,6 +102,7 @@ public class CraftingGridBehavior implements ICraftingGridBehavior {
|
|||||||
// For regular crafting, this is already called in ResultCraftingGridSlot#onTake -> onCrafting(stack)
|
// For regular crafting, this is already called in ResultCraftingGridSlot#onTake -> onCrafting(stack)
|
||||||
crafted.onCrafting(player.world, player, amountCrafted);
|
crafted.onCrafting(player.world, player, amountCrafted);
|
||||||
BasicEventHooks.firePlayerCraftingEvent(player, ItemHandlerHelper.copyStackWithSize(crafted, amountCrafted), grid.getCraftingMatrix());
|
BasicEventHooks.firePlayerCraftingEvent(player, ItemHandlerHelper.copyStackWithSize(crafted, amountCrafted), grid.getCraftingMatrix());
|
||||||
|
ForgeHooks.setCraftingPlayer(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Reference in New Issue
Block a user