mirror of
https://github.com/GTNewHorizons/StorageDrawers.git
synced 2026-11-18 11:29:31 +00:00
Refactor mods integration (#62)
This commit is contained in:
1 parent
fadf198e2e
commit
4e88ffa190
19 files changed
+268
-258
No files matched your search
@@ -54,7 +54,7 @@ import com.jaquadro.minecraft.storagedrawers.block.tile.TileEntityDrawersStandar
|
||||
import com.jaquadro.minecraft.storagedrawers.core.ModCreativeTabs;
|
||||
import com.jaquadro.minecraft.storagedrawers.core.ModItems;
|
||||
import com.jaquadro.minecraft.storagedrawers.core.handlers.GuiHandler;
|
||||
import com.jaquadro.minecraft.storagedrawers.integration.BackhandIntegrationModule;
|
||||
import com.jaquadro.minecraft.storagedrawers.integration.IntegrationRegistry;
|
||||
import com.jaquadro.minecraft.storagedrawers.item.ItemPersonalKey;
|
||||
import com.jaquadro.minecraft.storagedrawers.item.ItemTrim;
|
||||
import com.jaquadro.minecraft.storagedrawers.item.ItemUpgrade;
|
||||
@@ -313,7 +313,7 @@ public class BlockDrawers extends BlockContainer implements INetworked {
|
||||
|
||||
if (itemStack.hasDisplayName()) tile.setInventoryName(itemStack.getDisplayName());
|
||||
|
||||
if (BackhandIntegrationModule.isEnabled() && entity instanceof EntityPlayer) {
|
||||
if (entity instanceof EntityPlayer && IntegrationRegistry.instance().isModuleLoaded("backhand")) {
|
||||
ItemStack offhandItem = BackhandUtils.getOffhandItem((EntityPlayer) entity);
|
||||
useKey(tile, (EntityPlayer) entity, offhandItem, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
@@ -165,18 +165,12 @@ public class GuiDrawers extends GuiContainer {
|
||||
}
|
||||
|
||||
private RenderItem setItemRender(RenderItem renderItem) {
|
||||
if (IntegrationRegistry.instance().isModLoaded("NotEnoughItems"))
|
||||
if (IntegrationRegistry.instance().isModuleLoaded("NotEnoughItems")) {
|
||||
return NotEnoughItems.setItemRender(renderItem);
|
||||
else {
|
||||
} else {
|
||||
RenderItem prev = itemRender;
|
||||
itemRender = renderItem;
|
||||
|
||||
return prev;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* @Override public void func_146977_a (Slot slot) { RenderItem ri = setItemRender(storageItemRender);
|
||||
* super.func_146977_a(slot); setItemRender(ri); }
|
||||
*/
|
||||
}
|
||||
@@ -13,8 +13,7 @@ import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.core.recipe.FallbackShapedOreRecipe;
|
||||
import com.jaquadro.minecraft.storagedrawers.core.recipe.TemplateRecipe;
|
||||
import com.jaquadro.minecraft.storagedrawers.integration.ChiselIntegrationModule;
|
||||
import com.jaquadro.minecraft.storagedrawers.integration.GTNHIntegrationModule;
|
||||
import com.jaquadro.minecraft.storagedrawers.integration.IntegrationRegistry;
|
||||
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
@@ -23,13 +22,13 @@ public class ModRecipes {
|
||||
public void init() {
|
||||
OreDictionary.registerOre("chestWood", new ItemStack(Blocks.chest)); // Remove when porting to 1.8
|
||||
|
||||
if (GTNHIntegrationModule.isEnabled()) return;
|
||||
if (IntegrationRegistry.instance().isModuleLoaded("dreamcraft")) return;
|
||||
RecipeSorter.register(
|
||||
"StorageDrawers:FallbackShapedOreRecipe",
|
||||
FallbackShapedOreRecipe.class,
|
||||
RecipeSorter.Category.SHAPED,
|
||||
"after:forge:shapedore");
|
||||
if (!ChiselIntegrationModule.isEnabled()) {
|
||||
if (!IntegrationRegistry.instance().isModuleLoaded("chisel")) {
|
||||
for (int i = 0; i < BlockWood.field_150096_a.length; i++) {
|
||||
if (config.isBlockEnabled("fulldrawers1")) GameRegistry.addRecipe(
|
||||
new ShapedOreRecipe(
|
||||
@@ -95,7 +94,7 @@ public class ModRecipes {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (config.cache.enableFallbackRecipes || ChiselIntegrationModule.isEnabled()) {
|
||||
if (config.cache.enableFallbackRecipes || IntegrationRegistry.instance().isModuleLoaded("chisel")) {
|
||||
if (config.isBlockEnabled("fulldrawers1")) GameRegistry.addRecipe(
|
||||
new FallbackShapedOreRecipe(
|
||||
new ItemStack(ModBlocks.fullDrawers1, config.getBlockRecipeOutput("fulldrawers1"), 0),
|
||||
|
||||
@@ -35,15 +35,16 @@ public class PackFactory implements IPackBlockFactory {
|
||||
return new BlockDrawersPack(dataResolver, blockConfig.getDrawerCount(), blockConfig.isHalfDepth())
|
||||
.setConfigName(getConfigName(blockConfig));
|
||||
case DrawersSorting:
|
||||
if (IntegrationRegistry.instance().isModLoaded("RefinedRelocation")) return new BlockSortingDrawersPack(
|
||||
dataResolver,
|
||||
blockConfig.getDrawerCount(),
|
||||
blockConfig.isHalfDepth()).setConfigName(getConfigName(blockConfig));
|
||||
if (IntegrationRegistry.instance().isModuleLoaded("RefinedRelocation"))
|
||||
return new BlockSortingDrawersPack(
|
||||
dataResolver,
|
||||
blockConfig.getDrawerCount(),
|
||||
blockConfig.isHalfDepth()).setConfigName(getConfigName(blockConfig));
|
||||
return null;
|
||||
case Trim:
|
||||
return new BlockTrimPack(dataResolver);
|
||||
case TrimSorting:
|
||||
if (IntegrationRegistry.instance().isModLoaded("RefinedRelocation"))
|
||||
if (IntegrationRegistry.instance().isModuleLoaded("RefinedRelocation"))
|
||||
return new BlockSortingTrimPack(dataResolver);
|
||||
return null;
|
||||
default:
|
||||
@@ -67,7 +68,9 @@ public class PackFactory implements IPackBlockFactory {
|
||||
} else if (block instanceof BlockSortingTrimPack)
|
||||
GameRegistry.registerBlock(block, ItemSortingTrimPack.class, name);
|
||||
else if (block instanceof BlockTrimPack) GameRegistry.registerBlock(block, ItemTrimPack.class, name);
|
||||
ChiselIntegrationModule.registerPackBlock(block);
|
||||
if (IntegrationRegistry.instance().isModuleLoaded("chisel")) {
|
||||
ChiselIntegrationModule.registerPackBlock(block);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+48
-52
@@ -2,6 +2,8 @@ package com.jaquadro.minecraft.storagedrawers.integration;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.StorageDrawers;
|
||||
import com.jaquadro.minecraft.storagedrawers.integration.ae2.DrawerExternalStorageHandler;
|
||||
import com.jaquadro.minecraft.storagedrawers.integration.ae2.IStorageBusMonitorFactory;
|
||||
@@ -16,26 +18,60 @@ import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
|
||||
public class AppliedEnergistics extends IntegrationModule {
|
||||
public final class AppliedEnergistics extends IntegrationModule {
|
||||
|
||||
private IStorageBusMonitorFactory factory;
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getModID() {
|
||||
return "appliedenergistics2";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean moduleConfig() {
|
||||
return StorageDrawers.config.cache.enableAE2Integration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() throws Throwable {
|
||||
ShapedRecipeHandler shapedHandler = new ShapedRecipeHandler();
|
||||
if (shapedHandler.isValid()) {
|
||||
StorageDrawers.recipeHandlerRegistry.registerRecipeHandler(shapedHandler.getRecipeClass(), shapedHandler);
|
||||
}
|
||||
|
||||
ShapelessRecipeHandler shapelessHandler = new ShapelessRecipeHandler();
|
||||
if (shapelessHandler.isValid()) {
|
||||
StorageDrawers.recipeHandlerRegistry
|
||||
.registerRecipeHandler(shapelessHandler.getRecipeClass(), shapelessHandler);
|
||||
}
|
||||
|
||||
StorageDrawers.recipeHandlerRegistry.registerIngredientHandler(IIngredient.class, new IngredientHandler());
|
||||
|
||||
ReflectionFactory rfactory = new ReflectionFactory();
|
||||
if (!rfactory.init()) throw new Exception("No valid Storage Bus Monitor factory");
|
||||
|
||||
factory = rfactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit() {
|
||||
AEApi.instance().registries().externalStorage()
|
||||
.addExternalStorageInterface(new DrawerExternalStorageHandler(factory));
|
||||
}
|
||||
|
||||
private static class ReflectionFactory implements IStorageBusMonitorFactory {
|
||||
|
||||
private Class classInventoryAdaptor;
|
||||
private Class classMEAdaptor;
|
||||
private Class classMonitor;
|
||||
|
||||
private Constructor constMEAdaptor;
|
||||
private Constructor constMonitor;
|
||||
private Constructor<?> constMEAdaptor;
|
||||
private Constructor<?> constMonitor;
|
||||
|
||||
public boolean init() {
|
||||
try {
|
||||
classInventoryAdaptor = Class.forName("appeng.util.InventoryAdaptor");
|
||||
classMEAdaptor = Class.forName("appeng.util.inv.IMEAdaptor");
|
||||
classMonitor = Class.forName("appeng.me.storage.MEMonitorIInventory");
|
||||
|
||||
Class<?> classInventoryAdaptor = Class.forName("appeng.util.InventoryAdaptor");
|
||||
Class<?> classMEAdaptor = Class.forName("appeng.util.inv.IMEAdaptor");
|
||||
Class<?> classMonitor = Class.forName("appeng.me.storage.MEMonitorIInventory");
|
||||
constMEAdaptor = classMEAdaptor.getConstructor(IMEInventory.class, BaseActionSource.class);
|
||||
constMonitor = classMonitor.getConstructor(classInventoryAdaptor);
|
||||
|
||||
return true;
|
||||
} catch (Throwable t) {
|
||||
return false;
|
||||
@@ -55,44 +91,4 @@ public class AppliedEnergistics extends IntegrationModule {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class APIFactory implements IStorageBusMonitorFactory {
|
||||
|
||||
@Override
|
||||
public IMEMonitor<IAEItemStack> createStorageBusMonitor(IMEInventory<IAEItemStack> inventory,
|
||||
BaseActionSource src) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private IStorageBusMonitorFactory factory;
|
||||
|
||||
@Override
|
||||
public String getModID() {
|
||||
return "appliedenergistics2";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() throws Throwable {
|
||||
ShapedRecipeHandler shapedHandler = new ShapedRecipeHandler();
|
||||
if (shapedHandler.isValid())
|
||||
StorageDrawers.recipeHandlerRegistry.registerRecipeHandler(shapedHandler.getRecipeClass(), shapedHandler);
|
||||
|
||||
ShapelessRecipeHandler shapelessHandler = new ShapelessRecipeHandler();
|
||||
if (shapelessHandler.isValid()) StorageDrawers.recipeHandlerRegistry
|
||||
.registerRecipeHandler(shapelessHandler.getRecipeClass(), shapelessHandler);
|
||||
|
||||
StorageDrawers.recipeHandlerRegistry.registerIngredientHandler(IIngredient.class, new IngredientHandler());
|
||||
|
||||
ReflectionFactory rfactory = new ReflectionFactory();
|
||||
if (!rfactory.init()) throw new Exception("No valid Storage Bus Monitor factory");
|
||||
|
||||
factory = rfactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit() {
|
||||
AEApi.instance().registries().externalStorage()
|
||||
.addExternalStorageInterface(new DrawerExternalStorageHandler(factory));
|
||||
}
|
||||
}
|
||||
+6
-17
@@ -1,30 +1,19 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.integration;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.StorageDrawers;
|
||||
|
||||
import cpw.mods.fml.common.Loader;
|
||||
|
||||
public class BackhandIntegrationModule extends IntegrationModule {
|
||||
|
||||
private static final boolean BACKHAND_ENABLED = Loader.isModLoaded("backhand")
|
||||
&& StorageDrawers.config.integrationConfig.isBackhandEnabled();
|
||||
public final class BackhandIntegrationModule extends IntegrationModule {
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getModID() {
|
||||
return "backhand";
|
||||
}
|
||||
|
||||
public static boolean isEnabled() {
|
||||
return BACKHAND_ENABLED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() throws Throwable {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit() {
|
||||
|
||||
protected boolean moduleConfig() {
|
||||
return StorageDrawers.config.integrationConfig.isBackhandEnabled();
|
||||
}
|
||||
}
|
||||
+24
-32
@@ -1,5 +1,7 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.integration;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockWood;
|
||||
|
||||
@@ -12,25 +14,39 @@ import com.jaquadro.minecraft.storagedrawers.block.pack.BlockTrimPack;
|
||||
import com.jaquadro.minecraft.storagedrawers.config.ConfigManager;
|
||||
import com.jaquadro.minecraft.storagedrawers.core.ModBlocks;
|
||||
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.event.FMLInterModComms;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class ChiselIntegrationModule extends IntegrationModule {
|
||||
public final class ChiselIntegrationModule extends IntegrationModule {
|
||||
|
||||
private static final String chiselModID = "chisel";
|
||||
private static final String addVariation = "variation:add";
|
||||
|
||||
private static final boolean chiselEnabled = (Loader.isModLoaded(chiselModID)
|
||||
&& StorageDrawers.config.integrationConfig.isChiselEnabled());
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getModID() {
|
||||
return chiselModID;
|
||||
}
|
||||
|
||||
public static boolean isEnabled() {
|
||||
return chiselEnabled;
|
||||
@Override
|
||||
protected boolean moduleConfig() {
|
||||
return StorageDrawers.config.integrationConfig.isChiselEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() throws Throwable {
|
||||
final ConfigManager config = StorageDrawers.config;
|
||||
for (int meta = 0; meta < BlockWood.field_150096_a.length; meta++) {
|
||||
if (config.isBlockEnabled("fulldrawers1")) registerBlock(ModBlocks.fullDrawers1, meta, "basicFull1");
|
||||
if (config.isBlockEnabled("fulldrawers2")) registerBlock(ModBlocks.fullDrawers2, meta, "basicFull2");
|
||||
if (config.isBlockEnabled("fulldrawers4")) registerBlock(ModBlocks.fullDrawers4, meta, "basicFull4");
|
||||
if (config.isBlockEnabled("halfdrawers2")) registerBlock(ModBlocks.halfDrawers2, meta, "basicHalf2");
|
||||
if (config.isBlockEnabled("halfdrawers4")) registerBlock(ModBlocks.halfDrawers4, meta, "basicHalf4");
|
||||
if (config.isBlockEnabled("trim")) registerBlock(ModBlocks.trim, meta, "trim");
|
||||
}
|
||||
}
|
||||
|
||||
public static void registerPackBlock(Block block) {
|
||||
if (!chiselEnabled) return;
|
||||
|
||||
final String blockGroupName;
|
||||
final IPackDataResolver resolver;
|
||||
|
||||
@@ -79,28 +95,4 @@ public class ChiselIntegrationModule extends IntegrationModule {
|
||||
GameRegistry.findUniqueIdentifierFor(block).toString(),
|
||||
Integer.toString(meta)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModID() {
|
||||
return chiselModID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() throws Throwable {
|
||||
final ConfigManager config = StorageDrawers.config;
|
||||
|
||||
for (int meta = 0; meta < BlockWood.field_150096_a.length; meta++) {
|
||||
if (config.isBlockEnabled("fulldrawers1")) registerBlock(ModBlocks.fullDrawers1, meta, "basicFull1");
|
||||
if (config.isBlockEnabled("fulldrawers2")) registerBlock(ModBlocks.fullDrawers2, meta, "basicFull2");
|
||||
if (config.isBlockEnabled("fulldrawers4")) registerBlock(ModBlocks.fullDrawers4, meta, "basicFull4");
|
||||
if (config.isBlockEnabled("halfdrawers2")) registerBlock(ModBlocks.halfDrawers2, meta, "basicHalf2");
|
||||
if (config.isBlockEnabled("halfdrawers4")) registerBlock(ModBlocks.halfDrawers4, meta, "basicHalf4");
|
||||
if (config.isBlockEnabled("trim")) registerBlock(ModBlocks.trim, meta, "trim");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit() {
|
||||
/* nothing */
|
||||
}
|
||||
}
|
||||
+9
-13
@@ -1,29 +1,25 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.integration;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.StorageDrawers;
|
||||
import com.jaquadro.minecraft.storagedrawers.integration.gtnh.ModRecipes;
|
||||
|
||||
import cpw.mods.fml.common.Loader;
|
||||
|
||||
public class GTNHIntegrationModule extends IntegrationModule {
|
||||
|
||||
private static final boolean GTNHEnabled = (Loader.isModLoaded("dreamcraft")
|
||||
&& StorageDrawers.config.integrationConfig.isGTNHEnabled());
|
||||
|
||||
public static boolean isEnabled() {
|
||||
return GTNHEnabled;
|
||||
}
|
||||
public final class GTNHIntegrationModule extends IntegrationModule {
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getModID() {
|
||||
return "dreamcraft";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() throws Throwable {
|
||||
ModRecipes.init();
|
||||
protected boolean moduleConfig() {
|
||||
return StorageDrawers.config.integrationConfig.isGTNHEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit() {}
|
||||
public void init() throws Throwable {
|
||||
ModRecipes.init();
|
||||
}
|
||||
}
|
||||
+48
-23
@@ -1,44 +1,69 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.integration;
|
||||
|
||||
import java.util.List;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.ModContainer;
|
||||
import cpw.mods.fml.common.versioning.ArtifactVersion;
|
||||
import cpw.mods.fml.common.versioning.DefaultArtifactVersion;
|
||||
import cpw.mods.fml.common.versioning.InvalidVersionSpecificationException;
|
||||
import cpw.mods.fml.common.versioning.VersionRange;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
||||
public abstract class IntegrationModule {
|
||||
|
||||
@NotNull
|
||||
public abstract String getModID();
|
||||
|
||||
public boolean versionCheck() {
|
||||
String pattern = versionPattern();
|
||||
if (pattern == null) return true;
|
||||
|
||||
List<ModContainer> modList = Loader.instance().getModList();
|
||||
for (int i = 0, n = modList.size(); i < n; i++) {
|
||||
ModContainer mod = modList.get(i);
|
||||
if (mod.getModId().equals(getModID())) {
|
||||
try {
|
||||
VersionRange validVersions = VersionRange.createFromVersionSpec(pattern);
|
||||
ArtifactVersion version = new DefaultArtifactVersion(mod.getVersion());
|
||||
return validVersions.containsVersion(version);
|
||||
} catch (InvalidVersionSpecificationException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
protected abstract boolean moduleConfig();
|
||||
|
||||
protected String versionPattern() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public abstract void init() throws Throwable;
|
||||
protected LoadingSide loadingSide() {
|
||||
return LoadingSide.BOTH;
|
||||
}
|
||||
|
||||
public abstract void postInit();
|
||||
public void init() throws Throwable {}
|
||||
|
||||
public void postInit() {}
|
||||
|
||||
public final boolean shouldLoadModule() {
|
||||
return moduleConfig() && checkVersion() && checkSide();
|
||||
}
|
||||
|
||||
private boolean checkVersion() {
|
||||
String pattern = versionPattern();
|
||||
if (pattern == null) return true;
|
||||
VersionRange validVersions;
|
||||
try {
|
||||
validVersions = VersionRange.createFromVersionSpec(pattern);
|
||||
} catch (InvalidVersionSpecificationException e) {
|
||||
return false;
|
||||
}
|
||||
for (ModContainer mod : Loader.instance().getModList()) {
|
||||
if (mod.getModId().equals(getModID())) {
|
||||
ArtifactVersion version = new DefaultArtifactVersion(mod.getVersion());
|
||||
return validVersions.containsVersion(version);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean checkSide() {
|
||||
if (loadingSide() == LoadingSide.BOTH) {
|
||||
return true;
|
||||
}
|
||||
Side side = FMLCommonHandler.instance().getSide();
|
||||
if (side == Side.CLIENT && loadingSide() == LoadingSide.CLIENT) return true;
|
||||
return side == Side.SERVER && loadingSide() == LoadingSide.SERVER;
|
||||
}
|
||||
|
||||
protected enum LoadingSide {
|
||||
CLIENT,
|
||||
SERVER,
|
||||
BOTH
|
||||
}
|
||||
}
|
||||
+30
-44
@@ -1,7 +1,9 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.integration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
@@ -10,57 +12,43 @@ import com.jaquadro.minecraft.storagedrawers.StorageDrawers;
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
|
||||
public class IntegrationRegistry {
|
||||
public final class IntegrationRegistry {
|
||||
|
||||
private static IntegrationRegistry instance;
|
||||
private static IntegrationRegistry INSTANCE;
|
||||
private final List<IntegrationModule> registry = new ArrayList<>();
|
||||
private final Set<String> loadedMods = new HashSet<>();
|
||||
|
||||
private List<IntegrationModule> registry;
|
||||
|
||||
static {
|
||||
IntegrationRegistry reg = instance();
|
||||
if (Loader.isModLoaded("appliedenergistics2") && StorageDrawers.config.cache.enableAE2Integration)
|
||||
reg.add(new AppliedEnergistics());
|
||||
if (Loader.isModLoaded("Waila") && StorageDrawers.config.cache.enableWailaIntegration) reg.add(new Waila());
|
||||
if (Loader.isModLoaded("Thaumcraft") && StorageDrawers.config.cache.enableThaumcraftIntegration)
|
||||
reg.add(new Thaumcraft());
|
||||
if (Loader.isModLoaded("MineTweaker3") && StorageDrawers.config.cache.enableMineTweakerIntegration)
|
||||
reg.add(new MineTweaker());
|
||||
if (Loader.isModLoaded("RefinedRelocation") && StorageDrawers.config.cache.enableRefinedRelocationIntegration)
|
||||
reg.add(new RefinedRelocation());
|
||||
if (Loader.isModLoaded("NotEnoughItems")) reg.add(new NotEnoughItems());
|
||||
if (Loader.isModLoaded("ThermalExpansion") && StorageDrawers.config.cache.enableThermalExpansionIntegration)
|
||||
reg.add(new ThermalExpansion());
|
||||
if (Loader.isModLoaded("ThermalFoundation") && StorageDrawers.config.cache.enableThermalFoundationIntegration)
|
||||
reg.add(new ThermalFoundation());
|
||||
if (ChiselIntegrationModule.isEnabled()) reg.add(new ChiselIntegrationModule());
|
||||
if (GTNHIntegrationModule.isEnabled()) reg.add(new GTNHIntegrationModule());
|
||||
if (BackhandIntegrationModule.isEnabled()) reg.add(new BackhandIntegrationModule());
|
||||
public static IntegrationRegistry instance() {
|
||||
if (INSTANCE == null) INSTANCE = new IntegrationRegistry();
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
private IntegrationRegistry() {
|
||||
registry = new ArrayList<IntegrationModule>();
|
||||
if (Loader.isModLoaded("appliedenergistics2")) this.register(new AppliedEnergistics());
|
||||
if (Loader.isModLoaded("Waila")) this.register(new Waila());
|
||||
if (Loader.isModLoaded("Thaumcraft")) this.register(new Thaumcraft());
|
||||
if (Loader.isModLoaded("MineTweaker3")) this.register(new MineTweaker());
|
||||
if (Loader.isModLoaded("RefinedRelocation")) this.register(new RefinedRelocation());
|
||||
if (Loader.isModLoaded("NotEnoughItems")) this.register(new NotEnoughItems());
|
||||
if (Loader.isModLoaded("ThermalExpansion")) this.register(new ThermalExpansion());
|
||||
if (Loader.isModLoaded("ThermalFoundation")) this.register(new ThermalFoundation());
|
||||
if (Loader.isModLoaded("chisel")) this.register(new ChiselIntegrationModule());
|
||||
if (Loader.isModLoaded("dreamcraft")) this.register(new GTNHIntegrationModule());
|
||||
if (Loader.isModLoaded("backhand")) this.register(new BackhandIntegrationModule());
|
||||
}
|
||||
|
||||
public static IntegrationRegistry instance() {
|
||||
if (instance == null) instance = new IntegrationRegistry();
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
public void add(IntegrationModule module) {
|
||||
if (module.versionCheck()) registry.add(module);
|
||||
private void register(IntegrationModule module) {
|
||||
if (module.shouldLoadModule()) {
|
||||
registry.add(module);
|
||||
}
|
||||
}
|
||||
|
||||
public void init() {
|
||||
for (int i = 0; i < registry.size(); i++) {
|
||||
IntegrationModule module = registry.get(i);
|
||||
if (module.getModID() != null && !Loader.isModLoaded(module.getModID())) {
|
||||
registry.remove(i--);
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
module.init();
|
||||
loadedMods.add(module.getModID());
|
||||
} catch (Throwable t) {
|
||||
registry.remove(i--);
|
||||
FMLLog.log(
|
||||
@@ -72,14 +60,12 @@ public class IntegrationRegistry {
|
||||
}
|
||||
|
||||
public void postInit() {
|
||||
for (IntegrationModule module : registry) module.postInit();
|
||||
for (IntegrationModule module : registry) {
|
||||
module.postInit();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isModLoaded(String mod_id) {
|
||||
for (IntegrationModule module : registry) {
|
||||
if (module.getModID().equals(mod_id)) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
public boolean isModuleLoaded(String modId) {
|
||||
return this.loadedMods.contains(modId);
|
||||
}
|
||||
}
|
||||
@@ -1,25 +1,31 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.integration;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.StorageDrawers;
|
||||
import com.jaquadro.minecraft.storagedrawers.integration.minetweaker.Compaction;
|
||||
import com.jaquadro.minecraft.storagedrawers.integration.minetweaker.OreDictionaryBlacklist;
|
||||
import com.jaquadro.minecraft.storagedrawers.integration.minetweaker.OreDictionaryWhitelist;
|
||||
|
||||
import minetweaker.MineTweakerAPI;
|
||||
|
||||
public class MineTweaker extends IntegrationModule {
|
||||
public final class MineTweaker extends IntegrationModule {
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getModID() {
|
||||
return "MineTweaker3";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean moduleConfig() {
|
||||
return StorageDrawers.config.cache.enableMineTweakerIntegration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() throws Throwable {
|
||||
MineTweakerAPI.registerClass(OreDictionaryBlacklist.class);
|
||||
MineTweakerAPI.registerClass(OreDictionaryWhitelist.class);
|
||||
MineTweakerAPI.registerClass(Compaction.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit() {}
|
||||
}
|
||||
+17
-15
@@ -2,36 +2,38 @@ package com.jaquadro.minecraft.storagedrawers.integration;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
|
||||
public class NotEnoughItems extends IntegrationModule {
|
||||
public final class NotEnoughItems extends IntegrationModule {
|
||||
|
||||
private static final String MOD_ID = "NotEnoughItems";
|
||||
|
||||
boolean loaded;
|
||||
|
||||
static Class clGuiContainerManager;
|
||||
static Field fdDrawItems;
|
||||
private static Field fdDrawItems;
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getModID() {
|
||||
return MOD_ID;
|
||||
return "NotEnoughItems";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean moduleConfig() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected LoadingSide loadingSide() {
|
||||
return LoadingSide.CLIENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() throws Throwable {
|
||||
clGuiContainerManager = Class.forName("codechicken.nei.guihook.GuiContainerManager");
|
||||
Class<?> clGuiContainerManager = Class.forName("codechicken.nei.guihook.GuiContainerManager");
|
||||
fdDrawItems = clGuiContainerManager.getDeclaredField("drawItems");
|
||||
|
||||
loaded = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit() {}
|
||||
|
||||
public static RenderItem setItemRender(RenderItem itemRender) {
|
||||
if (fdDrawItems == null) return null;
|
||||
|
||||
try {
|
||||
RenderItem prev = (RenderItem) fdDrawItems.get(null);
|
||||
fdDrawItems.set(null, itemRender);
|
||||
|
||||
+9
-1
@@ -1,5 +1,7 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.integration;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.block.BlockWood;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.init.Blocks;
|
||||
@@ -27,7 +29,7 @@ import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class RefinedRelocation extends IntegrationModule {
|
||||
public final class RefinedRelocation extends IntegrationModule {
|
||||
|
||||
public static BlockSortingDrawers fullDrawers1;
|
||||
public static BlockSortingDrawers fullDrawers2;
|
||||
@@ -48,11 +50,17 @@ public class RefinedRelocation extends IntegrationModule {
|
||||
}
|
||||
};
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getModID() {
|
||||
return "RefinedRelocation";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean moduleConfig() {
|
||||
return StorageDrawers.config.cache.enableRefinedRelocationIntegration;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String versionPattern() {
|
||||
return "[1.0.8b,)";
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.integration;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityClientPlayerMP;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
@@ -15,6 +17,7 @@ import net.minecraftforge.common.util.Constants;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.StorageDrawers;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.StorageDrawersApi;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.event.DrawerPopulatedEvent;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.registry.IWailaTooltipHandler;
|
||||
@@ -28,15 +31,21 @@ import thaumcraft.api.ThaumcraftApiHelper;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.api.aspects.AspectList;
|
||||
|
||||
public class Thaumcraft extends IntegrationModule {
|
||||
public final class Thaumcraft extends IntegrationModule {
|
||||
|
||||
private Item[] aspectItems;
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getModID() {
|
||||
return "Thaumcraft";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean moduleConfig() {
|
||||
return StorageDrawers.config.cache.enableThaumcraftIntegration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() throws Throwable {
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
@@ -51,9 +60,6 @@ public class Thaumcraft extends IntegrationModule {
|
||||
StorageDrawersApi.instance().wailaRegistry().registerTooltipHandler(new WailaTooltipHandler());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit() {}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onDrawerPopulated(DrawerPopulatedEvent event) {
|
||||
IDrawer drawer = event.drawer;
|
||||
|
||||
+15
-20
@@ -2,6 +2,8 @@ package com.jaquadro.minecraft.storagedrawers.integration;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
@@ -19,32 +21,32 @@ import com.jaquadro.minecraft.storagedrawers.core.ModItems;
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import cpw.mods.fml.common.registry.GameData;
|
||||
|
||||
public class ThermalExpansion extends IntegrationModule {
|
||||
public final class ThermalExpansion extends IntegrationModule {
|
||||
|
||||
private static final String MOD_ID = "ThermalExpansion";
|
||||
|
||||
static Class clSawmillManager;
|
||||
static Class clPulverizerManager;
|
||||
static Method mtSawmillAddRecipe;
|
||||
static Method mtPulverizerAddRecipe;
|
||||
|
||||
static ItemStack itemSawdust;
|
||||
|
||||
static boolean initialized;
|
||||
private static Method mtSawmillAddRecipe;
|
||||
private static ItemStack itemSawdust;
|
||||
private static boolean initialized;
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getModID() {
|
||||
return MOD_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean moduleConfig() {
|
||||
return StorageDrawers.config.cache.enableThermalExpansionIntegration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() throws Throwable {
|
||||
clSawmillManager = Class.forName("cofh.thermalexpansion.util.crafting.SawmillManager");
|
||||
clPulverizerManager = Class.forName("cofh.thermalexpansion.util.crafting.PulverizerManager");
|
||||
Class<?> clSawmillManager = Class.forName("cofh.thermalexpansion.util.crafting.SawmillManager");
|
||||
|
||||
mtSawmillAddRecipe = clSawmillManager
|
||||
.getMethod("addRecipe", int.class, ItemStack.class, ItemStack.class, ItemStack.class, int.class);
|
||||
mtPulverizerAddRecipe = clSawmillManager
|
||||
Method mtPulverizerAddRecipe = clSawmillManager
|
||||
.getMethod("addRecipe", int.class, ItemStack.class, ItemStack.class, ItemStack.class, int.class);
|
||||
|
||||
Item itemMaterial = GameData.getItemRegistry().getObject(MOD_ID + ":material");
|
||||
@@ -206,9 +208,6 @@ public class ThermalExpansion extends IntegrationModule {
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit() {}
|
||||
|
||||
public static void registerPackBlock(IExtendedDataResolver resolver) {
|
||||
if (!initialized || resolver == null) return;
|
||||
|
||||
@@ -332,11 +331,7 @@ public class ThermalExpansion extends IntegrationModule {
|
||||
}
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
FMLLog.log(
|
||||
StorageDrawers.MOD_ID,
|
||||
Level.WARN,
|
||||
t,
|
||||
"Error registering pack block in module: " + ThermalExpansion.class.getName());
|
||||
FMLLog.log(StorageDrawers.MOD_ID, Level.WARN, t, "Error registering pack block");
|
||||
}
|
||||
}
|
||||
}
|
||||
+10
-4
@@ -2,6 +2,8 @@ package com.jaquadro.minecraft.storagedrawers.integration;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||
|
||||
@@ -12,19 +14,24 @@ import com.mojang.authlib.GameProfile;
|
||||
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class ThermalFoundation extends IntegrationModule {
|
||||
|
||||
private Class classRegistrySocial;
|
||||
public final class ThermalFoundation extends IntegrationModule {
|
||||
|
||||
private Method methodPlayerHasAccess;
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getModID() {
|
||||
return "ThermalFoundation";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean moduleConfig() {
|
||||
return StorageDrawers.config.cache.enableThermalFoundationIntegration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() throws Throwable {
|
||||
Class<?> classRegistrySocial;
|
||||
try {
|
||||
classRegistrySocial = Class.forName("cofh.core.RegistrySocial");
|
||||
} catch (ClassNotFoundException e) {
|
||||
@@ -38,7 +45,6 @@ public class ThermalFoundation extends IntegrationModule {
|
||||
@Override
|
||||
public void postInit() {
|
||||
StorageDrawers.securityRegistry.registerProvider(new CoFHSecurityProvider(this));
|
||||
|
||||
if (StorageDrawers.config.cache.enablePersonalUpgrades) {
|
||||
GameRegistry.addRecipe(
|
||||
new ShapedOreRecipe(
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.jaquadro.minecraft.storagedrawers.integration;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -29,21 +31,26 @@ import mcp.mobius.waila.api.IWailaRegistrar;
|
||||
* @author dmillerw
|
||||
* @author jaquadro
|
||||
*/
|
||||
public class Waila extends IntegrationModule {
|
||||
public final class Waila extends IntegrationModule {
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getModID() {
|
||||
return "Waila";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() throws Throwable {
|
||||
FMLInterModComms
|
||||
.sendMessage("Waila", "register", StorageDrawers.SOURCE_PATH + "integration.Waila.registerProvider");
|
||||
protected boolean moduleConfig() {
|
||||
return StorageDrawers.config.cache.enableWailaIntegration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit() {}
|
||||
public void init() throws Throwable {
|
||||
FMLInterModComms.sendMessage(
|
||||
"Waila",
|
||||
"register",
|
||||
"com.jaquadro.minecraft.storagedrawers.integration.Waila.registerProvider");
|
||||
}
|
||||
|
||||
public static void registerProvider(IWailaRegistrar registrar) {
|
||||
registrar.registerBodyProvider(new WailaDrawer(), BlockDrawers.class);
|
||||
|
||||
+2
-2
@@ -8,8 +8,8 @@ import com.mojang.authlib.GameProfile;
|
||||
|
||||
public class CoFHSecurityProvider implements ISecurityProvider {
|
||||
|
||||
ThermalFoundation foundation;
|
||||
private DefaultSecurityProvider defaultProvider = new DefaultSecurityProvider();
|
||||
private final ThermalFoundation foundation;
|
||||
private final DefaultSecurityProvider defaultProvider = new DefaultSecurityProvider();
|
||||
|
||||
public CoFHSecurityProvider(ThermalFoundation foundation) {
|
||||
this.foundation = foundation;
|
||||
|
||||
@@ -75,7 +75,7 @@ public class ItemPersonalKey extends Item {
|
||||
public void getSubItems(Item item, CreativeTabs creativeTabs, List list) {
|
||||
list.add(new ItemStack(item, 1, 0));
|
||||
if (StorageDrawers.config.cache.enableThermalFoundationIntegration
|
||||
&& IntegrationRegistry.instance().isModLoaded("ThermalFoundation"))
|
||||
&& IntegrationRegistry.instance().isModuleLoaded("ThermalFoundation"))
|
||||
list.add(new ItemStack(item, 1, 1));
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user