/* * This file is part of Industrial Wires. * Copyright (C) 2016-2018 malte0811 * Industrial Wires is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * Industrial Wires is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with Industrial Wires. If not, see . */ package malte0811.industrialWires.crafting; import blusunrize.immersiveengineering.api.ApiUtils; import malte0811.industrialWires.IndustrialWires; import malte0811.industrialWires.controlpanel.PanelComponent; import malte0811.industrialWires.items.ItemPanelComponent; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; import net.minecraft.util.NonNullList; import net.minecraft.world.World; import net.minecraftforge.registries.IForgeRegistryEntry; import javax.annotation.Nonnull; import javax.annotation.Nullable; public class RecipeComponentCopy extends IForgeRegistryEntry.Impl implements IRecipe { @Override public boolean matches(@Nonnull InventoryCrafting inv, @Nullable World worldIn) { boolean found = false; int foundX = -1; int foundY = -1; for (int x = 0; x < inv.getWidth(); x++) { for (int y = 0; y < inv.getHeight(); y++) { ItemStack here = inv.getStackInRowAndColumn(x, y); PanelComponent pc1 = ItemPanelComponent.componentFromStack(here); if (pc1!=null) { if (x==foundX&&y==foundY) { continue; } if (found) { return false; } if (y+10&&height>1; } @Nonnull @Override public ItemStack getRecipeOutput() { return ItemStack.EMPTY; } @Nonnull @Override public NonNullList getRemainingItems(@Nonnull InventoryCrafting inv) { return NonNullList.withSize(inv.getSizeInventory(), ItemStack.EMPTY); } @Nullable private int[] getTopComponent(@Nonnull InventoryCrafting inv) { for (int x = 0; x < inv.getWidth(); x++) { for (int y = 0; y < inv.getHeight() - 1; y++) { ItemStack here = inv.getStackInRowAndColumn(x, y); if (!here.isEmpty() && here.getItem() == IndustrialWires.panelComponent) { return new int[]{x, y}; } } } return null; } @Override public boolean isDynamic() { return true; } }