-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
70915ce
commit 10afd9c
Showing
6 changed files
with
68 additions
and
1 deletion.
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
27 changes: 27 additions & 0 deletions
27
src/main/java/electrolyte/greate/compat/kubejs/GreateKubeJSPlugin.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,27 @@ | ||
package electrolyte.greate.compat.kubejs; | ||
|
||
import dev.latvian.mods.kubejs.KubeJSPlugin; | ||
import dev.latvian.mods.kubejs.recipe.schema.RecipeSchema; | ||
import dev.latvian.mods.kubejs.recipe.schema.RegisterRecipeSchemasEvent; | ||
import electrolyte.greate.content.processing.recipe.TieredProcessingRecipeSerializer; | ||
import electrolyte.greate.registry.ModRecipeTypes; | ||
|
||
import java.util.Map; | ||
|
||
public class GreateKubeJSPlugin extends KubeJSPlugin { | ||
|
||
private static final Map<ModRecipeTypes, RecipeSchema> RECIPE_SCHEMAS = Map.of( | ||
ModRecipeTypes.MILLING, TieredProcessingRecipeSchema.PROCESSING_WITH_TIME, | ||
ModRecipeTypes.CRUSHING, TieredProcessingRecipeSchema.PROCESSING_WITH_TIME | ||
); | ||
|
||
@Override | ||
public void registerRecipeSchemas(RegisterRecipeSchemasEvent event) { | ||
for(ModRecipeTypes recipeType : ModRecipeTypes.values()) { | ||
if(recipeType.getSerializer() instanceof TieredProcessingRecipeSerializer<?>) { | ||
RecipeSchema schema = RECIPE_SCHEMAS.getOrDefault(recipeType, TieredProcessingRecipeSchema.PROCESSING_DEFAULT); | ||
event.register(recipeType.getId(), schema); | ||
} | ||
} | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
src/main/java/electrolyte/greate/compat/kubejs/TieredProcessingRecipeSchema.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,30 @@ | ||
package electrolyte.greate.compat.kubejs; | ||
|
||
import dev.latvian.mods.kubejs.create.ProcessingRecipeSchema; | ||
import dev.latvian.mods.kubejs.recipe.RecipeJS; | ||
import dev.latvian.mods.kubejs.recipe.RecipeKey; | ||
import dev.latvian.mods.kubejs.recipe.component.StringComponent; | ||
import dev.latvian.mods.kubejs.recipe.schema.RecipeSchema; | ||
import electrolyte.greate.GreateEnums.TIER; | ||
|
||
import java.util.Locale; | ||
|
||
public interface TieredProcessingRecipeSchema extends ProcessingRecipeSchema { | ||
|
||
RecipeKey<String> RECIPE_TIER = new StringComponent("Invalid Recipe Tier!", s -> { | ||
for(TIER tier : TIER.values()) { | ||
if(tier.name().equalsIgnoreCase(s)) return true; | ||
} | ||
return false; | ||
}).key("recipeTier").optional("ulv"); | ||
|
||
class TieredProcessingRecipeJS extends ProcessingRecipeJS { | ||
public RecipeJS recipeTier(Object from) { | ||
return setValue(RECIPE_TIER, ((String) from).toLowerCase(Locale.ROOT)); | ||
} | ||
} | ||
|
||
RecipeSchema PROCESSING_DEFAULT = new RecipeSchema(TieredProcessingRecipeJS.class, TieredProcessingRecipeJS::new, RESULTS, INGREDIENTS, PROCESSING_TIME, HEAT_REQUIREMENT, RECIPE_TIER); | ||
RecipeSchema PROCESSING_WITH_TIME = new RecipeSchema(TieredProcessingRecipeJS.class, TieredProcessingRecipeJS::new, RESULTS, INGREDIENTS, PROCESSING_TIME_REQUIRED, HEAT_REQUIREMENT, RECIPE_TIER); | ||
RecipeSchema PROCESSING_UNWRAPPED = new RecipeSchema(TieredProcessingRecipeJS.class, TieredProcessingRecipeJS::new, RESULTS, INGREDIENTS_UNWRAPPED, PROCESSING_TIME, HEAT_REQUIREMENT, RECIPE_TIER); | ||
} |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
electrolyte.greate.compat.kubejs.GreateKubeJSPlugin |