General clean up and improvement of internal plugin system

This commit is contained in:
CovertJaguar committed 2014-09-20 22:43:13 -07:00
1 parent 3ad5bdd598
commit 7cc3668a70
26 files changed
+593 -762

No files matched your search

+130 -147
View File
@@ -21,8 +21,6 @@ import ic2.api.item.IC2Items;
import ic2.api.recipe.RecipeInputItemStack;
import ic2.api.recipe.Recipes;
import forestry.api.core.IPlugin;
import forestry.api.core.PluginInfo;
import forestry.api.recipes.RecipeManagers;
import forestry.api.storage.BackpackManager;
import forestry.core.GameMode;
@@ -36,8 +34,8 @@ import forestry.core.utils.LiquidHelper;
import forestry.core.utils.RecipeUtil;
import forestry.core.utils.StackUtils;
@PluginInfo(pluginID = "IC2", name = "IndustrialCraft2", author = "SirSengir", url = Defaults.URL, description = "Compatibility plugin for IC2.")
public class PluginIC2 implements IPlugin {
@Plugin(pluginID = "IC2", name = "IndustrialCraft2", author = "SirSengir", url = Defaults.URL, description = "Compatibility plugin for IC2.")
public class PluginIC2 extends ForestryPlugin {
public static PluginIC2 instance;
public static Configuration config;
@@ -74,170 +72,155 @@ public class PluginIC2 implements IPlugin {
return Proxies.common.isModLoaded("IC2");
}
@Override
public String getFailMessage() {
return "IndustrialCraft2 not found";
}
@Override
public void doInit() {
config = Config.config;
if (!isAvailable()) return;
initLiquidContainers();
initRubberChain();
initFermentation();
new Impl().init();
}
@Override
public void preInit() {
// Remove some items from the recycler
Recipes.recyclerBlacklist.add(new RecipeInputItemStack(ForestryItem.beeQueenGE.getItemStack()));
Recipes.recyclerBlacklist.add(new RecipeInputItemStack(ForestryItem.beePrincessGE.getItemStack()));
}
@Override
public void postInit() {
protected void registerBackpackItems() {
if (BackpackManager.backpackItems == null)
return;
if (resin != null)
BackpackManager.definitions.get("forester").addValidItem(resin);
if (rubber != null)
BackpackManager.definitions.get("forester").addValidItem(rubber);
}
private static class Impl {
private void init() {
initLiquidContainers();
initRubberChain();
initFermentation();
initCrates();
@Override
protected void registerCrates() {
Recipes.recyclerBlacklist.add(new RecipeInputItemStack(ForestryItem.beeQueenGE.getItemStack()));
Recipes.recyclerBlacklist.add(new RecipeInputItemStack(ForestryItem.beePrincessGE.getItemStack()));
// Remove some items from the recycler
registerBackpackItems();
// Add crates for the IC2 items that exist.
resin = IC2Items.getItem("resin");
if (resin != null) {
ForestryItem.cratedResin.registerItem(new ItemCrated(), "cratedResin");
((ItemCrated) ForestryItem.cratedResin.item()).setContained(ForestryItem.cratedResin.getItemStack(), resin);
}
private void initFermentation() {
plantBall = IC2Items.getItem("plantBall");
compressedPlantBall = IC2Items.getItem("compressedPlantBall");
if (plantBall == null || compressedPlantBall == null) {
Proxies.log.fine("No IC2 plantballs found.");
return;
}
// Add extra recipes
RecipeUtil.injectLeveledRecipe(plantBall, GameMode.getGameMode().getIntegerSetting("fermenter.yield.wheat") * 4, Defaults.LIQUID_BIOMASS);
RecipeUtil.injectLeveledRecipe(compressedPlantBall, GameMode.getGameMode().getIntegerSetting("fermenter.yield.wheat") * 5, Defaults.LIQUID_BIOMASS);
rubber = IC2Items.getItem("rubber");
if (rubber != null) {
ForestryItem.cratedRubber.registerItem(new ItemCrated(), "cratedRubber");
((ItemCrated) ForestryItem.cratedRubber.item()).setContained(ForestryItem.cratedRubber.getItemStack(), rubber);
}
private void initLiquidContainers() {
emptyCell = IC2Items.getItem("cell");
if (emptyCell == null) {
Proxies.log.fine("IC2 empty cell could not be found. Skipped adding IC2 liquid containers.");
return;
}
lavaCell = IC2Items.getItem("lavaCell");
if (lavaCell != null)
LiquidHelper.injectTinContainer(Defaults.LIQUID_LAVA, Defaults.BUCKET_VOLUME, lavaCell, emptyCell);
waterCell = IC2Items.getItem("waterCell");
if (waterCell != null) {
LiquidHelper.injectTinContainer(Defaults.LIQUID_WATER, Defaults.BUCKET_VOLUME, waterCell, emptyCell);
ItemStack bogEarthCan = GameMode.getGameMode().getStackSetting("recipe.output.bogearth.can");
if (bogEarthCan.stackSize > 0)
Proxies.common.addRecipe(bogEarthCan, "#Y#", "YXY", "#Y#", '#', Blocks.dirt, 'X', waterCell, 'Y', Blocks.sand);
}
scrap = IC2Items.getItem("scrap");
if (scrap != null) {
ForestryItem.cratedScrap.registerItem(new ItemCrated(), "cratedScrap");
((ItemCrated) ForestryItem.cratedScrap.item()).setContained(ForestryItem.cratedScrap.getItemStack(), scrap);
}
private void initRubberChain() {
treetap = IC2Items.getItem("treetap");
rubberwood = IC2Items.getItem("rubberWood");
resin = IC2Items.getItem("resin");
if (resin != null)
RecipeManagers.centrifugeManager.addRecipe(20, ForestryItem.propolis.getItemStack(), resin);
else
Proxies.log.fine("Missing IC2 resin, skipping centrifuge recipe for propolis to resin.");
rubbersapling = IC2Items.getItem("rubberSapling");
if (rubbersapling != null) {
RecipeUtil.injectLeveledRecipe(rubbersapling, GameMode.getGameMode().getIntegerSetting("fermenter.yield.sapling"), Defaults.LIQUID_BIOMASS);
BackpackManager.backpackItems[2].add(rubbersapling);
} else {
Proxies.log.fine("Missing IC2 rubber sapling, skipping fermenter recipe for converting rubber sapling to biomass.");
}
if (rubbersapling != null && resin != null) {
String saplingName = GameData.getBlockRegistry().getNameForObject(StackUtils.getBlock(rubbersapling));
String resinName = GameData.getItemRegistry().getNameForObject(resin.getItem());
String imc = String.format("farmArboreal@%s.%s.%s.%s",
saplingName, rubbersapling.getItemDamage(),
resinName, resin.getItemDamage());
Proxies.log.finest("Sending IMC '%s'.", imc);
FMLInterModComms.sendMessage(Defaults.MOD, "add-farmable-sapling", imc);
}
rubberleaves = IC2Items.getItem("rubberLeaves");
if (rubberleaves != null)
BackpackManager.backpackItems[2].add(rubberleaves);
else
Proxies.log.fine("Missing IC2 rubber leaves");
fuelcanFilled = IC2Items.getItem("filledFuelCan");
fuelcanEmpty = IC2Items.getItem("fuelCan");
if (fuelcanEmpty != null && fuelcanFilled != null) {
ItemStack fuelcanStack = new ItemStack(fuelcanFilled.getItem(), 1, 0);
NBTTagCompound compound = new NBTTagCompound();
compound.setInteger("value", 15288);
fuelcanStack.setTagCompound(compound);
RecipeManagers.bottlerManager.addRecipe(20, LiquidHelper.getLiquid(Defaults.LIQUID_ETHANOL, Defaults.BOTTLER_FUELCAN_VOLUME), fuelcanEmpty, fuelcanStack);
} else {
Proxies.log.fine("Missing IC2 fuelcanEmpty or fuelcanFilled, skipping bottler recipe for ethanol to filled fuel can.");
}
// Rubber wood is added via ore dictionary.
uuMatter = IC2Items.getItem("matter");
if (uuMatter != null) {
ForestryItem.cratedUUM.registerItem(new ItemCrated(), "cratedUUM");
((ItemCrated) ForestryItem.cratedUUM.item()).setContained(ForestryItem.cratedUUM.getItemStack(), uuMatter);
}
private void initCrates() {
// Add crates for the IC2 items that exist.
resin = IC2Items.getItem("resin");
if (resin != null) {
ForestryItem.cratedResin.registerItem(new ItemCrated(), "cratedResin");
((ItemCrated) ForestryItem.cratedResin.item()).setContained(ForestryItem.cratedResin.getItemStack(), resin);
}
rubber = IC2Items.getItem("rubber");
if (rubber != null) {
ForestryItem.cratedRubber.registerItem(new ItemCrated(), "cratedRubber");
((ItemCrated) ForestryItem.cratedRubber.item()).setContained(ForestryItem.cratedRubber.getItemStack(), rubber);
}
scrap = IC2Items.getItem("scrap");
if (scrap != null) {
ForestryItem.cratedScrap.registerItem(new ItemCrated(), "cratedScrap");
((ItemCrated) ForestryItem.cratedScrap.item()).setContained(ForestryItem.cratedScrap.getItemStack(), scrap);
}
uuMatter = IC2Items.getItem("matter");
if (uuMatter != null) {
ForestryItem.cratedUUM.registerItem(new ItemCrated(), "cratedUUM");
((ItemCrated) ForestryItem.cratedUUM.item()).setContained(ForestryItem.cratedUUM.getItemStack(), uuMatter);
}
silver = IC2Items.getItem("silverIngot");
if (silver != null) {
ForestryItem.cratedSilver.registerItem(new ItemCrated(), "cratedSilver");
((ItemCrated) ForestryItem.cratedSilver.item()).setContained(ForestryItem.cratedSilver.getItemStack(), silver);
}
brass = IC2Items.getItem("bronzeIngot");
if (brass != null) {
ForestryItem.cratedBrass.registerItem(new ItemCrated(), "cratedBrass");
((ItemCrated) ForestryItem.cratedBrass.item()).setContained(ForestryItem.cratedBrass.getItemStack(), brass);
}
silver = IC2Items.getItem("silverIngot");
if (silver != null) {
ForestryItem.cratedSilver.registerItem(new ItemCrated(), "cratedSilver");
((ItemCrated) ForestryItem.cratedSilver.item()).setContained(ForestryItem.cratedSilver.getItemStack(), silver);
}
private void registerBackpackItems() {
if (BackpackManager.backpackItems == null)
return;
if (resin != null)
BackpackManager.definitions.get("forester").addValidItem(resin);
if (rubber != null)
BackpackManager.definitions.get("forester").addValidItem(rubber);
brass = IC2Items.getItem("bronzeIngot");
if (brass != null) {
ForestryItem.cratedBrass.registerItem(new ItemCrated(), "cratedBrass");
((ItemCrated) ForestryItem.cratedBrass.item()).setContained(ForestryItem.cratedBrass.getItemStack(), brass);
}
}
private void initFermentation() {
plantBall = IC2Items.getItem("plantBall");
compressedPlantBall = IC2Items.getItem("compressedPlantBall");
if (plantBall == null || compressedPlantBall == null) {
Proxies.log.fine("No IC2 plantballs found.");
return;
}
// Add extra recipes
RecipeUtil.injectLeveledRecipe(plantBall, GameMode.getGameMode().getIntegerSetting("fermenter.yield.wheat") * 4, Defaults.LIQUID_BIOMASS);
RecipeUtil.injectLeveledRecipe(compressedPlantBall, GameMode.getGameMode().getIntegerSetting("fermenter.yield.wheat") * 5, Defaults.LIQUID_BIOMASS);
}
private void initLiquidContainers() {
emptyCell = IC2Items.getItem("cell");
if (emptyCell == null) {
Proxies.log.fine("IC2 empty cell could not be found. Skipped adding IC2 liquid containers.");
return;
}
lavaCell = IC2Items.getItem("lavaCell");
if (lavaCell != null)
LiquidHelper.injectTinContainer(Defaults.LIQUID_LAVA, Defaults.BUCKET_VOLUME, lavaCell, emptyCell);
waterCell = IC2Items.getItem("waterCell");
if (waterCell != null) {
LiquidHelper.injectTinContainer(Defaults.LIQUID_WATER, Defaults.BUCKET_VOLUME, waterCell, emptyCell);
ItemStack bogEarthCan = GameMode.getGameMode().getStackSetting("recipe.output.bogearth.can");
if (bogEarthCan.stackSize > 0)
Proxies.common.addRecipe(bogEarthCan, "#Y#", "YXY", "#Y#", '#', Blocks.dirt, 'X', waterCell, 'Y', Blocks.sand);
}
}
private void initRubberChain() {
treetap = IC2Items.getItem("treetap");
rubberwood = IC2Items.getItem("rubberWood");
resin = IC2Items.getItem("resin");
if (resin != null)
RecipeManagers.centrifugeManager.addRecipe(20, ForestryItem.propolis.getItemStack(), resin);
else
Proxies.log.fine("Missing IC2 resin, skipping centrifuge recipe for propolis to resin.");
rubbersapling = IC2Items.getItem("rubberSapling");
if (rubbersapling != null) {
RecipeUtil.injectLeveledRecipe(rubbersapling, GameMode.getGameMode().getIntegerSetting("fermenter.yield.sapling"), Defaults.LIQUID_BIOMASS);
BackpackManager.backpackItems[2].add(rubbersapling);
} else
Proxies.log.fine("Missing IC2 rubber sapling, skipping fermenter recipe for converting rubber sapling to biomass.");
if (rubbersapling != null && resin != null) {
String saplingName = GameData.getBlockRegistry().getNameForObject(StackUtils.getBlock(rubbersapling));
String resinName = GameData.getItemRegistry().getNameForObject(resin.getItem());
String imc = String.format("farmArboreal@%s.%s.%s.%s",
saplingName, rubbersapling.getItemDamage(),
resinName, resin.getItemDamage());
Proxies.log.finest("Sending IMC '%s'.", imc);
FMLInterModComms.sendMessage(Defaults.MOD, "add-farmable-sapling", imc);
}
rubberleaves = IC2Items.getItem("rubberLeaves");
if (rubberleaves != null)
BackpackManager.backpackItems[2].add(rubberleaves);
else
Proxies.log.fine("Missing IC2 rubber leaves");
fuelcanFilled = IC2Items.getItem("filledFuelCan");
fuelcanEmpty = IC2Items.getItem("fuelCan");
if (fuelcanEmpty != null && fuelcanFilled != null) {
ItemStack fuelcanStack = new ItemStack(fuelcanFilled.getItem(), 1, 0);
NBTTagCompound compound = new NBTTagCompound();
compound.setInteger("value", 15288);
fuelcanStack.setTagCompound(compound);
RecipeManagers.bottlerManager.addRecipe(20, LiquidHelper.getLiquid(Defaults.LIQUID_ETHANOL, Defaults.BOTTLER_FUELCAN_VOLUME), fuelcanEmpty, fuelcanStack);
} else
Proxies.log.fine("Missing IC2 fuelcanEmpty or fuelcanFilled, skipping bottler recipe for ethanol to filled fuel can.");
// Rubber wood is added via ore dictionary.
}
}