mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-13 00:47:32 +00:00
Port TCon to use the v2 loader infrastructure from Mantle
This commit is contained in:
1 parent
a3aa7c2380
commit
891086dca4
9 files changed
+88
-241
No files matched your search
@@ -1,6 +1,7 @@
|
||||
package tconstruct;
|
||||
|
||||
import mantle.lib.TabTools;
|
||||
import mantle.module.ModuleController;
|
||||
import net.minecraft.world.gen.structure.MapGenStructureIO;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
@@ -80,6 +81,9 @@ public class TConstruct
|
||||
@SidedProxy(clientSide = "tconstruct.client.TProxyClient", serverSide = "tconstruct.common.TProxyCommon")
|
||||
public static TProxyCommon proxy;
|
||||
|
||||
// Module loader
|
||||
public static final ModuleController moduleLoader = new ModuleController("TDynstruct.cfg", "TConstruct");
|
||||
|
||||
// The packet pipeline
|
||||
public static final PacketPipeline packetPipeline = new PacketPipeline();
|
||||
|
||||
@@ -99,7 +103,7 @@ public class TConstruct
|
||||
|
||||
EnvironmentChecks.verifyEnvironmentSanity();
|
||||
MinecraftForge.EVENT_BUS.register(events = new TEventHandler());
|
||||
PluginController.getController().registerBuiltins();
|
||||
PluginController.registerModules();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@@ -166,7 +170,7 @@ public class TConstruct
|
||||
FMLCommonHandler.instance().bus().register(new TControls());
|
||||
}
|
||||
|
||||
PluginController.getController().preInit();
|
||||
moduleLoader.preInit();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@@ -181,12 +185,12 @@ public class TConstruct
|
||||
DimensionBlacklist.getBadBimensions();
|
||||
GameRegistry.registerWorldGenerator(new SlimeIslandGen(TRepo.slimePool, 2), 2);
|
||||
|
||||
PluginController.getController().init();
|
||||
|
||||
if (PHConstruct.achievementsEnabled)
|
||||
{
|
||||
TAchievements.init();
|
||||
}
|
||||
|
||||
moduleLoader.init();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@@ -201,7 +205,7 @@ public class TConstruct
|
||||
content.createEntities();
|
||||
recipes.modRecipes();
|
||||
|
||||
PluginController.getController().postInit();
|
||||
moduleLoader.postInit();
|
||||
}
|
||||
|
||||
public static LiquidCasting getTableCasting ()
|
||||
|
||||
@@ -1,133 +1,29 @@
|
||||
package tconstruct.plugins;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import tconstruct.TConstruct;
|
||||
import static tconstruct.TConstruct.moduleLoader;
|
||||
import tconstruct.plugins.fmp.ForgeMultiPart;
|
||||
import tconstruct.plugins.ic2.IC2;
|
||||
import tconstruct.plugins.imc.AppEng;
|
||||
import tconstruct.plugins.imc.BuildcraftTransport;
|
||||
import tconstruct.plugins.imc.Mystcraft;
|
||||
import tconstruct.plugins.imc.Thaumcraft;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
|
||||
public class PluginController
|
||||
{
|
||||
|
||||
private enum Phase
|
||||
{
|
||||
PRELAUNCH, PREINIT, INIT, POSTINIT, DONE
|
||||
}
|
||||
private PluginController() {} // Don't need to instantiate this.
|
||||
|
||||
private static PluginController instance;
|
||||
private Configuration conf = null;
|
||||
private List<ICompatPlugin> plugins = new LinkedList<ICompatPlugin>();
|
||||
private Phase currPhase = Phase.PRELAUNCH;
|
||||
|
||||
private PluginController()
|
||||
{
|
||||
String path = Loader.instance().getConfigDir().toString() + File.separator + "TDynstruct.cfg";
|
||||
TConstruct.logger.info("[PluginController] Using config path: " + path);
|
||||
conf = new Configuration(new File(path));
|
||||
}
|
||||
|
||||
public static PluginController getController ()
|
||||
{
|
||||
if (instance == null)
|
||||
instance = new PluginController();
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a plugin with the controller.
|
||||
*
|
||||
* Warning: Make sure your plugin class imports no APIs directly! Any API
|
||||
* interaction should be done by handlers called in pre/init/post so merely
|
||||
* creating an instance to check the mod ID isn't a hazard to the
|
||||
* controller.
|
||||
*
|
||||
* @param plugin
|
||||
* Plugin to register
|
||||
*/
|
||||
public void registerPlugin (ICompatPlugin plugin)
|
||||
{
|
||||
conf.load();
|
||||
boolean shouldLoad = conf.get("Plugins", plugin.getModId(), true).getBoolean(true);
|
||||
conf.save();
|
||||
|
||||
if (shouldLoad)
|
||||
loadPlugin(plugin);
|
||||
}
|
||||
|
||||
// This does the actual plugin loading if mod is present; needed to allow
|
||||
// force-enabling.
|
||||
private void loadPlugin (ICompatPlugin plugin)
|
||||
{
|
||||
if (!Loader.isModLoaded(plugin.getModId()))
|
||||
return;
|
||||
|
||||
TConstruct.logger.info("[PluginController] Registering compat plugin for " + plugin.getModId());
|
||||
plugins.add(plugin);
|
||||
|
||||
switch (currPhase)
|
||||
// Play catch-up if plugin is registered late
|
||||
{
|
||||
case DONE:
|
||||
case POSTINIT:
|
||||
plugin.preInit();
|
||||
plugin.init();
|
||||
plugin.postInit();
|
||||
break;
|
||||
case INIT:
|
||||
plugin.preInit();
|
||||
plugin.init();
|
||||
break;
|
||||
case PREINIT:
|
||||
plugin.preInit();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void preInit ()
|
||||
{
|
||||
currPhase = Phase.PREINIT;
|
||||
for (ICompatPlugin pl : plugins)
|
||||
pl.preInit();
|
||||
}
|
||||
|
||||
public void init ()
|
||||
{
|
||||
currPhase = Phase.INIT;
|
||||
for (ICompatPlugin pl : plugins)
|
||||
pl.init();
|
||||
}
|
||||
|
||||
public void postInit ()
|
||||
{
|
||||
currPhase = Phase.POSTINIT;
|
||||
for (ICompatPlugin pl : plugins)
|
||||
pl.postInit();
|
||||
currPhase = Phase.DONE;
|
||||
}
|
||||
|
||||
public void registerBuiltins ()
|
||||
public static void registerModules()
|
||||
{
|
||||
// Mystcraft is pushed in through the backdoor so it can't be disabled.
|
||||
loadPlugin(new Mystcraft());
|
||||
moduleLoader.registerUncheckedModule(Mystcraft.class);
|
||||
|
||||
registerPlugin(new AppEng());
|
||||
registerPlugin(new BuildcraftTransport());
|
||||
registerPlugin(new ForgeMultiPart());
|
||||
registerPlugin(new IC2());
|
||||
// registerPlugin(new MineFactoryReloaded());
|
||||
// registerPlugin(new NotEnoughItems());
|
||||
registerPlugin(new Thaumcraft());
|
||||
// registerPlugin(new Waila());
|
||||
// Register the remaining plugin classes normally
|
||||
moduleLoader.registerModule(AppEng.class);
|
||||
moduleLoader.registerModule(BuildcraftTransport.class);
|
||||
moduleLoader.registerModule(ForgeMultiPart.class);
|
||||
moduleLoader.registerModule(IC2.class);
|
||||
moduleLoader.registerModule(Thaumcraft.class);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,15 +1,18 @@
|
||||
package tconstruct.plugins.fmp;
|
||||
|
||||
import codechicken.microblock.BlockMicroMaterial;
|
||||
import codechicken.microblock.MicroMaterialRegistry;
|
||||
import mantle.module.ILoadableModule;
|
||||
import net.minecraft.block.Block;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.common.TRepo;
|
||||
import tconstruct.plugins.ICompatPlugin;
|
||||
|
||||
public class ForgeMultiPart implements ICompatPlugin
|
||||
public class ForgeMultiPart implements ILoadableModule
|
||||
{
|
||||
@Override
|
||||
public String getModId() {
|
||||
return "ForgeMultipart";
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public static String modId = "ForgeMultipart";
|
||||
|
||||
@Override
|
||||
public void preInit() {
|
||||
@@ -20,13 +23,13 @@ public class ForgeMultiPart implements ICompatPlugin
|
||||
public void init()
|
||||
{
|
||||
TConstruct.logger.info("ForgeMultipart detected. Registering TConstruct decorative blocks with FMP.");
|
||||
RegisterWithFMP.registerBlock(TRepo.clearGlass);
|
||||
RegisterWithFMP.registerBlock(TRepo.stainedGlassClear, 0, 15);
|
||||
RegisterWithFMP.registerBlock(TRepo.multiBrick, 0, 13);
|
||||
RegisterWithFMP.registerBlock(TRepo.metalBlock, 0, 10);
|
||||
RegisterWithFMP.registerBlock(TRepo.multiBrickFancy, 0, 15);
|
||||
RegisterWithFMP.registerBlock(TRepo.smeltery, 2, 2);
|
||||
RegisterWithFMP.registerBlock(TRepo.smeltery, 4, 10);
|
||||
registerBlock(TRepo.clearGlass);
|
||||
registerBlock(TRepo.stainedGlassClear, 0, 15);
|
||||
registerBlock(TRepo.multiBrick, 0, 13);
|
||||
registerBlock(TRepo.metalBlock, 0, 10);
|
||||
registerBlock(TRepo.multiBrickFancy, 0, 15);
|
||||
registerBlock(TRepo.smeltery, 2, 2);
|
||||
registerBlock(TRepo.smeltery, 4, 10);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -34,4 +37,36 @@ public class ForgeMultiPart implements ICompatPlugin
|
||||
// Nothing
|
||||
}
|
||||
|
||||
//For blocks with metadata values only
|
||||
public static void registerBlock (Block block, int metastart, int metaend)
|
||||
{
|
||||
for (int meta = metastart; meta <= metaend; meta++)
|
||||
{
|
||||
String identifier = new String(block.getUnlocalizedName());
|
||||
MicroMaterialRegistry.registerMaterial(new BlockMicroMaterial(block, meta), identifier + meta);
|
||||
}
|
||||
}
|
||||
|
||||
//For blocks without metadata values only.
|
||||
public static void registerBlock (Block block)
|
||||
{
|
||||
BlockMicroMaterial.createAndRegister(block, 0);
|
||||
}
|
||||
|
||||
//For blocks with metadata values and special MicroMaterial only
|
||||
public static void registerBlock (Block block, int metastart, int metaend, MicroMaterialRegistry.IMicroMaterial material)
|
||||
{
|
||||
for (int meta = metastart; meta <= metaend; meta++)
|
||||
{
|
||||
String identifier = new String(block.getUnlocalizedName());
|
||||
MicroMaterialRegistry.registerMaterial(material, identifier + meta);
|
||||
}
|
||||
}
|
||||
|
||||
//For blocks without metadata values and special MicroMaterial only.
|
||||
public static void registerBlock (Block block, MicroMaterialRegistry.IMicroMaterial material)
|
||||
{
|
||||
MicroMaterialRegistry.registerMaterial(material, new String(block.getUnlocalizedName()));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
package tconstruct.plugins.fmp;
|
||||
|
||||
import codechicken.microblock.MicroMaterialRegistry.IMicroMaterial;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import codechicken.microblock.BlockMicroMaterial;
|
||||
import codechicken.microblock.MicroMaterialRegistry;
|
||||
|
||||
public class RegisterWithFMP
|
||||
{
|
||||
//For blocks with metadata values only
|
||||
public static void registerBlock (Block block, int metastart, int metaend)
|
||||
{
|
||||
for (int meta = metastart; meta <= metaend; meta++)
|
||||
{
|
||||
String identifier = new String(block.getUnlocalizedName());
|
||||
MicroMaterialRegistry.registerMaterial(new BlockMicroMaterial(block, meta), identifier + meta);
|
||||
}
|
||||
}
|
||||
|
||||
//For blocks without metadata values only.
|
||||
public static void registerBlock (Block block)
|
||||
{
|
||||
BlockMicroMaterial.createAndRegister(block, 0);
|
||||
}
|
||||
|
||||
//For blocks with metadata values and special MicroMaterial only
|
||||
public static void registerBlock (Block block, int metastart, int metaend, IMicroMaterial material)
|
||||
{
|
||||
for (int meta = metastart; meta <= metaend; meta++)
|
||||
{
|
||||
String identifier = new String(block.getUnlocalizedName());
|
||||
MicroMaterialRegistry.registerMaterial(material, identifier + meta);
|
||||
}
|
||||
}
|
||||
|
||||
//For blocks without metadata values and special MicroMaterial only.
|
||||
public static void registerBlock (Block block, IMicroMaterial material)
|
||||
{
|
||||
MicroMaterialRegistry.registerMaterial(material, new String(block.getUnlocalizedName()));
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package tconstruct.plugins.ic2;
|
||||
|
||||
import mantle.module.ILoadableModule;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
@@ -10,17 +11,13 @@ import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.crafting.LiquidCasting;
|
||||
import tconstruct.plugins.ICompatPlugin;
|
||||
|
||||
public class IC2 implements ICompatPlugin
|
||||
public class IC2 implements ILoadableModule
|
||||
{
|
||||
|
||||
private static final String IC2_UUM_FLUIDNAME = "uumatter";
|
||||
private Fluid fluidUUM;
|
||||
|
||||
@Override
|
||||
public String getModId ()
|
||||
{
|
||||
return "IC2";
|
||||
}
|
||||
@SuppressWarnings("unused")
|
||||
public static String modId = "IC2";
|
||||
|
||||
@Override
|
||||
public void preInit ()
|
||||
@@ -33,50 +30,15 @@ public class IC2 implements ICompatPlugin
|
||||
{
|
||||
TConstruct.logger.info("[IC2] Preparing for shenanigans.");
|
||||
|
||||
fluidUUM = FluidRegistry.getFluid(IC2_UUM_FLUIDNAME);
|
||||
Fluid fluidUUM = FluidRegistry.getFluid(IC2_UUM_FLUIDNAME);
|
||||
if (fluidUUM == null)
|
||||
return;
|
||||
|
||||
// Useful stuff
|
||||
// ItemStack ingotCast = new ItemStack(TRepo.metalPattern, 1, 0);
|
||||
// ItemStack gemCast = new ItemStack(TRepo.metalPattern, 1, 26);
|
||||
// FluidStack fluidStack = new FluidStack(fluidUUM, 1);
|
||||
FluidStack fluidStackBlock = new FluidStack(fluidUUM, 4500);
|
||||
// LiquidCasting tableCasting = TConstructRegistry.getTableCasting();
|
||||
LiquidCasting basinCasting = TConstructRegistry.getBasinCasting();
|
||||
|
||||
// Table casting
|
||||
// tableCasting.addCastingRecipe(new ItemStack(Item.ingotIron),
|
||||
// fluidStack, ingotCast, 20);
|
||||
// tableCasting.addCastingRecipe(new ItemStack(Item.emerald),
|
||||
// fluidStack, gemCast, 20);
|
||||
|
||||
// Block casting
|
||||
// basinCasting.addCastingRecipe(new ItemStack(Block.blockIron),
|
||||
// fluidStackBlock, null, true, 50); // Iron convenience
|
||||
// Dirt <-> Diamonds
|
||||
// basinCasting.addCastingRecipe(new ItemStack(Block.dirt), new
|
||||
// FluidStack(fluidUUM, 500), new ItemStack(Block.blockDiamond), true,
|
||||
// 50);
|
||||
basinCasting.addCastingRecipe(new ItemStack(Blocks.diamond_block), fluidStackBlock, new ItemStack(Blocks.dirt), true, 50);
|
||||
// RS cycle
|
||||
// basinCasting.addCastingRecipe(new ItemStack(Block.blockRedstone),
|
||||
// fluidStack, new ItemStack(Item.redstone), true, 50);
|
||||
// basinCasting.addCastingRecipe(new ItemStack(Block.hardenedClay, 14,
|
||||
// 1), fluidStack, new ItemStack(Block.blockRedstone), true, 50);
|
||||
// basinCasting.addCastingRecipe(new ItemStack(Item.dyePowder, 1, 1),
|
||||
// fluidStack, new ItemStack(Block.hardenedClay, 14, 1), true, 50);
|
||||
// basinCasting.addCastingRecipe(new ItemStack(Block.blockRedstone),
|
||||
// fluidStack, new ItemStack(Item.dyePowder, 1, 1), true, 50);
|
||||
|
||||
// Alloy Mixing
|
||||
// 1mB Anything + 1mB UU = 2mB UU
|
||||
/*
|
||||
* Maybe a bit *too* trolly for (Map.Entry<String, Fluid> ent :
|
||||
* FluidRegistry.getRegisteredFluids().entrySet()) { if (ent.getValue()
|
||||
* != fluidUUM) Smeltery.addAlloyMixing(new FluidStack(fluidUUM, 2), new
|
||||
* FluidStack(fluidUUM, 1), new FluidStack(ent.getValue(), 1)); }
|
||||
*/
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -3,22 +3,20 @@ package tconstruct.plugins.imc;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import mantle.module.ILoadableModule;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.plugins.ICompatPlugin;
|
||||
import cpw.mods.fml.common.event.FMLInterModComms;
|
||||
|
||||
public class AppEng implements ICompatPlugin
|
||||
public class AppEng implements ILoadableModule
|
||||
{
|
||||
|
||||
private static List<String> spatialIOLogics = Arrays.asList("AdaptiveSmelteryLogic", "AqueductLogic", "CastingBasinLogic", "CastingChannelLogic", "CastingTableLogic", "CraftingStationLogic",
|
||||
"DryingRackLogic", "EssenceExtractorLogic", "FaucetLogic", "FrypanLogic", "GolemPedestalLogic", "LavaTankLogic", "PartBuilderLogic", "PatternChestLogic", "SmelteryDrainLogic",
|
||||
"SmelteryLogic", "StencilTableLogic", "TankAirLogic", "TileEntityLandmine", "ToolForgeLogic", "ToolStationLogic", "TowerFurnaceLogic", "MultiServantLogic");
|
||||
|
||||
@Override
|
||||
public String getModId ()
|
||||
{
|
||||
return "AppliedEnergistics";
|
||||
}
|
||||
@SuppressWarnings("unused")
|
||||
public static String modId = "AppliedEnergistics";
|
||||
|
||||
@Override
|
||||
public void preInit ()
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package tconstruct.plugins.imc;
|
||||
|
||||
import mantle.module.ILoadableModule;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import tconstruct.TConstruct;
|
||||
@@ -7,14 +8,11 @@ import tconstruct.common.TRepo;
|
||||
import tconstruct.plugins.ICompatPlugin;
|
||||
import cpw.mods.fml.common.event.FMLInterModComms;
|
||||
|
||||
public class BuildcraftTransport implements ICompatPlugin
|
||||
public class BuildcraftTransport implements ILoadableModule
|
||||
{
|
||||
|
||||
@Override
|
||||
public String getModId ()
|
||||
{
|
||||
return "BuildCraft|Transport";
|
||||
}
|
||||
@SuppressWarnings("unused")
|
||||
public static String modId = "BuildCraft|Transport";
|
||||
|
||||
@Override
|
||||
public void preInit ()
|
||||
|
||||
@@ -1,21 +1,19 @@
|
||||
package tconstruct.plugins.imc;
|
||||
|
||||
import mantle.module.ILoadableModule;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.plugins.ICompatPlugin;
|
||||
import cpw.mods.fml.common.event.FMLInterModComms;
|
||||
|
||||
public class Mystcraft implements ICompatPlugin
|
||||
public class Mystcraft implements ILoadableModule
|
||||
{
|
||||
|
||||
private static String[] fluids = new String[] { "invar.molten", "electrum.molten", "bronze.molten", "aluminumbrass.molten", "manyullyn.molten", "alumite.molten", "cobalt.molten", "moltenArdite",
|
||||
"ender", "steel.molten", "platinum.molten" };
|
||||
|
||||
@Override
|
||||
public String getModId ()
|
||||
{
|
||||
return "Mystcraft";
|
||||
}
|
||||
@SuppressWarnings("unused")
|
||||
public static String modId = "Mystcraft";
|
||||
|
||||
@Override
|
||||
public void preInit ()
|
||||
@@ -43,7 +41,7 @@ public class Mystcraft implements ICompatPlugin
|
||||
NBTMsg.setTag("fluidsymbol", new NBTTagCompound());
|
||||
NBTMsg.getCompoundTag("fluidsymbol").setFloat("rarity", 0.0F);
|
||||
NBTMsg.getCompoundTag("fluidsymbol").setFloat("grammarweight", 0.0F);
|
||||
NBTMsg.getCompoundTag("fluidsymbol").setFloat("instabilityPerBlock", 10000F);// renders creative symbol useless
|
||||
NBTMsg.getCompoundTag("fluidsymbol").setFloat("instabilityPerBlock", 10000F); // renders creative symbol useless
|
||||
NBTMsg.getCompoundTag("fluidsymbol").setString("fluidname", FluidName);
|
||||
FMLInterModComms.sendMessage("Mystcraft", "fluidsymbol", NBTMsg);
|
||||
}
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
package tconstruct.plugins.imc;
|
||||
|
||||
import mantle.module.ILoadableModule;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.common.TRepo;
|
||||
import tconstruct.plugins.ICompatPlugin;
|
||||
import cpw.mods.fml.common.event.FMLInterModComms;
|
||||
|
||||
public class Thaumcraft implements ICompatPlugin
|
||||
public class Thaumcraft implements ILoadableModule
|
||||
{
|
||||
|
||||
@Override
|
||||
public String getModId ()
|
||||
{
|
||||
return "Thaumcraft";
|
||||
}
|
||||
@SuppressWarnings("unused")
|
||||
public static String modId = "Thaumcraft";
|
||||
|
||||
@Override
|
||||
public void preInit ()
|
||||
|
||||
Reference in new issue
Block a user