generated from CleanroomMC/TemplateDevEnv
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move static helper code to separate Helper class
- Loading branch information
1 parent
28e6dee
commit 3d41c9b
Showing
19 changed files
with
52 additions
and
47 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
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
35 changes: 35 additions & 0 deletions
35
src/main/java/com/cleanroommc/groovyscript/compat/mods/techreborn/Helper.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,35 @@ | ||
package com.cleanroommc.groovyscript.compat.mods.techreborn; | ||
|
||
import com.cleanroommc.groovyscript.api.IIngredient; | ||
import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; | ||
import com.cleanroommc.groovyscript.helper.ingredient.OreDictIngredient; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraftforge.fluids.FluidStack; | ||
import net.minecraftforge.oredict.OreDictionary; | ||
import reborncore.api.praescriptum.ingredients.input.FluidStackInputIngredient; | ||
import reborncore.api.praescriptum.ingredients.input.InputIngredient; | ||
import reborncore.api.praescriptum.ingredients.input.ItemStackInputIngredient; | ||
import reborncore.api.praescriptum.ingredients.input.OreDictionaryInputIngredient; | ||
|
||
public class Helper { | ||
|
||
public static ItemStack getStackFromIIngredient(IIngredient ingredient) { | ||
if (ingredient instanceof OreDictIngredient oreDictIngredient) { | ||
if (OreDictionary.doesOreNameExist(oreDictIngredient.getOreDict())) { | ||
return OreDictionary.getOres(oreDictIngredient.getOreDict()).get(0).copy(); | ||
} | ||
} | ||
if (IngredientHelper.isItem(ingredient)) { | ||
return IngredientHelper.toItemStack(ingredient); | ||
} | ||
if (ingredient.getMatchingStacks().length > 0) return ingredient.getMatchingStacks()[0]; | ||
return ItemStack.EMPTY; | ||
} | ||
|
||
public static InputIngredient<?> toInputIngredient(IIngredient ingredient) { | ||
if (ingredient instanceof OreDictIngredient ore) return OreDictionaryInputIngredient.of(ore.getOreDict(), ore.getAmount()); | ||
if (ingredient instanceof FluidStack fluid) return FluidStackInputIngredient.of(fluid); | ||
if (IngredientHelper.isItem(ingredient)) return ItemStackInputIngredient.of(IngredientHelper.toItemStack(ingredient)); | ||
return ItemStackInputIngredient.of(ItemStack.EMPTY); | ||
} | ||
} |
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
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