-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A week and a half of suffering ended... mostly. This needs to be reviewed. Its still not good enough. It barely works.
- Loading branch information
1 parent
c650053
commit 9ac07c9
Showing
3 changed files
with
76 additions
and
2 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
74 changes: 74 additions & 0 deletions
74
src/main/java/com/nomiceu/nomilabs/gregtech/recipe/MicroverseMap.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,74 @@ | ||
package com.nomiceu.nomilabs.gregtech.recipe; | ||
|
||
import gregtech.api.capability.impl.FluidTankList; | ||
import gregtech.api.gui.ModularUI; | ||
import gregtech.api.recipes.RecipeMap; | ||
import gregtech.api.recipes.builders.SimpleRecipeBuilder; | ||
import net.minecraftforge.items.IItemHandlerModifiable; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
/** | ||
* TODO: Refactor when GT MUI Change Rolls In | ||
*/ | ||
public class MicroverseMap extends RecipeMap<SimpleRecipeBuilder> { | ||
public MicroverseMap(@NotNull String unlocalizedName, int maxInputs, int maxOutputs, int maxFluidInputs, int maxFluidOutputs, @NotNull SimpleRecipeBuilder defaultRecipeBuilder, boolean isHidden) { | ||
super(unlocalizedName, maxInputs, maxOutputs, maxFluidInputs, maxFluidOutputs, defaultRecipeBuilder, isHidden); | ||
} | ||
|
||
@Override | ||
protected void addInventorySlotGroup(ModularUI.Builder builder, IItemHandlerModifiable itemHandler, | ||
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); | ||
/* One Change: Swap Left & Down */ | ||
int itemSlotsToLeft = inputSlotGrid[1]; | ||
int itemSlotsToDown = inputSlotGrid[0]; | ||
int startInputsX = isOutputs ? 106 : 70 - itemSlotsToLeft * 18; | ||
int startInputsY = 33 - (int) (itemSlotsToDown / 2.0 * 18) + yOffset; | ||
// yOffset - 2 is the very border | ||
if (startInputsY < yOffset - 2) | ||
startInputsY = yOffset - 2; | ||
|
||
boolean wasGroup = itemHandler.getSlots() + fluidHandler.getTanks() == 12; | ||
if (wasGroup) startInputsY -= 9; | ||
else if (itemHandler.getSlots() >= 6 && fluidHandler.getTanks() >= 2 && !isOutputs) startInputsY -= 9; | ||
for (int i = 0; i < itemSlotsToDown; i++) { | ||
for (int j = 0; j < itemSlotsToLeft; j++) { | ||
int slotIndex = i * itemSlotsToLeft + j; | ||
if (slotIndex >= itemInputsCount) break; | ||
int x = startInputsX + 18 * j; | ||
int y = startInputsY + 18 * i; | ||
addSlot(builder, x, y, slotIndex, itemHandler, fluidHandler, invertFluids, isOutputs); | ||
} | ||
} | ||
if (wasGroup) startInputsY += 2; | ||
if (fluidInputsCount > 0 || invertFluids) { | ||
if (itemSlotsToDown >= fluidInputsCount && itemSlotsToLeft < 3) { | ||
int startSpecX = isOutputs ? startInputsX + itemSlotsToLeft * 18 : startInputsX - 18; | ||
for (int i = 0; i < fluidInputsCount; i++) { | ||
int y = startInputsY + 18 * i; | ||
addSlot(builder, startSpecX, y, i, itemHandler, fluidHandler, !invertFluids, isOutputs); | ||
} | ||
} else { | ||
int startSpecY = startInputsY + itemSlotsToDown * 18; | ||
for (int i = 0; i < fluidInputsCount; i++) { | ||
int x = isOutputs ? startInputsX + 18 * (i % 3) : | ||
startInputsX + itemSlotsToLeft * 18 - 18 - 18 * (i % 3); | ||
int y = startSpecY + (i / 3) * 18; | ||
addSlot(builder, x, y, i, itemHandler, fluidHandler, !invertFluids, isOutputs); | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
|
||
} |
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