Skip to content

Commit

Permalink
Changed gas siphon to check controller slots
Browse files Browse the repository at this point in the history
  • Loading branch information
RecursivePineapple committed Jul 10, 2024
1 parent 22f6682 commit d0eaa8a
Showing 1 changed file with 33 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -262,28 +262,45 @@ public boolean isCorrectMachinePart(ItemStack stack) {
*/
@Override
public @NotNull CheckRecipeResult checkProcessing() {
depth = 0;

// return early if no input busses are present, the first bus is invalid or the TE is not on a space station
if (mInputBusses.isEmpty() || !mInputBusses.get(0).isValid()) {
resetMachine(true);
resetMachine();
return SimpleCheckRecipeResult.ofFailure("no_mining_pipe");
}

if (!(this.getBaseMetaTileEntity().getWorld().provider instanceof IOrbitDimension provider)) {
resetMachine(true);
resetMachine();
return SimpleCheckRecipeResult.ofFailure("no_space_station");
}

Map<Integer, FluidStack> planetRecipes = GasSiphonRecipes.RECIPES.get(provider.getPlanetToOrbit());

// return early if there are no recipes for the planet the station is orbiting
if (planetRecipes == null) {
resetMachine(true);
resetMachine();
return CheckRecipeResultRegistry.NO_RECIPE;
}

GT_MetaTileEntity_Hatch_InputBus bus = mInputBusses.get(0);
int numPipes = 0;

// count mining pipes, get depth
for (int i = 0; i < mInventory.length; i++) {
ItemStack stack = mInventory[i];
if (stack == null) {
continue;
}
if (stack.getItem() == ItemList.Circuit_Integrated.getItem()) {
depth = stack.getItemDamage();
continue;
}
if (Objects.equals(stack.getItem(), GT_ModHandler.getIC2Item("miningPipe", 0).getItem())) {
numPipes += stack.stackSize;
}
}

for (int i = 0; i < bus.getBaseMetaTileEntity().getSizeInventory(); i++) {
ItemStack stack = bus.getBaseMetaTileEntity().getStackInSlot(i);
if (stack == null) {
Expand All @@ -298,19 +315,25 @@ public boolean isCorrectMachinePart(ItemStack stack) {
}
}

if(depth == 0) {
resetMachine();
return CheckRecipeResultRegistry.NO_RECIPE;
}

// return early if not enough mining pipes are in the input bus
if (depth == 0 || numPipes < depth * 64) {
resetMachine(false);
if (numPipes < depth * 64) {
resetMachine();
return SimpleCheckRecipeResult.ofFailure("no_mining_pipe");
}

FluidStack recipeFluid = planetRecipes.get(depth);

// return early if invalid depth
if (recipeFluid == null) {
resetMachine(true);
resetMachine();
return SimpleCheckRecipeResult.ofFailure("invalid_depth");
}

if (!canOutputAll(new FluidStack[] { recipeFluid })) {
return CheckRecipeResultRegistry.FLUID_OUTPUT_FULL;
}
Expand All @@ -323,10 +346,12 @@ public boolean isCorrectMachinePart(ItemStack stack) {
// apply recipe
if (ocLevel < 0) {
// no underclocking allowed
resetMachine(false);
resetMachine();
return CheckRecipeResultRegistry.insufficientPower(recipeEUt);
}

fluid = recipeFluid.copy();

if (ocLevel == 0) {
mEUt = -recipeEUt;
} else {
Expand Down Expand Up @@ -455,10 +480,7 @@ public boolean onSolderingToolRightClick(ForgeDirection side, ForgeDirection wre
*
* @param resetDepth should depth be reset too?
*/
private void resetMachine(boolean resetDepth) {
if (resetDepth) {
depth = 0;
}
private void resetMachine() {
mEUt = 0;
mEfficiency = 0;
}
Expand Down

0 comments on commit d0eaa8a

Please sign in to comment.