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: crash when tranferring items #3588

Merged
Merged
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Fixed

- Fixed JEI transfer for larger processing recipes

## [1.12.3] - 2023-07-07

### Fixed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.MenuType;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.CraftingRecipe;
import net.minecraft.world.item.crafting.Recipe;
import net.minecraftforge.fluids.FluidStack;
import org.jetbrains.annotations.Nullable;

Expand Down Expand Up @@ -127,7 +127,13 @@ public boolean hasTransferredRecently() {
private void moveItems(GridContainerMenu gridContainer, Object recipe, IRecipeSlotsView recipeLayout, Player player) {
this.lastTransferTimeMs = System.currentTimeMillis();

if (gridContainer.getGrid().getGridType() == GridType.PATTERN && !(recipe instanceof CraftingRecipe)) {
boolean isCraftingRecipe = false;
if(recipe instanceof Recipe<?> castRecipe)
{
isCraftingRecipe = castRecipe.getType() == net.minecraft.world.item.crafting.RecipeType.CRAFTING;
}

if (gridContainer.getGrid().getGridType() == GridType.PATTERN && !isCraftingRecipe) {
moveForProcessing(recipeLayout, gridContainer, player);
} else {
move(recipeLayout);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import java.util.List;
import java.util.function.Supplier;
public class GridTransferMessage {
private final ItemStack[][] recipe = new ItemStack[9][];
private ItemStack[][] recipe;
List<List<ItemStack>> inputs;

public GridTransferMessage() {
Expand All @@ -26,6 +26,7 @@ public GridTransferMessage(List<List<ItemStack>> inputs) {
public static GridTransferMessage decode(FriendlyByteBuf buf) {
GridTransferMessage msg = new GridTransferMessage();
int slots = buf.readInt();
msg.recipe = new ItemStack[slots][];
for (int i = 0; i < slots; i++) {
int numberOfIngredients = buf.readInt();
msg.recipe[i] = new ItemStack[numberOfIngredients];
Expand Down