-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Almost finished. Just need to fix chemical wrappers
- Loading branch information
1 parent
6fa3b7b
commit 6323a27
Showing
44 changed files
with
593 additions
and
30 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
src/main/java/dev/latvian/mods/kubejs/mekanism/ChemicalRecipeComponents.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,16 @@ | ||
package dev.latvian.mods.kubejs.mekanism; | ||
|
||
import dev.latvian.mods.kubejs.recipe.component.RecipeComponent; | ||
import dev.latvian.mods.kubejs.recipe.component.SimpleRecipeComponent; | ||
import mekanism.api.chemical.Chemical; | ||
import mekanism.api.chemical.ChemicalStack; | ||
import mekanism.api.recipes.ingredients.ChemicalStackIngredient; | ||
import mekanism.api.recipes.ingredients.chemical.ChemicalIngredient; | ||
import mekanism.api.recipes.ingredients.creator.IngredientCreatorAccess; | ||
|
||
public interface ChemicalRecipeComponents { | ||
RecipeComponent<Chemical> CHEMICAL = new SimpleRecipeComponent<>("mekanism:chemical", Chemical.CODEC, MekanismChemicalWrapper.CHEMICAL_TYPE_INFO); | ||
RecipeComponent<ChemicalStack> CHEMICAL_STACK = new SimpleRecipeComponent<>("mekanism:chemical_stack", ChemicalStack.OPTIONAL_CODEC, MekanismChemicalWrapper.CHEMICAL_STACK_TYPE_INFO); | ||
RecipeComponent<ChemicalIngredient> CHEMICAL_INGREDIENT = new SimpleRecipeComponent<>("mekanism:chemical_ingredient", IngredientCreatorAccess.chemical().codec(), MekanismChemicalWrapper.CHEMICAL_INGREDIENT_TYPE_INFO); | ||
RecipeComponent<ChemicalStackIngredient> CHEMICAL_STACK_INGREDIENT = new SimpleRecipeComponent<>("mekanism:chemical_stack_ingredient", ChemicalStackIngredient.CODEC, MekanismChemicalWrapper.CHEMICAL_STACK_INGREDIENT_TYPE_INFO); | ||
} |
79 changes: 79 additions & 0 deletions
79
src/main/java/dev/latvian/mods/kubejs/mekanism/MekanismChemicalWrapper.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,79 @@ | ||
package dev.latvian.mods.kubejs.mekanism; | ||
|
||
import com.mojang.brigadier.StringReader; | ||
import dev.latvian.mods.rhino.type.TypeInfo; | ||
import dev.latvian.mods.rhino.util.HideFromJS; | ||
import mekanism.api.MekanismAPI; | ||
import mekanism.api.chemical.Chemical; | ||
import mekanism.api.chemical.ChemicalStack; | ||
import mekanism.api.recipes.ingredients.ChemicalStackIngredient; | ||
import mekanism.api.recipes.ingredients.chemical.ChemicalIngredient; | ||
import mekanism.api.recipes.ingredients.chemical.EmptyChemicalIngredient; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.neoforged.neoforge.fluids.FluidType; | ||
import org.codehaus.plexus.util.cli.CommandLineException; | ||
|
||
public interface MekanismChemicalWrapper { | ||
TypeInfo CHEMICAL_TYPE_INFO = TypeInfo.of(Chemical.class); | ||
TypeInfo CHEMICAL_STACK_TYPE_INFO = TypeInfo.of(ChemicalStack.class); | ||
TypeInfo CHEMICAL_INGREDIENT_TYPE_INFO = TypeInfo.of(ChemicalIngredient.class); | ||
TypeInfo CHEMICAL_STACK_INGREDIENT_TYPE_INFO = TypeInfo.of(ChemicalStackIngredient.class); | ||
|
||
static Chemical of(Object from) { | ||
return switch (from) { | ||
case null -> MekanismAPI.EMPTY_CHEMICAL; | ||
case Chemical c -> c; | ||
case ChemicalStack c -> c.getChemical(); | ||
default -> { | ||
var str = from.toString(); | ||
|
||
if (str.isEmpty() || str.equals("mekanism:empty")) { | ||
yield MekanismAPI.EMPTY_CHEMICAL; | ||
} else { | ||
yield MekanismAPI.CHEMICAL_REGISTRY.get(ResourceLocation.parse(str)); | ||
} | ||
} | ||
}; | ||
} | ||
|
||
static ChemicalStack stack(Chemical chemical, long amount) { | ||
return new ChemicalStack(chemical, amount); | ||
} | ||
|
||
private static long readAmount(StringReader reader) throws CommandLineException { | ||
// long amount = FluidWrapper.readFluidAmount(reader); | ||
return 0L; | ||
} | ||
|
||
@HideFromJS | ||
static ChemicalStack wrapStack(Object from) { | ||
return switch (from) { | ||
case null -> null; | ||
case ChemicalStack c -> c; | ||
case Chemical c -> new ChemicalStack(c, FluidType.BUCKET_VOLUME); | ||
default -> { | ||
var str = from.toString(); | ||
|
||
if (str.isEmpty() || str.equals("mekanism:empty")) { | ||
yield ChemicalStack.EMPTY; | ||
} else { | ||
yield new ChemicalStack(of(from), FluidType.BUCKET_VOLUME); | ||
} | ||
} | ||
}; | ||
} | ||
|
||
@HideFromJS | ||
static ChemicalIngredient wrapIngredient(Object from) { | ||
return EmptyChemicalIngredient.INSTANCE; | ||
} | ||
|
||
static ChemicalStackIngredient ingredientStack(ChemicalIngredient ingredient, long amount) { | ||
return new ChemicalStackIngredient(ingredient, amount); | ||
} | ||
|
||
@HideFromJS | ||
static ChemicalStackIngredient wrapStackIngredient(Object from) { | ||
return new ChemicalStackIngredient(EmptyChemicalIngredient.INSTANCE, 1); | ||
} | ||
} |
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
3 changes: 3 additions & 0 deletions
3
src/main/resources/data/mekanism/kubejs/recipe_schema/activating.json
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,3 @@ | ||
{ | ||
"parent": "mekanism:base/chemical_to_chemical" | ||
} |
20 changes: 20 additions & 0 deletions
20
...main/resources/data/mekanism/kubejs/recipe_schema/base/chemical_chemical_to_chemical.json
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,20 @@ | ||
{ | ||
"keys": [ | ||
{ | ||
"name": "output", | ||
"role": "output", | ||
"type": "mekanism:chemical_stack" | ||
}, | ||
{ | ||
"name": "left_input", | ||
"role": "input", | ||
"type": "mekanism:chemical_stack_ingredient" | ||
}, | ||
{ | ||
"name": "right_input", | ||
"role": "input", | ||
"type": "mekanism:chemical_stack_ingredient" | ||
} | ||
], | ||
"unique": ["output"] | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/resources/data/mekanism/kubejs/recipe_schema/base/chemical_to_chemical.json
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,15 @@ | ||
{ | ||
"keys": [ | ||
{ | ||
"name": "output", | ||
"role": "output", | ||
"type": "mekanism:chemical_stack" | ||
}, | ||
{ | ||
"name": "input", | ||
"role": "input", | ||
"type": "mekanism:chemical_stack_ingredient" | ||
} | ||
], | ||
"unique": ["output"] | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/resources/data/mekanism/kubejs/recipe_schema/base/chemical_to_item.json
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,15 @@ | ||
{ | ||
"keys": [ | ||
{ | ||
"name": "output", | ||
"role": "output", | ||
"type": "item_stack" | ||
}, | ||
{ | ||
"name": "input", | ||
"role": "input", | ||
"type": "mekanism:chemical_stack_ingredient" | ||
} | ||
], | ||
"unique": ["output"] | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/resources/data/mekanism/kubejs/recipe_schema/base/fluid_chemical_to_chemical.json
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,20 @@ | ||
{ | ||
"keys": [ | ||
{ | ||
"name": "output", | ||
"role": "output", | ||
"type": "mekanism:chemical_stack" | ||
}, | ||
{ | ||
"name": "fluid_input", | ||
"role": "input", | ||
"type": "flat_sized_fluid_ingredient" | ||
}, | ||
{ | ||
"name": "chemical_input", | ||
"role": "input", | ||
"type": "mekanism:chemical_stack_ingredient" | ||
} | ||
], | ||
"unique": ["output"] | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/resources/data/mekanism/kubejs/recipe_schema/base/fluid_to_fluid.json
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,15 @@ | ||
{ | ||
"keys": [ | ||
{ | ||
"name": "output", | ||
"role": "output", | ||
"type": "fluid_stack" | ||
}, | ||
{ | ||
"name": "input", | ||
"role": "input", | ||
"type": "flat_sized_fluid_ingredient" | ||
} | ||
], | ||
"unique": ["output"] | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/resources/data/mekanism/kubejs/recipe_schema/base/item_chemical_to_item.json
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,24 @@ | ||
{ | ||
"keys": [ | ||
{ | ||
"name": "output", | ||
"role": "output", | ||
"type": "item_stack" | ||
}, | ||
{ | ||
"name": "item_input", | ||
"role": "input", | ||
"type": "flat_sized_ingredient" | ||
}, | ||
{ | ||
"name": "chemical_input", | ||
"role": "input", | ||
"type": "mekanism:chemical_stack_ingredient" | ||
}, | ||
{ | ||
"name": "per_tick_usage", | ||
"type": "boolean" | ||
} | ||
], | ||
"unique": ["output"] | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/resources/data/mekanism/kubejs/recipe_schema/base/item_to_chemical.json
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,15 @@ | ||
{ | ||
"keys": [ | ||
{ | ||
"name": "output", | ||
"role": "output", | ||
"type": "mekanism:chemical_stack" | ||
}, | ||
{ | ||
"name": "input", | ||
"role": "input", | ||
"type": "flat_sized_ingredient" | ||
} | ||
], | ||
"unique": ["output"] | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/resources/data/mekanism/kubejs/recipe_schema/base/item_to_energy.json
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,15 @@ | ||
{ | ||
"keys": [ | ||
{ | ||
"name": "input", | ||
"role": "input", | ||
"type": "flat_sized_ingredient" | ||
}, | ||
{ | ||
"name": "output", | ||
"role": "output", | ||
"type": "long<1,max>" | ||
} | ||
], | ||
"unique": ["input"] | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/resources/data/mekanism/kubejs/recipe_schema/base/item_to_item.json
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,15 @@ | ||
{ | ||
"keys": [ | ||
{ | ||
"name": "output", | ||
"role": "output", | ||
"type": "item_stack" | ||
}, | ||
{ | ||
"name": "input", | ||
"role": "input", | ||
"type": "flat_sized_ingredient" | ||
} | ||
], | ||
"unique": ["output"] | ||
} |
3 changes: 3 additions & 0 deletions
3
src/main/resources/data/mekanism/kubejs/recipe_schema/bin_extract.json
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,3 @@ | ||
{ | ||
"parent": "special" | ||
} |
3 changes: 3 additions & 0 deletions
3
src/main/resources/data/mekanism/kubejs/recipe_schema/bin_insert.json
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,3 @@ | ||
{ | ||
"parent": "special" | ||
} |
3 changes: 3 additions & 0 deletions
3
src/main/resources/data/mekanism/kubejs/recipe_schema/centrifuging.json
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,3 @@ | ||
{ | ||
"parent": "mekanism:base/chemical_to_chemical" | ||
} |
3 changes: 3 additions & 0 deletions
3
src/main/resources/data/mekanism/kubejs/recipe_schema/chemical_conversion.json
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,3 @@ | ||
{ | ||
"parent": "mekanism:base/item_to_chemical" | ||
} |
3 changes: 3 additions & 0 deletions
3
src/main/resources/data/mekanism/kubejs/recipe_schema/chemical_infusing.json
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,3 @@ | ||
{ | ||
"parent": "mekanism:base/chemical_chemical_to_chemical" | ||
} |
Oops, something went wrong.