This repository has been archived by the owner on May 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
70 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
src/main/java/gregicality/science/api/recipes/machines/RecipeMapSuprachronalAssembler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package gregicality.science.api.recipes.machines; | ||
|
||
import gregtech.api.capability.impl.FluidTankList; | ||
import gregtech.api.gui.GuiTextures; | ||
import gregtech.api.gui.ModularUI; | ||
import gregtech.api.gui.widgets.ProgressWidget; | ||
import gregtech.api.recipes.RecipeBuilder; | ||
import gregtech.api.recipes.RecipeMap; | ||
import net.minecraftforge.items.IItemHandlerModifiable; | ||
|
||
import javax.annotation.Nonnull; | ||
|
||
public class RecipeMapSuprachronalAssembler<R extends RecipeBuilder<R>> extends RecipeMap<R> { | ||
|
||
public RecipeMapSuprachronalAssembler(String unlocalizedName, | ||
int minInputs, int maxInputs, int minOutputs, int maxOutputs, | ||
int minFluidInputs, int maxFluidInputs, int minFluidOutputs, int maxFluidOutputs, | ||
R defaultRecipe, boolean isHidden) { | ||
super(unlocalizedName, minInputs, maxInputs, minOutputs, maxOutputs, minFluidInputs, maxFluidInputs, minFluidOutputs, maxFluidOutputs, defaultRecipe, isHidden); | ||
} | ||
|
||
@Override | ||
@Nonnull | ||
public ModularUI.Builder createJeiUITemplate(IItemHandlerModifiable importItems, IItemHandlerModifiable exportItems, FluidTankList importFluids, FluidTankList exportFluids, int yOffset) { | ||
ModularUI.Builder builder = ModularUI.builder(GuiTextures.BACKGROUND, 176, 176) | ||
.widget(new ProgressWidget(200, 80, 1, 54, 72, GuiTextures.PROGRESS_BAR_ASSEMBLY_LINE, ProgressWidget.MoveType.HORIZONTAL)); | ||
this.addInventorySlotGroup(builder, importItems, importFluids, false, yOffset); | ||
this.addInventorySlotGroup(builder, exportItems, exportFluids, true, yOffset); | ||
return builder; | ||
} | ||
|
||
@Override | ||
protected void addInventorySlotGroup(ModularUI.Builder builder, @Nonnull IItemHandlerModifiable itemHandler, @Nonnull FluidTankList fluidHandler, boolean isOutputs, int yOffset) { | ||
int itemInputsCount = itemHandler.getSlots(); | ||
int fluidInputsCount = fluidHandler.getTanks(); | ||
boolean invertFluids = false; | ||
if (itemInputsCount == 0) { | ||
int tmp = itemInputsCount; | ||
itemInputsCount = fluidInputsCount; | ||
fluidInputsCount = tmp; | ||
invertFluids = true; | ||
} | ||
int[] inputSlotGrid = determineSlotsGrid(itemInputsCount); | ||
int itemSlotsToLeft = inputSlotGrid[0]; | ||
int itemSlotsToDown = inputSlotGrid[1]; | ||
int startInputsX = 80 - itemSlotsToLeft * 18; | ||
int startInputsY = 37 - (int) (itemSlotsToDown / 2.0 * 18); | ||
|
||
if (!isOutputs) { | ||
for (int i = 0; i < itemSlotsToDown; i++) { | ||
for (int j = 0; j < itemSlotsToLeft; j++) { | ||
int slotIndex = i * itemSlotsToLeft + j/* + 1*/; // needed for data slot | ||
addSlot(builder, startInputsX + 18 * j, startInputsY + 18 * i, slotIndex, itemHandler, fluidHandler, invertFluids, false); | ||
} | ||
} | ||
if (fluidInputsCount > 0 || invertFluids) { | ||
if (itemSlotsToDown >= fluidInputsCount) { | ||
int startSpecX = startInputsX + 18 * 5; | ||
for (int i = 0; i < fluidInputsCount; i++) { | ||
addSlot(builder, startSpecX, startInputsY + 18 * i, i, itemHandler, fluidHandler, true, false); | ||
} | ||
} | ||
} | ||
} else { | ||
addSlot(builder, startInputsX + 18 * 4, 1, 0/*18*/, itemHandler, fluidHandler, invertFluids, true); // Output Slot - 18 for data slot | ||
} | ||
} | ||
} |