|
| 1 | +package gregicality.science.api.recipes.machines; |
| 2 | + |
| 3 | +import gregtech.api.capability.impl.FluidTankList; |
| 4 | +import gregtech.api.gui.GuiTextures; |
| 5 | +import gregtech.api.gui.ModularUI; |
| 6 | +import gregtech.api.gui.widgets.ProgressWidget; |
| 7 | +import gregtech.api.recipes.RecipeBuilder; |
| 8 | +import gregtech.api.recipes.RecipeMap; |
| 9 | +import net.minecraftforge.items.IItemHandlerModifiable; |
| 10 | + |
| 11 | +import javax.annotation.Nonnull; |
| 12 | + |
| 13 | +public class RecipeMapSuprachronalAssembler<R extends RecipeBuilder<R>> extends RecipeMap<R> { |
| 14 | + |
| 15 | + public RecipeMapSuprachronalAssembler(String unlocalizedName, |
| 16 | + int minInputs, int maxInputs, int minOutputs, int maxOutputs, |
| 17 | + int minFluidInputs, int maxFluidInputs, int minFluidOutputs, int maxFluidOutputs, |
| 18 | + R defaultRecipe, boolean isHidden) { |
| 19 | + super(unlocalizedName, minInputs, maxInputs, minOutputs, maxOutputs, minFluidInputs, maxFluidInputs, minFluidOutputs, maxFluidOutputs, defaultRecipe, isHidden); |
| 20 | + } |
| 21 | + |
| 22 | + @Override |
| 23 | + @Nonnull |
| 24 | + public ModularUI.Builder createJeiUITemplate(IItemHandlerModifiable importItems, IItemHandlerModifiable exportItems, FluidTankList importFluids, FluidTankList exportFluids, int yOffset) { |
| 25 | + ModularUI.Builder builder = ModularUI.builder(GuiTextures.BACKGROUND, 176, 176) |
| 26 | + .widget(new ProgressWidget(200, 80, 1, 54, 72, GuiTextures.PROGRESS_BAR_ASSEMBLY_LINE, ProgressWidget.MoveType.HORIZONTAL)); |
| 27 | + this.addInventorySlotGroup(builder, importItems, importFluids, false, yOffset); |
| 28 | + this.addInventorySlotGroup(builder, exportItems, exportFluids, true, yOffset); |
| 29 | + return builder; |
| 30 | + } |
| 31 | + |
| 32 | + @Override |
| 33 | + protected void addInventorySlotGroup(ModularUI.Builder builder, @Nonnull IItemHandlerModifiable itemHandler, @Nonnull FluidTankList fluidHandler, boolean isOutputs, int yOffset) { |
| 34 | + int itemInputsCount = itemHandler.getSlots(); |
| 35 | + int fluidInputsCount = fluidHandler.getTanks(); |
| 36 | + boolean invertFluids = false; |
| 37 | + if (itemInputsCount == 0) { |
| 38 | + int tmp = itemInputsCount; |
| 39 | + itemInputsCount = fluidInputsCount; |
| 40 | + fluidInputsCount = tmp; |
| 41 | + invertFluids = true; |
| 42 | + } |
| 43 | + int[] inputSlotGrid = determineSlotsGrid(itemInputsCount); |
| 44 | + int itemSlotsToLeft = inputSlotGrid[0]; |
| 45 | + int itemSlotsToDown = inputSlotGrid[1]; |
| 46 | + int startInputsX = 80 - itemSlotsToLeft * 18; |
| 47 | + int startInputsY = 37 - (int) (itemSlotsToDown / 2.0 * 18); |
| 48 | + |
| 49 | + if (!isOutputs) { |
| 50 | + for (int i = 0; i < itemSlotsToDown; i++) { |
| 51 | + for (int j = 0; j < itemSlotsToLeft; j++) { |
| 52 | + int slotIndex = i * itemSlotsToLeft + j/* + 1*/; // needed for data slot |
| 53 | + addSlot(builder, startInputsX + 18 * j, startInputsY + 18 * i, slotIndex, itemHandler, fluidHandler, invertFluids, false); |
| 54 | + } |
| 55 | + } |
| 56 | + if (fluidInputsCount > 0 || invertFluids) { |
| 57 | + if (itemSlotsToDown >= fluidInputsCount) { |
| 58 | + int startSpecX = startInputsX + 18 * 5; |
| 59 | + for (int i = 0; i < fluidInputsCount; i++) { |
| 60 | + addSlot(builder, startSpecX, startInputsY + 18 * i, i, itemHandler, fluidHandler, true, false); |
| 61 | + } |
| 62 | + } |
| 63 | + } |
| 64 | + } else { |
| 65 | + addSlot(builder, startInputsX + 18 * 4, 1, 0/*18*/, itemHandler, fluidHandler, invertFluids, true); // Output Slot - 18 for data slot |
| 66 | + } |
| 67 | + } |
| 68 | +} |
0 commit comments