Finished Thermal Expansion integration; fixed crash on creative tabs when RR integration is disabled

This commit is contained in:
Justin Aquadro committed 2015-12-10 23:08:08 -05:00
1 parent e098b4a449
commit fe1962d14d
3 files changed
+121 -25

No files matched your search

@@ -10,6 +10,7 @@ import com.jaquadro.minecraft.storagedrawers.api.registry.IRenderRegistry;
import com.jaquadro.minecraft.storagedrawers.api.registry.IWailaRegistry;
import com.jaquadro.minecraft.storagedrawers.core.api.PackFactory;
import com.jaquadro.minecraft.storagedrawers.core.api.PackRecipes;
import com.jaquadro.minecraft.storagedrawers.integration.ThermalExpansion;
public class Api implements IStorageDrawersApi
{
@@ -50,5 +51,6 @@ public class Api implements IStorageDrawersApi
public void registerStandardPackRecipes (IExtendedDataResolver resolver) {
PackRecipes.registerStandardRecipes(resolver);
PackRecipes.registerSortingRecipes(resolver);
ThermalExpansion.registerPackBlock(resolver);
}
}
@@ -139,16 +139,18 @@ public class RefinedRelocation extends IntegrationModule
private static Item getTabItem () {
ConfigManager config = StorageDrawers.config;
if (config.isBlockEnabled("fulldrawers2"))
if (config.isBlockEnabled("fulldrawers2") && fullDrawers1 != null)
return Item.getItemFromBlock(fullDrawers2);
if (config.isBlockEnabled("fulldrawers4"))
if (config.isBlockEnabled("fulldrawers4") && fullDrawers2 != null)
return Item.getItemFromBlock(fullDrawers4);
if (config.isBlockEnabled("fulldrawers1"))
if (config.isBlockEnabled("fulldrawers1") && fullDrawers4 != null)
return Item.getItemFromBlock(fullDrawers1);
if (config.isBlockEnabled("halfdrawers2"))
if (config.isBlockEnabled("halfdrawers2") && halfDrawers2 != null)
return Item.getItemFromBlock(halfDrawers2);
if (config.isBlockEnabled("halfdrawers4"))
if (config.isBlockEnabled("halfdrawers4") && halfDrawers4 != null)
return Item.getItemFromBlock(halfDrawers4);
if (config.isBlockEnabled("trim") && trim != null)
return Item.getItemFromBlock(trim);
return Item.getItemFromBlock(Blocks.chest);
}
@@ -1,15 +1,19 @@
package com.jaquadro.minecraft.storagedrawers.integration;
import com.jaquadro.minecraft.storagedrawers.api.pack.IPackBlock;
import com.jaquadro.minecraft.storagedrawers.api.pack.IPackDataResolver;
import com.jaquadro.minecraft.storagedrawers.StorageDrawers;
import com.jaquadro.minecraft.storagedrawers.api.pack.BlockConfiguration;
import com.jaquadro.minecraft.storagedrawers.api.pack.IExtendedDataResolver;
import com.jaquadro.minecraft.storagedrawers.core.ModBlocks;
import com.jaquadro.minecraft.storagedrawers.core.ModItems;
import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.common.registry.GameData;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import org.apache.logging.log4j.Level;
import java.lang.reflect.Method;
public class ThermalExpansion extends IntegrationModule
@@ -23,6 +27,8 @@ public class ThermalExpansion extends IntegrationModule
static ItemStack itemSawdust;
static boolean initialized;
@Override
public void init () throws Throwable {
clSawmillManager = Class.forName("cofh.thermalexpansion.util.crafting.SawmillManager");
@@ -35,26 +41,52 @@ public class ThermalExpansion extends IntegrationModule
itemSawdust = new ItemStack(itemMaterial, 1, 512);
for (int i = 0; i < 6; i++) {
mtSawmillAddRecipe.invoke(null, 2400, new ItemStack(ModBlocks.fullDrawers1, 1, i), new ItemStack(Blocks.planks, 6, i), itemSawdust, 100);
mtSawmillAddRecipe.invoke(null, 2400, new ItemStack(ModBlocks.fullDrawers2, 1, i), new ItemStack(Blocks.planks, 7, i), itemSawdust, 100);
mtSawmillAddRecipe.invoke(null, 2400, new ItemStack(ModBlocks.fullDrawers4, 1, i), new ItemStack(Blocks.planks, 5, i), itemSawdust, 100);
mtSawmillAddRecipe.invoke(null, 2400, new ItemStack(ModBlocks.halfDrawers2, 1, i), new ItemStack(Blocks.planks, 3, i), itemSawdust, 100);
mtSawmillAddRecipe.invoke(null, 2400, new ItemStack(ModBlocks.halfDrawers4, 1, i), new ItemStack(Blocks.planks, 2, i), itemSawdust, 100);
mtSawmillAddRecipe.invoke(null, 2400, new ItemStack(ModBlocks.trim, 1, i), new ItemStack(Blocks.planks, 5, i), itemSawdust, 100);
if (ModBlocks.fullDrawers1 != null)
mtSawmillAddRecipe.invoke(null, 2400, new ItemStack(ModBlocks.fullDrawers1, 1, i), new ItemStack(Blocks.planks, 6, i), new ItemStack(Blocks.planks, 8, 0), 100);
if (ModBlocks.fullDrawers2 != null)
mtSawmillAddRecipe.invoke(null, 2400, new ItemStack(ModBlocks.fullDrawers2, 1, i), new ItemStack(Blocks.planks, 7, i), new ItemStack(Blocks.planks, 8, 0), 100);
if (ModBlocks.fullDrawers4 != null)
mtSawmillAddRecipe.invoke(null, 2400, new ItemStack(ModBlocks.fullDrawers4, 1, i), new ItemStack(Blocks.planks, 5, i), new ItemStack(Blocks.planks, 8, 0), 100);
if (ModBlocks.halfDrawers2 != null)
mtSawmillAddRecipe.invoke(null, 2400, new ItemStack(ModBlocks.halfDrawers2, 1, i), new ItemStack(Blocks.planks, 3, i), new ItemStack(Blocks.planks, 8, 0), 100);
if (ModBlocks.halfDrawers4 != null)
mtSawmillAddRecipe.invoke(null, 2400, new ItemStack(ModBlocks.halfDrawers4, 1, i), new ItemStack(Blocks.planks, 2, i), new ItemStack(Blocks.planks, 8, 0), 100);
if (ModBlocks.trim != null)
mtSawmillAddRecipe.invoke(null, 2400, new ItemStack(ModBlocks.trim, 1, i), new ItemStack(Blocks.planks, 5, i), itemSawdust, 100);
if (RefinedRelocation.fullDrawers1 != null)
mtSawmillAddRecipe.invoke(null, 2400, new ItemStack(RefinedRelocation.fullDrawers1, 1, i), new ItemStack(Blocks.planks, 6, i), new ItemStack(Blocks.planks, 8, 0), 100);
if (RefinedRelocation.fullDrawers2 != null)
mtSawmillAddRecipe.invoke(null, 2400, new ItemStack(RefinedRelocation.fullDrawers2, 1, i), new ItemStack(Blocks.planks, 7, i), new ItemStack(Blocks.planks, 8, 0), 100);
if (RefinedRelocation.fullDrawers4 != null)
mtSawmillAddRecipe.invoke(null, 2400, new ItemStack(RefinedRelocation.fullDrawers4, 1, i), new ItemStack(Blocks.planks, 5, i), new ItemStack(Blocks.planks, 8, 0), 100);
if (RefinedRelocation.halfDrawers2 != null)
mtSawmillAddRecipe.invoke(null, 2400, new ItemStack(RefinedRelocation.halfDrawers2, 1, i), new ItemStack(Blocks.planks, 3, i), new ItemStack(Blocks.planks, 8, 0), 100);
if (RefinedRelocation.halfDrawers4 != null)
mtSawmillAddRecipe.invoke(null, 2400, new ItemStack(RefinedRelocation.halfDrawers4, 1, i), new ItemStack(Blocks.planks, 2, i), new ItemStack(Blocks.planks, 8, 0), 100);
if (RefinedRelocation.trim != null)
mtSawmillAddRecipe.invoke(null, 2400, new ItemStack(RefinedRelocation.trim, 1, i), new ItemStack(Blocks.planks, 5, i), itemSawdust, 100);
}
itemMaterial = GameData.getItemRegistry().getObject("ThermalFoundation:material");
mtPulverizerAddRecipe.invoke(null, 2400, new ItemStack(ModItems.upgrade, 1, 2), new ItemStack(itemMaterial, 2, 0), itemSawdust, 100);
mtPulverizerAddRecipe.invoke(null, 2400, new ItemStack(ModItems.upgrade, 1, 3), new ItemStack(itemMaterial, 2, 1), itemSawdust, 100);
mtPulverizerAddRecipe.invoke(null, 2400, new ItemStack(ModItems.upgrade, 1, 4), new ItemStack(itemMaterial, 2, 4), itemSawdust, 100);
mtPulverizerAddRecipe.invoke(null, 2400, new ItemStack(ModItems.upgrade, 1, 5), new ItemStack(Items.diamond, 2), itemSawdust, 100);
mtPulverizerAddRecipe.invoke(null, 2400, new ItemStack(ModItems.upgrade, 1, 6), new ItemStack(Items.emerald, 2), itemSawdust, 100);
if (StorageDrawers.config.cache.enableStorageUpgrades) {
mtPulverizerAddRecipe.invoke(null, 2400, new ItemStack(ModItems.upgrade, 1, 2), new ItemStack(itemMaterial, 2, 0), itemSawdust, 100);
mtPulverizerAddRecipe.invoke(null, 2400, new ItemStack(ModItems.upgrade, 1, 3), new ItemStack(itemMaterial, 2, 1), itemSawdust, 100);
mtPulverizerAddRecipe.invoke(null, 2400, new ItemStack(ModItems.upgrade, 1, 4), new ItemStack(itemMaterial, 2, 4), itemSawdust, 100);
mtPulverizerAddRecipe.invoke(null, 2400, new ItemStack(ModItems.upgrade, 1, 5), new ItemStack(Items.diamond, 2), itemSawdust, 100);
mtPulverizerAddRecipe.invoke(null, 2400, new ItemStack(ModItems.upgrade, 1, 6), new ItemStack(Items.emerald, 2), itemSawdust, 100);
}
mtPulverizerAddRecipe.invoke(null, 2400, new ItemStack(ModItems.upgradeStatus, 1, 1), new ItemStack(Items.redstone, 2), itemSawdust, 100);
mtPulverizerAddRecipe.invoke(null, 2400, new ItemStack(ModItems.upgradeStatus, 1, 2), new ItemStack(Items.quartz, 2), itemSawdust, 100);
if (StorageDrawers.config.cache.enableIndicatorUpgrades) {
mtPulverizerAddRecipe.invoke(null, 2400, new ItemStack(ModItems.upgradeStatus, 1, 1), new ItemStack(Items.redstone, 2), itemSawdust, 100);
mtPulverizerAddRecipe.invoke(null, 2400, new ItemStack(ModItems.upgradeStatus, 1, 2), new ItemStack(Items.quartz, 2), itemSawdust, 100);
}
mtPulverizerAddRecipe.invoke(null, 2400, new ItemStack(ModItems.upgradeVoid, 1, 1), new ItemStack(itemMaterial, 2, 4), itemSawdust, 100);
if (StorageDrawers.config.cache.enableVoidUpgrades)
mtPulverizerAddRecipe.invoke(null, 2400, new ItemStack(ModItems.upgradeVoid, 1, 1), new ItemStack(itemMaterial, 2, 4), itemSawdust, 100);
initialized = true;
}
@Override
@@ -62,9 +94,69 @@ public class ThermalExpansion extends IntegrationModule
}
/*public static void registerPackBlock (Block block, IPackBlock packBlock) {
IPackDataResolver resolver = packBlock.getDataResolver();
if (resolver == null)
public static void registerPackBlock (IExtendedDataResolver resolver) {
if (!initialized || resolver == null)
return;
}*/
Item itemMaterial = GameData.getItemRegistry().getObject(MOD_ID + ":material");
itemSawdust = new ItemStack(itemMaterial, 1, 512);
try {
Block basicFull1 = resolver.getBlock(BlockConfiguration.BasicFull1);
Block basicFull2 = resolver.getBlock(BlockConfiguration.BasicFull2);
Block basicFull4 = resolver.getBlock(BlockConfiguration.BasicFull4);
Block basicHalf2 = resolver.getBlock(BlockConfiguration.BasicHalf2);
Block basicHalf4 = resolver.getBlock(BlockConfiguration.BasicHalf4);
Block basicTrim = resolver.getBlock(BlockConfiguration.Trim);
Block sortingFull1 = resolver.getBlock(BlockConfiguration.SortingFull1);
Block sortingFull2 = resolver.getBlock(BlockConfiguration.SortingFull2);
Block sortingFull4 = resolver.getBlock(BlockConfiguration.SortingFull4);
Block sortingHalf2 = resolver.getBlock(BlockConfiguration.SortingHalf2);
Block sortingHalf4 = resolver.getBlock(BlockConfiguration.SortingHalf4);
Block sortingTrim = resolver.getBlock(BlockConfiguration.TrimSorting);
for (int i = 0; i < 16; i++) {
if (!resolver.isValidMetaValue(i))
continue;
Block plank = resolver.getPlankBlock(i);
if (plank != null) {
if (basicFull1 != null)
mtSawmillAddRecipe.invoke(null, 2400, new ItemStack(basicFull1, 1, i), new ItemStack(plank, 6, i), new ItemStack(Blocks.planks, 8, 0), 100);
if (basicFull2 != null)
mtSawmillAddRecipe.invoke(null, 2400, new ItemStack(basicFull2, 1, i), new ItemStack(plank, 7, i), new ItemStack(Blocks.planks, 8, 0), 100);
if (basicFull4 != null)
mtSawmillAddRecipe.invoke(null, 2400, new ItemStack(basicFull4, 1, i), new ItemStack(plank, 5, i), new ItemStack(Blocks.planks, 8, 0), 100);
if (basicTrim != null)
mtSawmillAddRecipe.invoke(null, 2400, new ItemStack(basicTrim, 1, i), new ItemStack(plank, 5, i), itemSawdust, 100);
if (sortingFull1 != null)
mtSawmillAddRecipe.invoke(null, 2400, new ItemStack(sortingFull1, 1, i), new ItemStack(plank, 6, i), new ItemStack(Blocks.planks, 8, 0), 100);
if (sortingFull2 != null)
mtSawmillAddRecipe.invoke(null, 2400, new ItemStack(sortingFull2, 1, i), new ItemStack(plank, 7, i), new ItemStack(Blocks.planks, 8, 0), 100);
if (sortingFull4 != null)
mtSawmillAddRecipe.invoke(null, 2400, new ItemStack(sortingFull4, 1, i), new ItemStack(plank, 5, i), new ItemStack(Blocks.planks, 8, 0), 100);
if (sortingTrim != null)
mtSawmillAddRecipe.invoke(null, 2400, new ItemStack(sortingTrim, 1, i), new ItemStack(plank, 5, i), itemSawdust, 100);
}
Block slab = resolver.getSlabBlock(i);
if (slab != null) {
if (basicHalf2 != null)
mtSawmillAddRecipe.invoke(null, 2400, new ItemStack(basicHalf2, 1, i), new ItemStack(slab, 7, i), new ItemStack(Blocks.planks, 8, 0), 100);
if (basicHalf4 != null)
mtSawmillAddRecipe.invoke(null, 2400, new ItemStack(basicHalf4, 1, i), new ItemStack(slab, 5, i), new ItemStack(Blocks.planks, 8, 0), 100);
if (sortingHalf2 != null)
mtSawmillAddRecipe.invoke(null, 2400, new ItemStack(sortingHalf2, 1, i), new ItemStack(slab, 7, i), new ItemStack(Blocks.planks, 8, 0), 100);
if (sortingHalf4 != null)
mtSawmillAddRecipe.invoke(null, 2400, new ItemStack(sortingHalf4, 1, i), new ItemStack(slab, 5, i), new ItemStack(Blocks.planks, 8, 0), 100);
}
}
}
catch (Throwable t) {
FMLLog.log(StorageDrawers.MOD_ID, Level.WARN, t, "Error registering pack block in module: " + ThermalExpansion.class.getName());
}
}
}