diff --git a/build.gradle b/build.gradle index c800e0276..767f48d96 100644 --- a/build.gradle +++ b/build.gradle @@ -98,9 +98,8 @@ sourceSets { resources { srcDir "src/main/resources/" - include "assets/appliedenergistics2/recipes/*.recipe", + include "assets/appliedenergistics2/recipes/**/*.recipe", "assets/appliedenergistics2/recipes/README.html", - "assets/appliedenergistics2/oredict/*.oredict", "assets/appliedenergistics2/lang/*.lang", "assets/appliedenergistics2/textures/blocks/*", "assets/appliedenergistics2/textures/guis/*", diff --git a/src/main/java/appeng/core/RecipeLoader.java b/src/main/java/appeng/core/RecipeLoader.java index 937451445..b5668e50b 100644 --- a/src/main/java/appeng/core/RecipeLoader.java +++ b/src/main/java/appeng/core/RecipeLoader.java @@ -22,6 +22,7 @@ package appeng.core; import java.io.File; import java.io.IOException; import java.net.URISyntaxException; + import javax.annotation.Nonnull; import com.google.common.base.Preconditions; @@ -29,7 +30,6 @@ import com.google.common.base.Preconditions; import org.apache.commons.io.FileUtils; import appeng.api.recipes.IRecipeHandler; -import appeng.api.recipes.IRecipeLoader; import appeng.recipes.loader.ConfigLoader; import appeng.recipes.loader.JarLoader; import appeng.recipes.loader.RecipeResourceCopier; @@ -69,11 +69,7 @@ public class RecipeLoader implements Runnable final File readmeGenDest = new File( generatedRecipesDir, "README.html" ); final File readmeUserDest = new File( userRecipesDir, "README.html" ); - final IRecipeLoader oreDictLoader = new JarLoader( "/assets/appliedenergistics2/oredict/" ); - this.handler.parseRecipes( oreDictLoader, "vanilla.oredict" ); - this.handler.parseRecipes( oreDictLoader, "ae2.oredict" ); - - // generates generated and user recipes dir + // generates generated and user recipes dir // will clean the generated every time to keep it up to date // copies over the recipes in the jar over to the generated folder // copies over the readmes diff --git a/src/main/java/appeng/recipes/loader/RecipeResourceCopier.java b/src/main/java/appeng/recipes/loader/RecipeResourceCopier.java index 80973c9b3..f2151ef72 100644 --- a/src/main/java/appeng/recipes/loader/RecipeResourceCopier.java +++ b/src/main/java/appeng/recipes/loader/RecipeResourceCopier.java @@ -88,22 +88,60 @@ public class RecipeResourceCopier Preconditions.checkNotNull( destination ); Preconditions.checkArgument( destination.isDirectory() ); - final String[] listing = this.getResourceListing( this.getClass(), this.root ); + this.copyTo( destination, this.root ); + } + + /** + * @see {RecipeResourceCopier#copyTo(File)} + * + * @param destination destination folder to which the recipes are copied to + * @param directory the folder to copy. + * + * @throws URISyntaxException {@see #getResourceListing} + * @throws IOException {@see #getResourceListing} and if copying the detected resource to file is not possible + */ + private void copyTo( File destination, String directory ) throws URISyntaxException, IOException + { + assert destination != null; + assert directory != null; + + final String[] listing = this.getResourceListing( this.getClass(), directory ); for( String list : listing ) { if( list.endsWith( ".recipe" ) || list.endsWith( ".html" ) ) { - final InputStream inStream = this.getClass().getResourceAsStream( '/' + this.root + list ); - final File outFile = new File( destination, list ); - if( !outFile.exists() ) - { - if( inStream != null ) - { - FileUtils.copyInputStreamToFile( inStream, outFile ); - inStream.close(); - } - } + this.copyFile( destination, directory, list ); } + else if( !list.contains( "." ) ) + { + final File subDirectory = new File( destination, list ); + FileUtils.forceMkdir( subDirectory ); + this.copyTo( subDirectory, directory + list + "/" ); + } + } + } + + /** + * Copies a single file inside a folder to the destination. + * + * @param destination folder to which the file is copied to + * @param directory the directory containing the file + * @param fileName the fily to copy + * + * @throws IOException if copying the file is not possible + */ + private void copyFile( File destination, String directory, String fileName ) throws IOException + { + assert destination != null; + assert fileName != null; + + final InputStream inStream = this.getClass().getResourceAsStream( '/' + directory + fileName ); + final File outFile = new File( destination, fileName ); + + if( !outFile.exists() && inStream != null ) + { + FileUtils.copyInputStreamToFile( inStream, outFile ); + inStream.close(); } } diff --git a/src/main/resources/assets/appliedenergistics2/oredict/vanilla.oredict b/src/main/resources/assets/appliedenergistics2/oredict/vanilla.oredict deleted file mode 100644 index 0b3965285..000000000 --- a/src/main/resources/assets/appliedenergistics2/oredict/vanilla.oredict +++ /dev/null @@ -1,11 +0,0 @@ -# Forge Ore Dictionary -# logWood, slabWood, stairWood, treeSapling, treeLeaves, -# oreGold, oreIron, oreLapis, oreDiamond, oreRedstone, oreEmerald, oreQuartz, oreCoal, -# stone, cobblestone, record, stickWood, plankWood, -# dyeBlack, dyeRed, dyeGreen, dyeBrown, dyeBlue, dyePurple, dyeCyan, dyeLightGray, dyeGray, dyePink, dyeLime, dyeYellow, dyeLightBlue, dyeMagenta, dyeOrange, dyeWhite - -# Minecraft Ore Dict Entries -# Renamed for less clashing -ore=mc:quartz -> crystalNetherQuartz -ore=mc:wool:* -> blockWool -ore=mc:stained_hardened_clay:* -> blockStainedHardenedClay diff --git a/src/main/resources/assets/appliedenergistics2/recipes/README.html b/src/main/resources/assets/appliedenergistics2/recipes/README.html index 6266574c3..662caf1ce 100644 --- a/src/main/resources/assets/appliedenergistics2/recipes/README.html +++ b/src/main/resources/assets/appliedenergistics2/recipes/README.html @@ -328,6 +328,7 @@

Import