use of com.codetaylor.mc.artisanworktables.api.recipe.IArtisanRecipe in project artisan-worktables by codetaylor.
the class PluginGameStages method processStagedRecipes.
@SideOnly(Side.CLIENT)
private void processStagedRecipes() {
if (!FMLCommonHandler.instance().getEffectiveSide().isClient()) {
return;
}
if (PluginJEI.RECIPE_REGISTRY == null) {
return;
}
EntityPlayerSP player = Minecraft.getMinecraft().player;
Collection<String> unlockedStages = GameStagesHelper.getUnlockedStages(player);
GameStagesRequirementContext context = (GameStagesRequirementContext) ArtisanAPI.getRequirementContext(new ResourceLocation(ModArtisanWorktables.MOD_ID, "gamestages"));
context.setUnlockedStages(unlockedStages);
for (String name : ArtisanAPI.getWorktableNames()) {
RecipeRegistry registry = ArtisanAPI.getWorktableRecipeRegistry(name);
if (registry != null) {
for (EnumTier tier : EnumTier.values()) {
List<IArtisanRecipe> recipeList = registry.getRecipeListByTier(new ArrayList<>(), tier);
String uid = PluginJEI.createUID(name, tier);
for (IArtisanRecipe recipe : recipeList) {
IRecipeWrapper recipeWrapper = PluginJEI.RECIPE_REGISTRY.getRecipeWrapper(recipe, uid);
if (recipeWrapper == null) {
continue;
}
IRequirement requirement = recipe.getRequirement(GameStagesRequirement.LOCATION);
// noinspection unchecked
if (requirement == null || requirement.match(context)) {
PluginJEI.RECIPE_REGISTRY.unhideRecipe(recipeWrapper);
} else {
PluginJEI.RECIPE_REGISTRY.hideRecipe(recipeWrapper);
}
}
}
}
}
}
Aggregations