From dd11a81b43c73fc647f4b313cb9b73b6662b6bd1 Mon Sep 17 00:00:00 2001 From: Justin Aquadro Date: Thu, 10 Dec 2015 22:12:11 -0500 Subject: [PATCH] Updated erebus pack to use extended API --- packs/Erebus/build.gradle | 4 +- .../packs/erebus/StorageDrawersPack.java | 12 +-- .../packs/erebus/core/DataResolver.java | 58 +++++++++++++- .../packs/erebus/core/ModRecipes.java | 80 ------------------- .../packs/erebus/core/RefinedRelocation.java | 42 ++-------- 5 files changed, 72 insertions(+), 124 deletions(-) delete mode 100644 packs/Erebus/src/com/jaquadro/minecraft/storagedrawers/packs/erebus/core/ModRecipes.java diff --git a/packs/Erebus/build.gradle b/packs/Erebus/build.gradle index 6ac94ce..ad02755 100644 --- a/packs/Erebus/build.gradle +++ b/packs/Erebus/build.gradle @@ -17,7 +17,7 @@ buildscript { apply plugin: 'forge' -version = "1.7.10-1.0.4" +version = "1.7.10-1.1.0" group= "com.jaquadro.minecraft.storagedrawers" // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = "StorageDrawers-Erebus" @@ -26,7 +26,7 @@ minecraft { assetDir = "../../runtime/assets" replace '@VERSION@', project.version - replace 'required-after:StorageDrawers', "required-after:StorageDrawers@[1.5.8,)" + replace 'required-after:StorageDrawers', "required-after:StorageDrawers@[1.7.5,)" } sourceSets.main { diff --git a/packs/Erebus/src/com/jaquadro/minecraft/storagedrawers/packs/erebus/StorageDrawersPack.java b/packs/Erebus/src/com/jaquadro/minecraft/storagedrawers/packs/erebus/StorageDrawersPack.java index 4ed360a..53a5c38 100644 --- a/packs/Erebus/src/com/jaquadro/minecraft/storagedrawers/packs/erebus/StorageDrawersPack.java +++ b/packs/Erebus/src/com/jaquadro/minecraft/storagedrawers/packs/erebus/StorageDrawersPack.java @@ -1,6 +1,7 @@ package com.jaquadro.minecraft.storagedrawers.packs.erebus; -import com.jaquadro.minecraft.storagedrawers.api.pack.IPackDataResolver; +import com.jaquadro.minecraft.storagedrawers.api.IStorageDrawersApi; +import com.jaquadro.minecraft.storagedrawers.api.StorageDrawersApi; import com.jaquadro.minecraft.storagedrawers.packs.erebus.core.*; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.SidedProxy; @@ -16,10 +17,9 @@ public class StorageDrawersPack public static final String MOD_VERSION = "@VERSION@"; public static final String SOURCE_PATH = "com.jaquadro.minecraft.storagedrawers.packs.erebus."; - public IPackDataResolver resolver = new DataResolver(MOD_ID); + public DataResolver resolver = new DataResolver(MOD_ID); public ModBlocks blocks = new ModBlocks(); - public ModRecipes recipes = new ModRecipes(); @Mod.Instance(MOD_ID) public static StorageDrawersPack instance; @@ -35,11 +35,13 @@ public class StorageDrawersPack @Mod.EventHandler public void init (FMLInitializationEvent event) { RefinedRelocation.init(); - recipes.init(); + resolver.init(); } @Mod.EventHandler public void postInit (FMLPostInitializationEvent event) { - RefinedRelocation.postInit(); + IStorageDrawersApi api = StorageDrawersApi.instance(); + if (api != null) + api.registerStandardPackRecipes(resolver); } } diff --git a/packs/Erebus/src/com/jaquadro/minecraft/storagedrawers/packs/erebus/core/DataResolver.java b/packs/Erebus/src/com/jaquadro/minecraft/storagedrawers/packs/erebus/core/DataResolver.java index 2367e7c..5573b27 100644 --- a/packs/Erebus/src/com/jaquadro/minecraft/storagedrawers/packs/erebus/core/DataResolver.java +++ b/packs/Erebus/src/com/jaquadro/minecraft/storagedrawers/packs/erebus/core/DataResolver.java @@ -1,10 +1,14 @@ package com.jaquadro.minecraft.storagedrawers.packs.erebus.core; +import com.jaquadro.minecraft.storagedrawers.api.pack.BlockConfiguration; import com.jaquadro.minecraft.storagedrawers.api.pack.BlockType; +import com.jaquadro.minecraft.storagedrawers.api.pack.ExtendedDataResolver; import com.jaquadro.minecraft.storagedrawers.api.pack.StandardDataResolver; +import cpw.mods.fml.common.registry.GameRegistry; +import net.minecraft.block.Block; import net.minecraft.creativetab.CreativeTabs; -public class DataResolver extends StandardDataResolver +public class DataResolver extends ExtendedDataResolver { public static String[] blockNames = new String[] { "Baobab", "Eucalyptus", "Mahogany", "Mossbark", "Asper", "Cypress", null, "White", "Bamboo", "Rotten", "Marshwood", null, null, null, "Scorched", "Varnished" }; public static String[] textureNames = new String[] { "baobab", "eucalyptus", "mahogany", "mossbark", "asper", "cypress", null, "white", "bamboo", "rotten", "marshwood", null, null, null, "scorched", "varnished" }; @@ -25,4 +29,56 @@ public class DataResolver extends StandardDataResolver return textureNames[meta]; } + + @Override + public Block getBlock (BlockConfiguration blockConfig) { + switch (blockConfig.getBlockType()) { + case Drawers: + if (blockConfig.getDrawerCount() == 1) + return ModBlocks.fullDrawers1; + if (blockConfig.getDrawerCount() == 2 && !blockConfig.isHalfDepth()) + return ModBlocks.fullDrawers2; + if (blockConfig.getDrawerCount() == 4 && !blockConfig.isHalfDepth()) + return ModBlocks.fullDrawers4; + if (blockConfig.getDrawerCount() == 2 && blockConfig.isHalfDepth()) + return ModBlocks.halfDrawers2; + if (blockConfig.getDrawerCount() == 4 && blockConfig.isHalfDepth()) + return ModBlocks.halfDrawers4; + break; + case DrawersSorting: + if (blockConfig.getDrawerCount() == 1) + return RefinedRelocation.fullDrawers1; + if (blockConfig.getDrawerCount() == 2 && !blockConfig.isHalfDepth()) + return RefinedRelocation.fullDrawers2; + if (blockConfig.getDrawerCount() == 4 && !blockConfig.isHalfDepth()) + return RefinedRelocation.fullDrawers4; + if (blockConfig.getDrawerCount() == 2 && blockConfig.isHalfDepth()) + return RefinedRelocation.halfDrawers2; + if (blockConfig.getDrawerCount() == 4 && blockConfig.isHalfDepth()) + return RefinedRelocation.halfDrawers4; + break; + case Trim: + return ModBlocks.trim; + case TrimSorting: + return RefinedRelocation.trim; + } + return null; + } + + @Override + public void init () { + Block planks = GameRegistry.findBlock("erebus", "planks"); + for (int i = 0, p = 0; i < 6; i++, p++) + setPlankSlab(i, planks, p, GameRegistry.findBlock("erebus", getPlankName(getUnlocalizedName(i))), 0); + for (int i = 7, p = 7; i < 11; i++, p++) + setPlankSlab(i, planks, p, GameRegistry.findBlock("erebus", getPlankName(getUnlocalizedName(i))), 0); + for (int i = 14, p = 14; i < 15; i++, p++) + setPlankSlab(i, GameRegistry.findBlock("erebus", "planks_scorched"), p, GameRegistry.findBlock("erebus", getPlankName(getUnlocalizedName(i))), 0); + for (int i = 15, p = 15; i < 16; i++, p++) + setPlankSlab(i, GameRegistry.findBlock("erebus", "planks_varnished"), p, GameRegistry.findBlock("erebus", getPlankName(getUnlocalizedName(i))), 0); + } + + private String getPlankName (String name) { + return "slabPlanks" + Character.toUpperCase(name.charAt(0)) + name.substring(1); + } } diff --git a/packs/Erebus/src/com/jaquadro/minecraft/storagedrawers/packs/erebus/core/ModRecipes.java b/packs/Erebus/src/com/jaquadro/minecraft/storagedrawers/packs/erebus/core/ModRecipes.java deleted file mode 100644 index 2810a1d..0000000 --- a/packs/Erebus/src/com/jaquadro/minecraft/storagedrawers/packs/erebus/core/ModRecipes.java +++ /dev/null @@ -1,80 +0,0 @@ -package com.jaquadro.minecraft.storagedrawers.packs.erebus.core; - -import com.jaquadro.minecraft.storagedrawers.api.IStorageDrawersApi; -import com.jaquadro.minecraft.storagedrawers.api.StorageDrawersApi; -import com.jaquadro.minecraft.storagedrawers.api.config.IBlockConfig; -import com.jaquadro.minecraft.storagedrawers.api.pack.BlockConfiguration; -import com.jaquadro.minecraft.storagedrawers.api.pack.IPackDataResolver; -import com.jaquadro.minecraft.storagedrawers.packs.erebus.StorageDrawersPack; -import cpw.mods.fml.common.registry.GameRegistry; -import net.minecraft.block.Block; -import net.minecraft.item.ItemStack; -import net.minecraftforge.oredict.ShapedOreRecipe; - -public class ModRecipes -{ - public void init () { - IStorageDrawersApi api = StorageDrawersApi.instance(); - if (api == null) - return; - - IBlockConfig blockConfig = api.userConfig().blockConfig(); - - String nameFull1 = blockConfig.getBlockConfigName(BlockConfiguration.BasicFull1); - String nameFull2 = blockConfig.getBlockConfigName(BlockConfiguration.BasicFull2); - String nameFull4 = blockConfig.getBlockConfigName(BlockConfiguration.BasicFull4); - String nameHalf2 = blockConfig.getBlockConfigName(BlockConfiguration.BasicHalf2); - String nameHalf4 = blockConfig.getBlockConfigName(BlockConfiguration.BasicHalf4); - String nameTrim = blockConfig.getBlockConfigName(BlockConfiguration.Trim); - - Block planks = GameRegistry.findBlock("erebus", "planks"); - - IPackDataResolver resolver = StorageDrawersPack.instance.resolver; - - for (int i = 0; i < 16; i++) { - if (!resolver.isValidMetaValue(i)) - continue; - - int src = i; - if (resolver.getUnlocalizedName(i).equals("scorched")) { - planks = GameRegistry.findBlock("erebus", "planks_scorched"); - src = 0; - } - else if (resolver.getUnlocalizedName(i).equals("varnished")) { - planks = GameRegistry.findBlock("erebus", "planks_varnished"); - src = 0; - } - - if (planks != null) { - if (blockConfig.isBlockEnabled(nameFull1)) - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModBlocks.fullDrawers1, blockConfig.getBlockRecipeOutput(nameFull1), i), "xxx", " y ", "xxx", - 'x', new ItemStack(planks, 1, src), 'y', "chestWood")); - if (blockConfig.isBlockEnabled(nameFull2)) - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModBlocks.fullDrawers2, blockConfig.getBlockRecipeOutput(nameFull2), i), "xyx", "xxx", "xyx", - 'x', new ItemStack(planks, 1, src), 'y', "chestWood")); - if (blockConfig.isBlockEnabled(nameFull4)) - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModBlocks.fullDrawers4, blockConfig.getBlockRecipeOutput(nameFull4), i), "yxy", "xxx", "yxy", - 'x', new ItemStack(planks, 1, src), 'y', "chestWood")); - if (blockConfig.isBlockEnabled(nameTrim)) { - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModBlocks.trim, blockConfig.getBlockRecipeOutput(nameTrim), i), "xyx", "yyy", "xyx", - 'x', "stickWood", 'y', new ItemStack(planks, 1, src))); - } - } - - Block slab = GameRegistry.findBlock("erebus", getPlankName(resolver.getUnlocalizedName(i))); - - if (slab != null) { - if (blockConfig.isBlockEnabled(nameHalf2)) - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModBlocks.halfDrawers2, blockConfig.getBlockRecipeOutput(nameHalf2), i), "xyx", "xxx", "xyx", - 'x', new ItemStack(slab, 1), 'y', "chestWood")); - if (blockConfig.isBlockEnabled(nameHalf4)) - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModBlocks.halfDrawers4, blockConfig.getBlockRecipeOutput(nameHalf4), i), "yxy", "xxx", "yxy", - 'x', new ItemStack(slab, 1), 'y', "chestWood")); - } - } - } - - private String getPlankName (String name) { - return "slabPlanks" + Character.toUpperCase(name.charAt(0)) + name.substring(1); - } -} diff --git a/packs/Erebus/src/com/jaquadro/minecraft/storagedrawers/packs/erebus/core/RefinedRelocation.java b/packs/Erebus/src/com/jaquadro/minecraft/storagedrawers/packs/erebus/core/RefinedRelocation.java index 1fc7a51..d7f5ab1 100644 --- a/packs/Erebus/src/com/jaquadro/minecraft/storagedrawers/packs/erebus/core/RefinedRelocation.java +++ b/packs/Erebus/src/com/jaquadro/minecraft/storagedrawers/packs/erebus/core/RefinedRelocation.java @@ -9,10 +9,7 @@ import com.jaquadro.minecraft.storagedrawers.api.pack.IPackBlockFactory; import com.jaquadro.minecraft.storagedrawers.api.pack.IPackDataResolver; import com.jaquadro.minecraft.storagedrawers.packs.erebus.StorageDrawersPack; import cpw.mods.fml.common.Loader; -import cpw.mods.fml.common.registry.GameRegistry; import net.minecraft.block.Block; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; public class RefinedRelocation { @@ -21,6 +18,7 @@ public class RefinedRelocation public static Block fullDrawers4; public static Block halfDrawers2; public static Block halfDrawers4; + public static Block trim; public static void init () { IStorageDrawersApi api = StorageDrawersApi.instance(); @@ -38,12 +36,14 @@ public class RefinedRelocation fullDrawers4 = factory.createBlock(BlockConfiguration.SortingFull4, resolver); halfDrawers2 = factory.createBlock(BlockConfiguration.SortingHalf2, resolver); halfDrawers4 = factory.createBlock(BlockConfiguration.SortingHalf4, resolver); + trim = factory.createBlock(BlockConfiguration.TrimSorting, resolver); factory.bindSortingBlock(ModBlocks.fullDrawers1, fullDrawers1); factory.bindSortingBlock(ModBlocks.fullDrawers2, fullDrawers2); factory.bindSortingBlock(ModBlocks.fullDrawers4, fullDrawers4); factory.bindSortingBlock(ModBlocks.halfDrawers2, halfDrawers2); factory.bindSortingBlock(ModBlocks.halfDrawers4, halfDrawers4); + factory.bindSortingBlock(ModBlocks.trim, trim); IUserConfig config = api.userConfig(); IBlockConfig blockConfig = config.blockConfig(); @@ -58,6 +58,8 @@ public class RefinedRelocation factory.registerBlock(halfDrawers2, "halfDrawersSort2"); if (blockConfig.isBlockEnabled(blockConfig.getBlockConfigName(BlockConfiguration.SortingHalf4))) factory.registerBlock(halfDrawers4, "halfDrawersSort4"); + if (blockConfig.isBlockEnabled(blockConfig.getBlockConfigName(BlockConfiguration.TrimSorting))) + factory.registerBlock(trim, "trimSort"); if (!config.addonConfig().showAddonItemsNEI()) { factory.hideBlock(ModBlocks.getQualifiedName(fullDrawers1)); @@ -65,39 +67,7 @@ public class RefinedRelocation factory.hideBlock(ModBlocks.getQualifiedName(fullDrawers4)); factory.hideBlock(ModBlocks.getQualifiedName(halfDrawers2)); factory.hideBlock(ModBlocks.getQualifiedName(halfDrawers4)); - } - } - - public static void postInit () { - IStorageDrawersApi api = StorageDrawersApi.instance(); - if (api == null) - return; - - if (!Loader.isModLoaded("RefinedRelocation") || !api.userConfig().integrationConfig().isRefinedRelocationEnabled()) - return; - - IPackDataResolver resolver = StorageDrawersPack.instance.resolver; - IBlockConfig blockConfig = api.userConfig().blockConfig(); - - for (int i = 0; i < 16; i++) { - if (!resolver.isValidMetaValue(i)) - continue; - - if (blockConfig.isBlockEnabled(blockConfig.getBlockConfigName(BlockConfiguration.SortingFull1))) - GameRegistry.addRecipe(new ItemStack(fullDrawers1, 1, i), "x x", " y ", "x x", - 'x', Items.gold_nugget, 'y', new ItemStack(ModBlocks.fullDrawers1, 1, i)); - if (blockConfig.isBlockEnabled(blockConfig.getBlockConfigName(BlockConfiguration.SortingFull2))) - GameRegistry.addRecipe(new ItemStack(fullDrawers2, 1, i), "x x", " y ", "x x", - 'x', Items.gold_nugget, 'y', new ItemStack(ModBlocks.fullDrawers2, 1, i)); - if (blockConfig.isBlockEnabled(blockConfig.getBlockConfigName(BlockConfiguration.SortingFull4))) - GameRegistry.addRecipe(new ItemStack(halfDrawers2, 1, i), "x x", " y ", "x x", - 'x', Items.gold_nugget, 'y', new ItemStack(ModBlocks.halfDrawers2, 1, i)); - if (blockConfig.isBlockEnabled(blockConfig.getBlockConfigName(BlockConfiguration.SortingHalf2))) - GameRegistry.addRecipe(new ItemStack(fullDrawers4, 1, i), "x x", " y ", "x x", - 'x', Items.gold_nugget, 'y', new ItemStack(ModBlocks.fullDrawers4, 1, i)); - if (blockConfig.isBlockEnabled(blockConfig.getBlockConfigName(BlockConfiguration.SortingHalf4))) - GameRegistry.addRecipe(new ItemStack(halfDrawers4, 1, i), "x x", " y ", "x x", - 'x', Items.gold_nugget, 'y', new ItemStack(ModBlocks.halfDrawers4, 1, i)); + factory.hideBlock(ModBlocks.getQualifiedName(trim)); } } }