-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplify chemical import and export strategies (#32)
* Simplify chemical import and export strategies * Update actions * Ensure other chemical types attempt extraction
- Loading branch information
Showing
5 changed files
with
58 additions
and
70 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
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
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
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
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 |
---|---|---|
@@ -1,24 +1,12 @@ | ||
package me.ramidzkh.mekae2.util; | ||
|
||
import mekanism.api.chemical.ChemicalStack; | ||
import mekanism.api.chemical.gas.GasStack; | ||
import mekanism.api.chemical.infuse.InfusionStack; | ||
import mekanism.api.chemical.pigment.PigmentStack; | ||
import mekanism.api.chemical.slurry.SlurryStack; | ||
|
||
public interface ChemicalBridge { | ||
|
||
static <S extends ChemicalStack<?>> S withAmount(S stack, long amount) { | ||
if (stack instanceof GasStack gas) { | ||
return (S) new GasStack(gas, amount); | ||
} else if (stack instanceof InfusionStack infusion) { | ||
return (S) new InfusionStack(infusion, amount); | ||
} else if (stack instanceof PigmentStack pigment) { | ||
return (S) new PigmentStack(pigment, amount); | ||
} else if (stack instanceof SlurryStack slurry) { | ||
return (S) new SlurryStack(slurry, amount); | ||
} else { | ||
throw new UnsupportedOperationException(); | ||
} | ||
var copy = stack.copy(); | ||
copy.setAmount(amount); | ||
return (S) copy; | ||
} | ||
} |