Skip to content

Commit

Permalink
Merge pull request #3588 from Darkere/fix/GH-3442/fix-jei-transfer
Browse files Browse the repository at this point in the history
fix: crash when tranferring items
  • Loading branch information
raoulvdberge authored Nov 5, 2023
2 parents 1522971 + 5c2c146 commit ea71488
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
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

0 comments on commit ea71488

Please sign in to comment.