From 9c58ed549f541b5024b37d1c79d910088e973109 Mon Sep 17 00:00:00 2001 From: Ben Spiers Date: Thu, 26 Jun 2014 01:10:53 +0100 Subject: [PATCH] =?UTF-8?q?Start=20of=20work=20on=20Doing=20It=20Right?= =?UTF-8?q?=E2=84=A2.=20Appears=20to=20work=20for=20cofh's=20API,=20not=20?= =?UTF-8?q?yet=20for=20IC2=20or=20BC.=20Not=20sure=20why.=20Might=20have?= =?UTF-8?q?=20to=20ask=20@cpw.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.properties | 6 +- .../cofh/api/energy/IEnergyConnection.java | 0 .../cofh/api/energy/IEnergyContainerItem.java | 0 .../java/cofh/api/energy/IEnergyHandler.java | 0 .../java/cofh/api/energy/package-info.java | 0 .../java/cofh/api/package-info.java | 0 src/{main => api}/java/ic2/api/Direction.java | 0 .../ic2/api/energy/event/EnergyTileEvent.java | 0 .../api/energy/event/EnergyTileLoadEvent.java | 0 .../energy/event/EnergyTileUnloadEvent.java | 0 .../ic2/api/energy/event/package-info.java | 0 .../java/ic2/api/energy/package-info.java | 0 .../ic2/api/energy/tile/IEnergyAcceptor.java | 0 .../ic2/api/energy/tile/IEnergyEmitter.java | 0 .../java/ic2/api/energy/tile/IEnergySink.java | 0 .../ic2/api/energy/tile/IEnergySource.java | 0 .../java/ic2/api/energy/tile/IEnergyTile.java | 0 .../ic2/api/energy/tile/package-info.java | 0 .../java/ic2/api/energy/usage.txt | 0 .../ic2/api/info/IEnergyValueProvider.java | 0 .../java/ic2/api/info/IFuelValueProvider.java | 0 src/{main => api}/java/ic2/api/info/Info.java | 0 .../java/ic2/api/info/package-info.java | 0 .../java/ic2/api/item/ElectricItem.java | 0 .../java/ic2/api/item/IElectricItem.java | 0 .../ic2/api/item/IElectricItemManager.java | 0 .../ic2/api/item/ISpecialElectricItem.java | 0 .../java/ic2/api/item/package-info.java | 0 .../java/ic2/api/package-info.java | 0 .../recipe/ICannerBottleRecipeManager.java | 0 .../recipe/ICannerEnrichRecipeManager.java | 0 .../api/recipe/ICraftingRecipeManager.java | 0 .../ic2/api/recipe/ILiquidAcceptManager.java | 0 .../ic2/api/recipe/IListRecipeManager.java | 0 .../ic2/api/recipe/IMachineRecipeManager.java | 0 .../java/ic2/api/recipe/IPatternStorage.java | 0 .../java/ic2/api/recipe/IRecipeInput.java | 0 .../java/ic2/api/recipe/IScrapboxManager.java | 0 .../ic2/api/recipe/ISemiFluidFuelManager.java | 0 .../api/recipe/RecipeInputFluidContainer.java | 0 .../ic2/api/recipe/RecipeInputItemStack.java | 0 .../ic2/api/recipe/RecipeInputOreDict.java | 0 .../java/ic2/api/recipe/RecipeOutput.java | 0 .../java/ic2/api/recipe/Recipes.java | 0 .../java/ic2/api/recipe/package-info.java | 0 .../java/ic2/api/tile/IEnergyStorage.java | 0 .../java/ic2/api/tile/IWrenchable.java | 0 .../java/ic2/api/tile/package-info.java | 0 .../java/mekanism/api/gas/FuelHandler.java | 6 +- .../java/mekanism/common/EnergyNetwork.java | 12 +- .../common/IAdvancedBoundingBlock.java | 11 +- src/main/java/mekanism/common/Mekanism.java | 5 +- .../common/block/BlockEnergyCube.java | 4 +- .../mekanism/common/block/BlockGasTank.java | 4 +- .../mekanism/common/block/BlockMachine.java | 4 +- .../mekanism/common/entity/EntityRobit.java | 6 +- .../common/integration/MekanismHooks.java | 132 ++++++++++-------- .../common/integration/OreDictManager.java | 12 +- .../container/ContainerEnergyCube.java | 4 +- .../common/item/ItemBlockEnergyCube.java | 15 ++ .../common/item/ItemBlockMachine.java | 20 ++- .../common/item/ItemConfigurator.java | 6 + .../mekanism/common/item/ItemEnergized.java | 15 ++ .../mekanism/common/item/ItemFreeRunners.java | 15 ++ .../multipart/PartLogisticalTransporter.java | 7 +- .../common/multipart/PartSidedPipe.java | 4 +- .../common/multipart/PartUniversalCable.java | 60 +++++--- .../tile/TileEntityAdvancedBoundingBlock.java | 24 +++- .../common/tile/TileEntityBasicBlock.java | 9 ++ .../common/tile/TileEntityBasicMachine.java | 10 ++ .../common/tile/TileEntityChargepad.java | 4 +- .../common/tile/TileEntityElectricBlock.java | 50 +++++-- .../tile/TileEntityElectricMachine.java | 10 ++ .../tile/TileEntityEnergizedSmelter.java | 9 ++ .../java/mekanism/common/util/CableUtils.java | 24 ++-- .../mekanism/common/util/ChargeUtils.java | 20 +-- .../mekanism/common/util/MekanismUtils.java | 26 +++- .../generators/common/MekanismGenerators.java | 21 +-- .../common/block/BlockGenerator.java | 4 +- .../common/item/ItemBlockGenerator.java | 16 +++ .../common/tile/TileEntityGenerator.java | 5 +- 81 files changed, 425 insertions(+), 155 deletions(-) rename src/{main => api}/java/cofh/api/energy/IEnergyConnection.java (100%) rename src/{main => api}/java/cofh/api/energy/IEnergyContainerItem.java (100%) rename src/{main => api}/java/cofh/api/energy/IEnergyHandler.java (100%) rename src/{main => api}/java/cofh/api/energy/package-info.java (100%) rename src/{main => api}/java/cofh/api/package-info.java (100%) rename src/{main => api}/java/ic2/api/Direction.java (100%) rename src/{main => api}/java/ic2/api/energy/event/EnergyTileEvent.java (100%) rename src/{main => api}/java/ic2/api/energy/event/EnergyTileLoadEvent.java (100%) rename src/{main => api}/java/ic2/api/energy/event/EnergyTileUnloadEvent.java (100%) rename src/{main => api}/java/ic2/api/energy/event/package-info.java (100%) rename src/{main => api}/java/ic2/api/energy/package-info.java (100%) rename src/{main => api}/java/ic2/api/energy/tile/IEnergyAcceptor.java (100%) rename src/{main => api}/java/ic2/api/energy/tile/IEnergyEmitter.java (100%) rename src/{main => api}/java/ic2/api/energy/tile/IEnergySink.java (100%) rename src/{main => api}/java/ic2/api/energy/tile/IEnergySource.java (100%) rename src/{main => api}/java/ic2/api/energy/tile/IEnergyTile.java (100%) rename src/{main => api}/java/ic2/api/energy/tile/package-info.java (100%) rename src/{main => api}/java/ic2/api/energy/usage.txt (100%) rename src/{main => api}/java/ic2/api/info/IEnergyValueProvider.java (100%) rename src/{main => api}/java/ic2/api/info/IFuelValueProvider.java (100%) rename src/{main => api}/java/ic2/api/info/Info.java (100%) rename src/{main => api}/java/ic2/api/info/package-info.java (100%) rename src/{main => api}/java/ic2/api/item/ElectricItem.java (100%) rename src/{main => api}/java/ic2/api/item/IElectricItem.java (100%) rename src/{main => api}/java/ic2/api/item/IElectricItemManager.java (100%) rename src/{main => api}/java/ic2/api/item/ISpecialElectricItem.java (100%) rename src/{main => api}/java/ic2/api/item/package-info.java (100%) rename src/{main => api}/java/ic2/api/package-info.java (100%) rename src/{main => api}/java/ic2/api/recipe/ICannerBottleRecipeManager.java (100%) rename src/{main => api}/java/ic2/api/recipe/ICannerEnrichRecipeManager.java (100%) rename src/{main => api}/java/ic2/api/recipe/ICraftingRecipeManager.java (100%) rename src/{main => api}/java/ic2/api/recipe/ILiquidAcceptManager.java (100%) rename src/{main => api}/java/ic2/api/recipe/IListRecipeManager.java (100%) rename src/{main => api}/java/ic2/api/recipe/IMachineRecipeManager.java (100%) rename src/{main => api}/java/ic2/api/recipe/IPatternStorage.java (100%) rename src/{main => api}/java/ic2/api/recipe/IRecipeInput.java (100%) rename src/{main => api}/java/ic2/api/recipe/IScrapboxManager.java (100%) rename src/{main => api}/java/ic2/api/recipe/ISemiFluidFuelManager.java (100%) rename src/{main => api}/java/ic2/api/recipe/RecipeInputFluidContainer.java (100%) rename src/{main => api}/java/ic2/api/recipe/RecipeInputItemStack.java (100%) rename src/{main => api}/java/ic2/api/recipe/RecipeInputOreDict.java (100%) rename src/{main => api}/java/ic2/api/recipe/RecipeOutput.java (100%) rename src/{main => api}/java/ic2/api/recipe/Recipes.java (100%) rename src/{main => api}/java/ic2/api/recipe/package-info.java (100%) rename src/{main => api}/java/ic2/api/tile/IEnergyStorage.java (100%) rename src/{main => api}/java/ic2/api/tile/IWrenchable.java (100%) rename src/{main => api}/java/ic2/api/tile/package-info.java (100%) diff --git a/build.properties b/build.properties index 09eb19140..5d630b540 100644 --- a/build.properties +++ b/build.properties @@ -1,6 +1,6 @@ minecraft_version=1.7.2 -forge_version=10.12.1.1112 -FMP_version=1.1.0.282 -CCLIB_version=1.1.1.81 +forge_version=10.12.2.1121 +FMP_version=1.1.0.288 +CCLIB_version=1.1.1.87 NEI_version=1.0.1 mod_version=7.0.0 diff --git a/src/main/java/cofh/api/energy/IEnergyConnection.java b/src/api/java/cofh/api/energy/IEnergyConnection.java similarity index 100% rename from src/main/java/cofh/api/energy/IEnergyConnection.java rename to src/api/java/cofh/api/energy/IEnergyConnection.java diff --git a/src/main/java/cofh/api/energy/IEnergyContainerItem.java b/src/api/java/cofh/api/energy/IEnergyContainerItem.java similarity index 100% rename from src/main/java/cofh/api/energy/IEnergyContainerItem.java rename to src/api/java/cofh/api/energy/IEnergyContainerItem.java diff --git a/src/main/java/cofh/api/energy/IEnergyHandler.java b/src/api/java/cofh/api/energy/IEnergyHandler.java similarity index 100% rename from src/main/java/cofh/api/energy/IEnergyHandler.java rename to src/api/java/cofh/api/energy/IEnergyHandler.java diff --git a/src/main/java/cofh/api/energy/package-info.java b/src/api/java/cofh/api/energy/package-info.java similarity index 100% rename from src/main/java/cofh/api/energy/package-info.java rename to src/api/java/cofh/api/energy/package-info.java diff --git a/src/main/java/cofh/api/package-info.java b/src/api/java/cofh/api/package-info.java similarity index 100% rename from src/main/java/cofh/api/package-info.java rename to src/api/java/cofh/api/package-info.java diff --git a/src/main/java/ic2/api/Direction.java b/src/api/java/ic2/api/Direction.java similarity index 100% rename from src/main/java/ic2/api/Direction.java rename to src/api/java/ic2/api/Direction.java diff --git a/src/main/java/ic2/api/energy/event/EnergyTileEvent.java b/src/api/java/ic2/api/energy/event/EnergyTileEvent.java similarity index 100% rename from src/main/java/ic2/api/energy/event/EnergyTileEvent.java rename to src/api/java/ic2/api/energy/event/EnergyTileEvent.java diff --git a/src/main/java/ic2/api/energy/event/EnergyTileLoadEvent.java b/src/api/java/ic2/api/energy/event/EnergyTileLoadEvent.java similarity index 100% rename from src/main/java/ic2/api/energy/event/EnergyTileLoadEvent.java rename to src/api/java/ic2/api/energy/event/EnergyTileLoadEvent.java diff --git a/src/main/java/ic2/api/energy/event/EnergyTileUnloadEvent.java b/src/api/java/ic2/api/energy/event/EnergyTileUnloadEvent.java similarity index 100% rename from src/main/java/ic2/api/energy/event/EnergyTileUnloadEvent.java rename to src/api/java/ic2/api/energy/event/EnergyTileUnloadEvent.java diff --git a/src/main/java/ic2/api/energy/event/package-info.java b/src/api/java/ic2/api/energy/event/package-info.java similarity index 100% rename from src/main/java/ic2/api/energy/event/package-info.java rename to src/api/java/ic2/api/energy/event/package-info.java diff --git a/src/main/java/ic2/api/energy/package-info.java b/src/api/java/ic2/api/energy/package-info.java similarity index 100% rename from src/main/java/ic2/api/energy/package-info.java rename to src/api/java/ic2/api/energy/package-info.java diff --git a/src/main/java/ic2/api/energy/tile/IEnergyAcceptor.java b/src/api/java/ic2/api/energy/tile/IEnergyAcceptor.java similarity index 100% rename from src/main/java/ic2/api/energy/tile/IEnergyAcceptor.java rename to src/api/java/ic2/api/energy/tile/IEnergyAcceptor.java diff --git a/src/main/java/ic2/api/energy/tile/IEnergyEmitter.java b/src/api/java/ic2/api/energy/tile/IEnergyEmitter.java similarity index 100% rename from src/main/java/ic2/api/energy/tile/IEnergyEmitter.java rename to src/api/java/ic2/api/energy/tile/IEnergyEmitter.java diff --git a/src/main/java/ic2/api/energy/tile/IEnergySink.java b/src/api/java/ic2/api/energy/tile/IEnergySink.java similarity index 100% rename from src/main/java/ic2/api/energy/tile/IEnergySink.java rename to src/api/java/ic2/api/energy/tile/IEnergySink.java diff --git a/src/main/java/ic2/api/energy/tile/IEnergySource.java b/src/api/java/ic2/api/energy/tile/IEnergySource.java similarity index 100% rename from src/main/java/ic2/api/energy/tile/IEnergySource.java rename to src/api/java/ic2/api/energy/tile/IEnergySource.java diff --git a/src/main/java/ic2/api/energy/tile/IEnergyTile.java b/src/api/java/ic2/api/energy/tile/IEnergyTile.java similarity index 100% rename from src/main/java/ic2/api/energy/tile/IEnergyTile.java rename to src/api/java/ic2/api/energy/tile/IEnergyTile.java diff --git a/src/main/java/ic2/api/energy/tile/package-info.java b/src/api/java/ic2/api/energy/tile/package-info.java similarity index 100% rename from src/main/java/ic2/api/energy/tile/package-info.java rename to src/api/java/ic2/api/energy/tile/package-info.java diff --git a/src/main/java/ic2/api/energy/usage.txt b/src/api/java/ic2/api/energy/usage.txt similarity index 100% rename from src/main/java/ic2/api/energy/usage.txt rename to src/api/java/ic2/api/energy/usage.txt diff --git a/src/main/java/ic2/api/info/IEnergyValueProvider.java b/src/api/java/ic2/api/info/IEnergyValueProvider.java similarity index 100% rename from src/main/java/ic2/api/info/IEnergyValueProvider.java rename to src/api/java/ic2/api/info/IEnergyValueProvider.java diff --git a/src/main/java/ic2/api/info/IFuelValueProvider.java b/src/api/java/ic2/api/info/IFuelValueProvider.java similarity index 100% rename from src/main/java/ic2/api/info/IFuelValueProvider.java rename to src/api/java/ic2/api/info/IFuelValueProvider.java diff --git a/src/main/java/ic2/api/info/Info.java b/src/api/java/ic2/api/info/Info.java similarity index 100% rename from src/main/java/ic2/api/info/Info.java rename to src/api/java/ic2/api/info/Info.java diff --git a/src/main/java/ic2/api/info/package-info.java b/src/api/java/ic2/api/info/package-info.java similarity index 100% rename from src/main/java/ic2/api/info/package-info.java rename to src/api/java/ic2/api/info/package-info.java diff --git a/src/main/java/ic2/api/item/ElectricItem.java b/src/api/java/ic2/api/item/ElectricItem.java similarity index 100% rename from src/main/java/ic2/api/item/ElectricItem.java rename to src/api/java/ic2/api/item/ElectricItem.java diff --git a/src/main/java/ic2/api/item/IElectricItem.java b/src/api/java/ic2/api/item/IElectricItem.java similarity index 100% rename from src/main/java/ic2/api/item/IElectricItem.java rename to src/api/java/ic2/api/item/IElectricItem.java diff --git a/src/main/java/ic2/api/item/IElectricItemManager.java b/src/api/java/ic2/api/item/IElectricItemManager.java similarity index 100% rename from src/main/java/ic2/api/item/IElectricItemManager.java rename to src/api/java/ic2/api/item/IElectricItemManager.java diff --git a/src/main/java/ic2/api/item/ISpecialElectricItem.java b/src/api/java/ic2/api/item/ISpecialElectricItem.java similarity index 100% rename from src/main/java/ic2/api/item/ISpecialElectricItem.java rename to src/api/java/ic2/api/item/ISpecialElectricItem.java diff --git a/src/main/java/ic2/api/item/package-info.java b/src/api/java/ic2/api/item/package-info.java similarity index 100% rename from src/main/java/ic2/api/item/package-info.java rename to src/api/java/ic2/api/item/package-info.java diff --git a/src/main/java/ic2/api/package-info.java b/src/api/java/ic2/api/package-info.java similarity index 100% rename from src/main/java/ic2/api/package-info.java rename to src/api/java/ic2/api/package-info.java diff --git a/src/main/java/ic2/api/recipe/ICannerBottleRecipeManager.java b/src/api/java/ic2/api/recipe/ICannerBottleRecipeManager.java similarity index 100% rename from src/main/java/ic2/api/recipe/ICannerBottleRecipeManager.java rename to src/api/java/ic2/api/recipe/ICannerBottleRecipeManager.java diff --git a/src/main/java/ic2/api/recipe/ICannerEnrichRecipeManager.java b/src/api/java/ic2/api/recipe/ICannerEnrichRecipeManager.java similarity index 100% rename from src/main/java/ic2/api/recipe/ICannerEnrichRecipeManager.java rename to src/api/java/ic2/api/recipe/ICannerEnrichRecipeManager.java diff --git a/src/main/java/ic2/api/recipe/ICraftingRecipeManager.java b/src/api/java/ic2/api/recipe/ICraftingRecipeManager.java similarity index 100% rename from src/main/java/ic2/api/recipe/ICraftingRecipeManager.java rename to src/api/java/ic2/api/recipe/ICraftingRecipeManager.java diff --git a/src/main/java/ic2/api/recipe/ILiquidAcceptManager.java b/src/api/java/ic2/api/recipe/ILiquidAcceptManager.java similarity index 100% rename from src/main/java/ic2/api/recipe/ILiquidAcceptManager.java rename to src/api/java/ic2/api/recipe/ILiquidAcceptManager.java diff --git a/src/main/java/ic2/api/recipe/IListRecipeManager.java b/src/api/java/ic2/api/recipe/IListRecipeManager.java similarity index 100% rename from src/main/java/ic2/api/recipe/IListRecipeManager.java rename to src/api/java/ic2/api/recipe/IListRecipeManager.java diff --git a/src/main/java/ic2/api/recipe/IMachineRecipeManager.java b/src/api/java/ic2/api/recipe/IMachineRecipeManager.java similarity index 100% rename from src/main/java/ic2/api/recipe/IMachineRecipeManager.java rename to src/api/java/ic2/api/recipe/IMachineRecipeManager.java diff --git a/src/main/java/ic2/api/recipe/IPatternStorage.java b/src/api/java/ic2/api/recipe/IPatternStorage.java similarity index 100% rename from src/main/java/ic2/api/recipe/IPatternStorage.java rename to src/api/java/ic2/api/recipe/IPatternStorage.java diff --git a/src/main/java/ic2/api/recipe/IRecipeInput.java b/src/api/java/ic2/api/recipe/IRecipeInput.java similarity index 100% rename from src/main/java/ic2/api/recipe/IRecipeInput.java rename to src/api/java/ic2/api/recipe/IRecipeInput.java diff --git a/src/main/java/ic2/api/recipe/IScrapboxManager.java b/src/api/java/ic2/api/recipe/IScrapboxManager.java similarity index 100% rename from src/main/java/ic2/api/recipe/IScrapboxManager.java rename to src/api/java/ic2/api/recipe/IScrapboxManager.java diff --git a/src/main/java/ic2/api/recipe/ISemiFluidFuelManager.java b/src/api/java/ic2/api/recipe/ISemiFluidFuelManager.java similarity index 100% rename from src/main/java/ic2/api/recipe/ISemiFluidFuelManager.java rename to src/api/java/ic2/api/recipe/ISemiFluidFuelManager.java diff --git a/src/main/java/ic2/api/recipe/RecipeInputFluidContainer.java b/src/api/java/ic2/api/recipe/RecipeInputFluidContainer.java similarity index 100% rename from src/main/java/ic2/api/recipe/RecipeInputFluidContainer.java rename to src/api/java/ic2/api/recipe/RecipeInputFluidContainer.java diff --git a/src/main/java/ic2/api/recipe/RecipeInputItemStack.java b/src/api/java/ic2/api/recipe/RecipeInputItemStack.java similarity index 100% rename from src/main/java/ic2/api/recipe/RecipeInputItemStack.java rename to src/api/java/ic2/api/recipe/RecipeInputItemStack.java diff --git a/src/main/java/ic2/api/recipe/RecipeInputOreDict.java b/src/api/java/ic2/api/recipe/RecipeInputOreDict.java similarity index 100% rename from src/main/java/ic2/api/recipe/RecipeInputOreDict.java rename to src/api/java/ic2/api/recipe/RecipeInputOreDict.java diff --git a/src/main/java/ic2/api/recipe/RecipeOutput.java b/src/api/java/ic2/api/recipe/RecipeOutput.java similarity index 100% rename from src/main/java/ic2/api/recipe/RecipeOutput.java rename to src/api/java/ic2/api/recipe/RecipeOutput.java diff --git a/src/main/java/ic2/api/recipe/Recipes.java b/src/api/java/ic2/api/recipe/Recipes.java similarity index 100% rename from src/main/java/ic2/api/recipe/Recipes.java rename to src/api/java/ic2/api/recipe/Recipes.java diff --git a/src/main/java/ic2/api/recipe/package-info.java b/src/api/java/ic2/api/recipe/package-info.java similarity index 100% rename from src/main/java/ic2/api/recipe/package-info.java rename to src/api/java/ic2/api/recipe/package-info.java diff --git a/src/main/java/ic2/api/tile/IEnergyStorage.java b/src/api/java/ic2/api/tile/IEnergyStorage.java similarity index 100% rename from src/main/java/ic2/api/tile/IEnergyStorage.java rename to src/api/java/ic2/api/tile/IEnergyStorage.java diff --git a/src/main/java/ic2/api/tile/IWrenchable.java b/src/api/java/ic2/api/tile/IWrenchable.java similarity index 100% rename from src/main/java/ic2/api/tile/IWrenchable.java rename to src/api/java/ic2/api/tile/IWrenchable.java diff --git a/src/main/java/ic2/api/tile/package-info.java b/src/api/java/ic2/api/tile/package-info.java similarity index 100% rename from src/main/java/ic2/api/tile/package-info.java rename to src/api/java/ic2/api/tile/package-info.java diff --git a/src/main/java/mekanism/api/gas/FuelHandler.java b/src/main/java/mekanism/api/gas/FuelHandler.java index 9f70ca891..ca2153a59 100644 --- a/src/main/java/mekanism/api/gas/FuelHandler.java +++ b/src/main/java/mekanism/api/gas/FuelHandler.java @@ -3,9 +3,13 @@ package mekanism.api.gas; import java.util.HashMap; import mekanism.common.Mekanism; +import mekanism.common.util.MekanismUtils; import net.minecraftforge.fluids.FluidContainerRegistry; +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.Optional.Method; + import buildcraft.api.fuels.IronEngineFuel; import buildcraft.api.fuels.IronEngineFuel.Fuel; @@ -25,7 +29,7 @@ public class FuelHandler return fuels.get(gas.getName()); } - if(gas.hasFluid()) + if(Loader.isModLoaded("BuildCraftAPI|fuel") && gas.hasFluid()) { Fuel bcFuel = IronEngineFuel.getFuelForFluid(gas.getFluid()); diff --git a/src/main/java/mekanism/common/EnergyNetwork.java b/src/main/java/mekanism/common/EnergyNetwork.java index eec127814..4cd3e9e3a 100644 --- a/src/main/java/mekanism/common/EnergyNetwork.java +++ b/src/main/java/mekanism/common/EnergyNetwork.java @@ -202,19 +202,19 @@ public class EnergyNetwork extends DynamicNetwork { sent += ((IStrictEnergyAcceptor)acceptor).transferEnergyToAcceptor(side.getOpposite(), currentSending); } - else if(acceptor instanceof IEnergyHandler) + else if(MekanismUtils.useRF() && acceptor instanceof IEnergyHandler) { IEnergyHandler handler = (IEnergyHandler)acceptor; int used = handler.receiveEnergy(side.getOpposite(), (int)Math.round(currentSending*Mekanism.TO_TE), false); sent += used*Mekanism.FROM_TE; } - else if(acceptor instanceof IEnergySink) + else if(MekanismUtils.useIC2() && acceptor instanceof IEnergySink) { double toSend = Math.min(currentSending, ((IEnergySink)acceptor).getMaxSafeInput()*Mekanism.FROM_IC2); toSend = Math.min(toSend, ((IEnergySink)acceptor).demandedEnergyUnits()*Mekanism.FROM_IC2); sent += (toSend - (((IEnergySink)acceptor).injectEnergyUnits(side.getOpposite(), toSend*Mekanism.TO_IC2)*Mekanism.FROM_IC2)); } - else if(acceptor instanceof IPowerReceptor && MekanismUtils.useBuildCraft()) + else if(MekanismUtils.useBuildCraft() && acceptor instanceof IPowerReceptor) { PowerReceiver receiver = ((IPowerReceptor)acceptor).getPowerReceiver(side.getOpposite()); @@ -262,7 +262,7 @@ public class EnergyNetwork extends DynamicNetwork } } } - else if(acceptor instanceof IEnergyHandler) + else if(MekanismUtils.useRF() && acceptor instanceof IEnergyHandler) { IEnergyHandler handler = (IEnergyHandler)acceptor; @@ -274,7 +274,7 @@ public class EnergyNetwork extends DynamicNetwork } } } - else if(acceptor instanceof IEnergySink) + else if(MekanismUtils.useIC2() && acceptor instanceof IEnergySink) { IEnergySink handler = (IEnergySink)acceptor; @@ -286,7 +286,7 @@ public class EnergyNetwork extends DynamicNetwork } } } - else if(acceptor instanceof IPowerReceptor && MekanismUtils.useBuildCraft()) + else if(MekanismUtils.useBuildCraft() && acceptor instanceof IPowerReceptor) { IPowerReceptor handler = (IPowerReceptor)acceptor; diff --git a/src/main/java/mekanism/common/IAdvancedBoundingBlock.java b/src/main/java/mekanism/common/IAdvancedBoundingBlock.java index 1d6ee6cf8..1d5a6b274 100644 --- a/src/main/java/mekanism/common/IAdvancedBoundingBlock.java +++ b/src/main/java/mekanism/common/IAdvancedBoundingBlock.java @@ -1,18 +1,25 @@ package mekanism.common; import ic2.api.energy.tile.IEnergySink; -import ic2.api.energy.tile.IEnergyTile; import mekanism.api.Coord4D; import mekanism.api.IFilterAccess; import mekanism.api.energy.IStrictEnergyAcceptor; import mekanism.api.energy.IStrictEnergyStorage; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; +import cpw.mods.fml.common.Optional.Interface; +import cpw.mods.fml.common.Optional.InterfaceList; + import buildcraft.api.power.IPowerReceptor; import cofh.api.energy.IEnergyHandler; import dan200.computercraft.api.peripheral.IPeripheral; -public interface IAdvancedBoundingBlock extends IBoundingBlock, ISidedInventory, IEnergySink, IStrictEnergyAcceptor, IPowerReceptor, IEnergyTile, IStrictEnergyStorage, IEnergyHandler, IPeripheral, IFilterAccess +@InterfaceList({ + @Interface(iface = "buildcraft.api.power.IPowerReceptor", modid = "BuildCraftAPI|power"), + @Interface(iface = "ic2.api.energy.tile.IEnergySink", modid = "IC2API", striprefs = true), + @Interface(iface = "cofh.api.energy.IEnergyHandler", modid = "CoFHAPI|energy") +}) +public interface IAdvancedBoundingBlock extends IBoundingBlock, ISidedInventory, IEnergySink, IStrictEnergyAcceptor, IPowerReceptor, IStrictEnergyStorage, IEnergyHandler, IPeripheral, IFilterAccess { public int[] getBoundSlots(Coord4D location, int side); diff --git a/src/main/java/mekanism/common/Mekanism.java b/src/main/java/mekanism/common/Mekanism.java index 98682b052..4ecd02eaf 100644 --- a/src/main/java/mekanism/common/Mekanism.java +++ b/src/main/java/mekanism/common/Mekanism.java @@ -175,7 +175,7 @@ public class Mekanism public static Mekanism instance; /** Mekanism hooks instance */ - public static MekanismHooks hooks = new MekanismHooks(); + public static MekanismHooks hooks; /** Mekanism configuration instance */ public static Configuration configuration; @@ -1091,7 +1091,7 @@ public class Mekanism OreDictionary.registerOre("ingotIron", new ItemStack(Items.iron_ingot)); OreDictionary.registerOre("ingotGold", new ItemStack(Items.gold_ingot)); OreDictionary.registerOre("oreRedstone", new ItemStack(Blocks.redstone_ore)); - OreDictionary.registerOre("oreRedstone", new ItemStack(Blocks.lit_redstone_ore)); + //OreDictionary.registerOre("oreRedstone", new ItemStack(Blocks.lit_redstone_ore)); if(controlCircuitOreDict || !hooks.BasicComponentsLoaded) { @@ -1344,6 +1344,7 @@ public class Mekanism public void postInit(FMLPostInitializationEvent event) { proxy.loadSoundHandler(); + hooks = new MekanismHooks(); hooks.hook(); MinecraftForge.EVENT_BUS.post(new BoxBlacklistEvent()); diff --git a/src/main/java/mekanism/common/block/BlockEnergyCube.java b/src/main/java/mekanism/common/block/BlockEnergyCube.java index 0492ccce5..f84eb2c02 100644 --- a/src/main/java/mekanism/common/block/BlockEnergyCube.java +++ b/src/main/java/mekanism/common/block/BlockEnergyCube.java @@ -31,6 +31,8 @@ import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; import buildcraft.api.tools.IToolWrench; + +import cpw.mods.fml.common.Loader; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -151,7 +153,7 @@ public class BlockEnergyCube extends BlockContainer { Item tool = entityplayer.getCurrentEquippedItem().getItem(); - if(tool instanceof IToolWrench && !tool.getUnlocalizedName().contains("omniwrench")) + if(Loader.isModLoaded("BuildCraftAPI|tools") && tool instanceof IToolWrench && !tool.getUnlocalizedName().contains("omniwrench")) { if(((IToolWrench)tool).canWrench(entityplayer, x, y, z)) { diff --git a/src/main/java/mekanism/common/block/BlockGasTank.java b/src/main/java/mekanism/common/block/BlockGasTank.java index 2374701a9..7a6045de7 100644 --- a/src/main/java/mekanism/common/block/BlockGasTank.java +++ b/src/main/java/mekanism/common/block/BlockGasTank.java @@ -22,6 +22,8 @@ import net.minecraft.util.MathHelper; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; import buildcraft.api.tools.IToolWrench; + +import cpw.mods.fml.common.Loader; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -96,7 +98,7 @@ public class BlockGasTank extends BlockContainer { Item tool = entityplayer.getCurrentEquippedItem().getItem(); - if(tool instanceof IToolWrench && !tool.getUnlocalizedName().contains("omniwrench")) + if(Loader.isModLoaded("BuildCraftAPI|tools") && tool instanceof IToolWrench && !tool.getUnlocalizedName().contains("omniwrench")) { if(((IToolWrench)tool).canWrench(entityplayer, x, y, z)) { diff --git a/src/main/java/mekanism/common/block/BlockMachine.java b/src/main/java/mekanism/common/block/BlockMachine.java index 233c1a322..76235f9cf 100644 --- a/src/main/java/mekanism/common/block/BlockMachine.java +++ b/src/main/java/mekanism/common/block/BlockMachine.java @@ -85,6 +85,8 @@ import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidStack; import buildcraft.api.tools.IToolWrench; + +import cpw.mods.fml.common.Loader; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import dan200.computercraft.api.peripheral.IPeripheral; @@ -657,7 +659,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IPer { Item tool = entityplayer.getCurrentEquippedItem().getItem(); - if(tool instanceof IToolWrench && !tool.getUnlocalizedName().contains("omniwrench")) + if(Loader.isModLoaded("BuildCraftAPI|tools") && tool instanceof IToolWrench && !tool.getUnlocalizedName().contains("omniwrench")) { if(((IToolWrench)tool).canWrench(entityplayer, x, y, z)) { diff --git a/src/main/java/mekanism/common/entity/EntityRobit.java b/src/main/java/mekanism/common/entity/EntityRobit.java index 2321fdace..50f7be9ea 100644 --- a/src/main/java/mekanism/common/entity/EntityRobit.java +++ b/src/main/java/mekanism/common/entity/EntityRobit.java @@ -18,6 +18,8 @@ import mekanism.common.RobitAIPickup; import mekanism.common.item.ItemConfigurator; import mekanism.common.item.ItemRobit; import mekanism.common.tile.TileEntityChargepad; +import mekanism.common.util.MekanismUtils; + import micdoodle8.mods.galacticraft.api.entity.IEntityBreathable; import net.minecraft.entity.EntityCreature; import net.minecraft.entity.SharedMonsterAttributes; @@ -170,7 +172,7 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine { setEnergy(getEnergy() + EnergizedItemManager.discharge(inventory[27], MAX_ELECTRICITY - getEnergy())); } - else if(Mekanism.hooks.IC2Loaded && inventory[27].getItem() instanceof IElectricItem) + else if(MekanismUtils.useIC2() && inventory[27].getItem() instanceof IElectricItem) { IElectricItem item = (IElectricItem)inventory[27].getItem(); @@ -180,7 +182,7 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine setEnergy(getEnergy() + gain); } } - else if(inventory[27].getItem() instanceof IEnergyContainerItem) + else if(MekanismUtils.useRF() && inventory[27].getItem() instanceof IEnergyContainerItem) { ItemStack itemStack = inventory[27]; IEnergyContainerItem item = (IEnergyContainerItem)inventory[27].getItem(); diff --git a/src/main/java/mekanism/common/integration/MekanismHooks.java b/src/main/java/mekanism/common/integration/MekanismHooks.java index bb2a020b0..105e65b36 100644 --- a/src/main/java/mekanism/common/integration/MekanismHooks.java +++ b/src/main/java/mekanism/common/integration/MekanismHooks.java @@ -1,11 +1,5 @@ package mekanism.common.integration; -import ic2.api.recipe.IRecipeInput; -import ic2.api.recipe.RecipeInputItemStack; -import ic2.api.recipe.RecipeInputOreDict; -import ic2.api.recipe.RecipeOutput; -import ic2.api.recipe.Recipes; - import java.util.List; import java.util.Map; @@ -19,8 +13,15 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.ModAPIManager; +import cpw.mods.fml.common.Optional.Method; import cpw.mods.fml.common.event.FMLInterModComms; import dan200.computercraft.api.ComputerCraftAPI; +import ic2.api.recipe.IRecipeInput; +import ic2.api.recipe.RecipeInputItemStack; +import ic2.api.recipe.RecipeInputOreDict; +import ic2.api.recipe.RecipeOutput; +import ic2.api.recipe.Recipes; /** * Hooks for Mekanism. Use to grab items or blocks out of different mods. @@ -34,9 +35,11 @@ public final class MekanismHooks private Class BuildCraftEnergy; public boolean IC2Loaded = false; + public boolean IC2APILoaded = false; public boolean RailcraftLoaded = false; public boolean BasicComponentsLoaded = false; - public boolean BuildCraftLoaded = false; + public boolean BuildCraftPowerLoaded = false; + public boolean RedstoneFluxLoaded = false; public boolean TELoaded = false; public boolean CCLoaded = false; @@ -45,10 +48,12 @@ public final class MekanismHooks public void hook() { + if(ModAPIManager.INSTANCE.hasAPI("IC2API")) IC2APILoaded = true; + if(ModAPIManager.INSTANCE.hasAPI("BuildCraftAPI|power")) BuildCraftPowerLoaded = true; + if(ModAPIManager.INSTANCE.hasAPI("CoFHAPI|energy")) RedstoneFluxLoaded = true; if(Loader.isModLoaded("IC2")) IC2Loaded = true; if(Loader.isModLoaded("Railcraft")) RailcraftLoaded = true; if(Loader.isModLoaded("BasicComponents")) BasicComponentsLoaded = true; - if(Loader.isModLoaded("BuildCraft|Energy")) BuildCraftLoaded = true; if(Loader.isModLoaded("ThermalExpansion")) TELoaded = true; if(Loader.isModLoaded("ComputerCraft")) CCLoaded = true; @@ -61,58 +66,7 @@ public final class MekanismHooks if(IC2Loaded) { - for(Map.Entry entry : Recipes.macerator.getRecipes().entrySet()) - { - if(!entry.getKey().getInputs().isEmpty()) - { - List names = MekanismUtils.getOreDictName(entry.getKey().getInputs().get(0)); - - for(String name : names) - { - boolean did = false; - - if(name.startsWith("ingot")) - { - RecipeHandler.addCrusherRecipe(entry.getKey().getInputs().get(0), entry.getValue().items.get(0)); - did = true; - } - - if(did) - { - break; - } - } - } - } - - try { - Recipes.macerator.addRecipe(new RecipeInputOreDict("oreOsmium"), null, new ItemStack(Mekanism.Dust, 2, 2)); - } catch(Exception e) {} - - try { - Recipes.macerator.addRecipe(new RecipeInputOreDict("ingotOsmium"), null, new ItemStack(Mekanism.Dust, 1, 2)); - Recipes.macerator.addRecipe(new RecipeInputOreDict("ingotRefinedObsidian"), null, new ItemStack(Mekanism.Dust, 1, 3)); - Recipes.macerator.addRecipe(new RecipeInputOreDict("ingotRefinedGlowstone"), null, new ItemStack(Items.glowstone_dust)); - Recipes.macerator.addRecipe(new RecipeInputOreDict("ingotSteel"), null, new ItemStack(Mekanism.Dust, 1, 5)); - } catch(Exception e) {} - - try { - Recipes.macerator.addRecipe(new RecipeInputOreDict("clumpIron"), null, new ItemStack(Mekanism.DirtyDust, 1, 0)); - Recipes.macerator.addRecipe(new RecipeInputOreDict("clumpGold"), null, new ItemStack(Mekanism.DirtyDust, 1, 1)); - Recipes.macerator.addRecipe(new RecipeInputOreDict("clumpOsmium"), null, new ItemStack(Mekanism.DirtyDust, 1, 2)); - Recipes.macerator.addRecipe(new RecipeInputOreDict("clumpCopper"), null, new ItemStack(Mekanism.DirtyDust, 1, 3)); - Recipes.macerator.addRecipe(new RecipeInputOreDict("clumpTin"), null, new ItemStack(Mekanism.DirtyDust, 1, 4)); - Recipes.macerator.addRecipe(new RecipeInputOreDict("clumpSilver"), null, new ItemStack(Mekanism.DirtyDust, 1, 5)); - Recipes.macerator.addRecipe(new RecipeInputOreDict("clumpObsidian"), null, new ItemStack(Mekanism.DirtyDust, 1, 6)); - Recipes.macerator.addRecipe(new RecipeInputOreDict("clumpLead"), null, new ItemStack(Mekanism.DirtyDust, 1, 7)); - } catch(Exception e) {} - - NBTTagCompound tag = new NBTTagCompound(); - - tag.setInteger("amplification", 50000); - - Recipes.matterAmplifier.addRecipe(new RecipeInputItemStack(new ItemStack(Mekanism.EnrichedAlloy), 1), tag); - + hookIC2Recipes(); Mekanism.logger.info("Hooked into IC2 successfully."); } @@ -133,7 +87,7 @@ public final class MekanismHooks Mekanism.logger.info("Hooked into BasicComponents successfully."); } - if(BuildCraftLoaded) + if(BuildCraftPowerLoaded) { Mekanism.logger.info("Hooked into BuildCraft successfully."); } @@ -147,6 +101,62 @@ public final class MekanismHooks } + @Method(modid = "IC2API") + public void hookIC2Recipes() + { + for(Map.Entry entry : Recipes.macerator.getRecipes().entrySet()) + { + if(!entry.getKey().getInputs().isEmpty()) + { + List names = MekanismUtils.getOreDictName(entry.getKey().getInputs().get(0)); + + for(String name : names) + { + boolean did = false; + + if(name.startsWith("ingot")) + { + RecipeHandler.addCrusherRecipe(entry.getKey().getInputs().get(0), entry.getValue().items.get(0)); + did = true; + } + + if(did) + { + break; + } + } + } + } + + try { + Recipes.macerator.addRecipe(new RecipeInputOreDict("oreOsmium"), null, new ItemStack(Mekanism.Dust, 2, 2)); + } catch(Exception e) {} + + try { + Recipes.macerator.addRecipe(new RecipeInputOreDict("ingotOsmium"), null, new ItemStack(Mekanism.Dust, 1, 2)); + Recipes.macerator.addRecipe(new RecipeInputOreDict("ingotRefinedObsidian"), null, new ItemStack(Mekanism.Dust, 1, 3)); + Recipes.macerator.addRecipe(new RecipeInputOreDict("ingotRefinedGlowstone"), null, new ItemStack(Items.glowstone_dust)); + Recipes.macerator.addRecipe(new RecipeInputOreDict("ingotSteel"), null, new ItemStack(Mekanism.Dust, 1, 5)); + } catch(Exception e) {} + + try { + Recipes.macerator.addRecipe(new RecipeInputOreDict("clumpIron"), null, new ItemStack(Mekanism.DirtyDust, 1, 0)); + Recipes.macerator.addRecipe(new RecipeInputOreDict("clumpGold"), null, new ItemStack(Mekanism.DirtyDust, 1, 1)); + Recipes.macerator.addRecipe(new RecipeInputOreDict("clumpOsmium"), null, new ItemStack(Mekanism.DirtyDust, 1, 2)); + Recipes.macerator.addRecipe(new RecipeInputOreDict("clumpCopper"), null, new ItemStack(Mekanism.DirtyDust, 1, 3)); + Recipes.macerator.addRecipe(new RecipeInputOreDict("clumpTin"), null, new ItemStack(Mekanism.DirtyDust, 1, 4)); + Recipes.macerator.addRecipe(new RecipeInputOreDict("clumpSilver"), null, new ItemStack(Mekanism.DirtyDust, 1, 5)); + Recipes.macerator.addRecipe(new RecipeInputOreDict("clumpObsidian"), null, new ItemStack(Mekanism.DirtyDust, 1, 6)); + Recipes.macerator.addRecipe(new RecipeInputOreDict("clumpLead"), null, new ItemStack(Mekanism.DirtyDust, 1, 7)); + } catch(Exception e) {} + + NBTTagCompound tag = new NBTTagCompound(); + + tag.setInteger("amplification", 50000); + + Recipes.matterAmplifier.addRecipe(new RecipeInputItemStack(new ItemStack(Mekanism.EnrichedAlloy), 1), tag); + } + public void addPulverizerRecipe(ItemStack input, ItemStack output, int energy) { NBTTagCompound nbtTags = new NBTTagCompound(); diff --git a/src/main/java/mekanism/common/integration/OreDictManager.java b/src/main/java/mekanism/common/integration/OreDictManager.java index 3e827dbd9..c6bc0ea7a 100644 --- a/src/main/java/mekanism/common/integration/OreDictManager.java +++ b/src/main/java/mekanism/common/integration/OreDictManager.java @@ -26,6 +26,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.CraftingManager; import net.minecraft.item.crafting.FurnaceRecipes; import net.minecraftforge.oredict.OreDictionary; +import cpw.mods.fml.common.Optional.Method; public final class OreDictManager { @@ -348,9 +349,9 @@ public final class OreDictManager try { RecipeHandler.addCrusherRecipe(new ItemStack(Mekanism.Ingot, 1, 2), MekanismUtils.size(OreDictionary.getOres("dustBronze").get(0), 1)); - if(Mekanism.hooks.IC2Loaded) + if(Mekanism.hooks.IC2APILoaded) { - Recipes.macerator.addRecipe(new RecipeInputOreDict("ingotBronze"), null, MekanismUtils.size(OreDictionary.getOres("dustBronze").get(0), 1)); + addIC2BronzeRecipe(); } } catch(Exception e) {} @@ -456,6 +457,13 @@ public final class OreDictManager } + @Method(modid = "IC2API") + public static void addIC2BronzeRecipe() + { + Recipes.macerator.addRecipe(new RecipeInputOreDict("ingotBronze"), null, MekanismUtils.size(OreDictionary.getOres("dustBronze").get(0), 1)); + } + + /** * Handy method for retrieving all log items, finding their corresponding planks, and making recipes with them. Taken from CofhCore. */ diff --git a/src/main/java/mekanism/common/inventory/container/ContainerEnergyCube.java b/src/main/java/mekanism/common/inventory/container/ContainerEnergyCube.java index 934c5c2a3..b545ba3e1 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerEnergyCube.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerEnergyCube.java @@ -5,6 +5,8 @@ import mekanism.common.inventory.slot.SlotEnergy.SlotCharge; import mekanism.common.inventory.slot.SlotEnergy.SlotDischarge; import mekanism.common.tile.TileEntityEnergyCube; import mekanism.common.util.ChargeUtils; +import mekanism.common.util.MekanismUtils; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.init.Items; @@ -181,6 +183,6 @@ public class ContainerEnergyCube extends Container private boolean canTransfer(ItemStack slotStack) { - return slotStack.getItem() instanceof IElectricItem; + return MekanismUtils.useIC2() && slotStack.getItem() instanceof IElectricItem; } } diff --git a/src/main/java/mekanism/common/item/ItemBlockEnergyCube.java b/src/main/java/mekanism/common/item/ItemBlockEnergyCube.java index 83abb51b4..fd18c495c 100644 --- a/src/main/java/mekanism/common/item/ItemBlockEnergyCube.java +++ b/src/main/java/mekanism/common/item/ItemBlockEnergyCube.java @@ -31,9 +31,17 @@ import net.minecraftforge.common.util.Constants.NBT; import org.lwjgl.input.Keyboard; import cofh.api.energy.IEnergyContainerItem; + +import cpw.mods.fml.common.Optional.Interface; +import cpw.mods.fml.common.Optional.InterfaceList; +import cpw.mods.fml.common.Optional.Method; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +@InterfaceList({ + @Interface(iface = "cofh.api.energy.IEnergyContainerItem", modid = "CoFHAPI|energy"), + @Interface(iface = "ic2.api.item.ISpecialElectricItem", modid = "IC2API") +}) public class ItemBlockEnergyCube extends ItemBlock implements IEnergizedItem, IEnergyCube, ISpecialElectricItem, ISustainedInventory, IEnergyContainerItem { public Block metaBlock; @@ -126,24 +134,28 @@ public class ItemBlockEnergyCube extends ItemBlock implements IEnergizedItem, IE } @Override + @Method(modid = "IC2API") public boolean canProvideEnergy(ItemStack itemStack) { return true; } @Override + @Method(modid = "IC2API") public int getMaxCharge(ItemStack itemStack) { return 0; } @Override + @Method(modid = "IC2API") public int getTier(ItemStack itemStack) { return 4; } @Override + @Method(modid = "IC2API") public int getTransferLimit(ItemStack itemStack) { return 0; @@ -291,18 +303,21 @@ public class ItemBlockEnergyCube extends ItemBlock implements IEnergizedItem, IE } @Override + @Method(modid = "IC2API") public IElectricItemManager getManager(ItemStack itemStack) { return IC2ItemManager.getManager(this); } @Override + @Method(modid = "IC2API") public Item getChargedItem(ItemStack itemStack) { return this; } @Override + @Method(modid = "IC2API") public Item getEmptyItem(ItemStack itemStack) { return this; diff --git a/src/main/java/mekanism/common/item/ItemBlockMachine.java b/src/main/java/mekanism/common/item/ItemBlockMachine.java index 2c2ff46f4..ca77c099b 100644 --- a/src/main/java/mekanism/common/item/ItemBlockMachine.java +++ b/src/main/java/mekanism/common/item/ItemBlockMachine.java @@ -65,6 +65,10 @@ import net.minecraftforge.fluids.FluidStack; import org.lwjgl.input.Keyboard; import cofh.api.energy.IEnergyContainerItem; + +import cpw.mods.fml.common.Optional.Interface; +import cpw.mods.fml.common.Optional.InterfaceList; +import cpw.mods.fml.common.Optional.Method; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -101,6 +105,10 @@ import cpw.mods.fml.relauncher.SideOnly; * @author AidanBrady * */ +@InterfaceList({ + @Interface(iface = "cofh.api.energy.IEnergyContainerItem", modid = "CoFHAPI|energy"), + @Interface(iface = "ic2.api.item.ISpecialElectricItem", modid = "IC2API") +}) public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpecialElectricItem, IUpgradeManagement, IFactory, ISustainedInventory, ISustainedTank, IElectricChest, IEnergyContainerItem { public Block metaBlock; @@ -385,24 +393,28 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec } @Override + @Method(modid = "IC2API") public boolean canProvideEnergy(ItemStack itemStack) { return false; } @Override + @Method(modid = "IC2API") public int getMaxCharge(ItemStack itemStack) { return 0; } @Override + @Method(modid = "IC2API") public int getTier(ItemStack itemStack) { return 4; } @Override + @Method(modid = "IC2API") public int getTransferLimit(ItemStack itemStack) { return 0; @@ -425,7 +437,7 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec { setEnergy(itemstack, getEnergy(itemstack) + EnergizedItemManager.discharge(inv.getStackInSlot(54), getMaxEnergy(itemstack) - getEnergy(itemstack))); } - else if(Mekanism.hooks.IC2Loaded && inv.getStackInSlot(54).getItem() instanceof IElectricItem) + else if(MekanismUtils.useIC2() && inv.getStackInSlot(54).getItem() instanceof IElectricItem) { IElectricItem item = (IElectricItem)inv.getStackInSlot(54).getItem(); @@ -435,7 +447,7 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec setEnergy(itemstack, getEnergy(itemstack) + gain); } } - else if(inv.getStackInSlot(54).getItem() instanceof IEnergyContainerItem) + else if(MekanismUtils.useRF() && inv.getStackInSlot(54).getItem() instanceof IEnergyContainerItem) { ItemStack itemStack = inv.getStackInSlot(54); IEnergyContainerItem item = (IEnergyContainerItem)inv.getStackInSlot(54).getItem(); @@ -981,6 +993,7 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec } @Override + @Method(modid = "IC2API") public double getMaxTransfer(ItemStack itemStack) { return getMaxEnergy(itemStack)*0.005; @@ -1055,18 +1068,21 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec } @Override + @Method(modid = "IC2API") public IElectricItemManager getManager(ItemStack itemStack) { return IC2ItemManager.getManager(this); } @Override + @Method(modid = "IC2API") public Item getChargedItem(ItemStack itemStack) { return this; } @Override + @Method(modid = "IC2API") public Item getEmptyItem(ItemStack itemStack) { return this; diff --git a/src/main/java/mekanism/common/item/ItemConfigurator.java b/src/main/java/mekanism/common/item/ItemConfigurator.java index 74e0c9621..2d6cf23b1 100644 --- a/src/main/java/mekanism/common/item/ItemConfigurator.java +++ b/src/main/java/mekanism/common/item/ItemConfigurator.java @@ -22,8 +22,12 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ChatComponentText; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; +import cpw.mods.fml.common.Optional.Interface; +import cpw.mods.fml.common.Optional.Method; + import buildcraft.api.tools.IToolWrench; +@Interface(iface = "buildcraft.api.tools.IToolWrench", modid = "BuildCraftAPI|tools") public class ItemConfigurator extends ItemEnergized implements IToolWrench { public final int ENERGY_PER_CONFIGURE = 400; @@ -304,11 +308,13 @@ public class ItemConfigurator extends ItemEnergized implements IToolWrench } @Override + @Method(modid = "BuildCraftAPI|tools") public boolean canWrench(EntityPlayer player, int x, int y, int z) { return !(player.worldObj.getTileEntity(x, y, z) instanceof TileEntityBasicBlock); } @Override + @Method(modid = "BuildCraftAPI|tools") public void wrenchUsed(EntityPlayer player, int x, int y, int z) {} } diff --git a/src/main/java/mekanism/common/item/ItemEnergized.java b/src/main/java/mekanism/common/item/ItemEnergized.java index 991fa05db..a096e0c96 100644 --- a/src/main/java/mekanism/common/item/ItemEnergized.java +++ b/src/main/java/mekanism/common/item/ItemEnergized.java @@ -15,8 +15,16 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import cpw.mods.fml.common.Optional.Interface; +import cpw.mods.fml.common.Optional.InterfaceList; +import cpw.mods.fml.common.Optional.Method; + import cofh.api.energy.IEnergyContainerItem; +@InterfaceList({ + @Interface(iface = "cofh.api.energy.IEnergyContainerItem", modid = "CoFHAPI|energy"), + @Interface(iface = "ic2.api.item.ISpecialElectricItem", modid = "IC2API") +}) public class ItemEnergized extends ItemMekanism implements IEnergizedItem, ISpecialElectricItem, IEnergyContainerItem { /** The maximum amount of energy this item can hold. */ @@ -57,36 +65,42 @@ public class ItemEnergized extends ItemMekanism implements IEnergizedItem, ISpec } @Override + @Method(modid = "IC2API") public boolean canProvideEnergy(ItemStack itemStack) { return canSend(itemStack); } @Override + @Method(modid = "IC2API") public Item getChargedItem(ItemStack itemStack) { return this; } @Override + @Method(modid = "IC2API") public Item getEmptyItem(ItemStack itemStack) { return this; } @Override + @Method(modid = "IC2API") public int getMaxCharge(ItemStack itemStack) { return 0; } @Override + @Method(modid = "IC2API") public int getTier(ItemStack itemStack) { return 4; } @Override + @Method(modid = "IC2API") public int getTransferLimit(ItemStack itemStack) { return 0; @@ -200,6 +214,7 @@ public class ItemEnergized extends ItemMekanism implements IEnergizedItem, ISpec } @Override + @Method(modid = "IC2API") public IElectricItemManager getManager(ItemStack itemStack) { return IC2ItemManager.getManager(this); diff --git a/src/main/java/mekanism/common/item/ItemFreeRunners.java b/src/main/java/mekanism/common/item/ItemFreeRunners.java index 3fd5c241b..9b4f15331 100644 --- a/src/main/java/mekanism/common/item/ItemFreeRunners.java +++ b/src/main/java/mekanism/common/item/ItemFreeRunners.java @@ -27,10 +27,18 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.EnumHelper; import net.minecraftforge.event.entity.living.LivingAttackEvent; import cofh.api.energy.IEnergyContainerItem; + +import cpw.mods.fml.common.Optional.Interface; +import cpw.mods.fml.common.Optional.InterfaceList; +import cpw.mods.fml.common.Optional.Method; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +@InterfaceList({ + @Interface(iface = "cofh.api.energy.IEnergyContainerItem", modid = "CoFHAPI|energy"), + @Interface(iface = "ic2.api.item.ISpecialElectricItem", modid = "IC2API") +}) public class ItemFreeRunners extends ItemArmor implements IEnergizedItem, ISpecialElectricItem, IEnergyContainerItem { /** The maximum amount of energy this item can hold. */ @@ -96,36 +104,42 @@ public class ItemFreeRunners extends ItemArmor implements IEnergizedItem, ISpeci } @Override + @Method(modid = "IC2API") public boolean canProvideEnergy(ItemStack itemStack) { return canSend(itemStack); } @Override + @Method(modid = "IC2API") public Item getChargedItem(ItemStack itemStack) { return this; } @Override + @Method(modid = "IC2API") public Item getEmptyItem(ItemStack itemStack) { return this; } @Override + @Method(modid = "IC2API") public int getMaxCharge(ItemStack itemStack) { return 0; } @Override + @Method(modid = "IC2API") public int getTier(ItemStack itemStack) { return 4; } @Override + @Method(modid = "IC2API") public int getTransferLimit(ItemStack itemStack) { return 0; @@ -239,6 +253,7 @@ public class ItemFreeRunners extends ItemArmor implements IEnergizedItem, ISpeci } @Override + @Method(modid = "IC2API") public IElectricItemManager getManager(ItemStack itemStack) { return IC2ItemManager.getManager(this); diff --git a/src/main/java/mekanism/common/multipart/PartLogisticalTransporter.java b/src/main/java/mekanism/common/multipart/PartLogisticalTransporter.java index 745bbfacd..e8ef818cf 100644 --- a/src/main/java/mekanism/common/multipart/PartLogisticalTransporter.java +++ b/src/main/java/mekanism/common/multipart/PartLogisticalTransporter.java @@ -37,9 +37,13 @@ import net.minecraftforge.common.util.ForgeDirection; import buildcraft.api.transport.IPipeTile; import buildcraft.api.transport.PipeWire; import codechicken.lib.vec.Vector3; + +import cpw.mods.fml.common.Optional.Interface; +import cpw.mods.fml.common.Optional.Method; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +@Interface(iface = "buildcraft.api.transport.IPipeTile", modid = "BuildCraftAPI|transport") public class PartLogisticalTransporter extends PartSidedPipe implements ILogisticalTransporter, IPipeTile { public static TransmitterIcons transporterIcons = new TransmitterIcons(3, 2); @@ -760,7 +764,8 @@ public class PartLogisticalTransporter extends PartSidedPipe implements ILogisti } @Override - public boolean isWireActive(PipeWire wire) + @Method(modid = "BuildCraftAPI|transport") + public boolean isWireActive(PipeWire wire) { return false; } diff --git a/src/main/java/mekanism/common/multipart/PartSidedPipe.java b/src/main/java/mekanism/common/multipart/PartSidedPipe.java index 14b492d5b..448561675 100644 --- a/src/main/java/mekanism/common/multipart/PartSidedPipe.java +++ b/src/main/java/mekanism/common/multipart/PartSidedPipe.java @@ -47,6 +47,8 @@ import codechicken.multipart.NormalOcclusionTest; import codechicken.multipart.PartMap; import codechicken.multipart.TMultiPart; import codechicken.multipart.TSlottedPart; + +import cpw.mods.fml.common.Loader; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -421,7 +423,7 @@ public abstract class PartSidedPipe extends TMultiPart implements TSlottedPart, return false; } - if(item.getItem() instanceof IToolWrench && !(item.getItem() instanceof ItemConfigurator) && player.isSneaking()) + if(Loader.isModLoaded("BuildCraftAPI|tools") && item.getItem() instanceof IToolWrench && !(item.getItem() instanceof ItemConfigurator) && player.isSneaking()) { if(!world().isRemote) { diff --git a/src/main/java/mekanism/common/multipart/PartUniversalCable.java b/src/main/java/mekanism/common/multipart/PartUniversalCable.java index 35b57f940..52dc19d5b 100644 --- a/src/main/java/mekanism/common/multipart/PartUniversalCable.java +++ b/src/main/java/mekanism/common/multipart/PartUniversalCable.java @@ -1,6 +1,6 @@ package mekanism.common.multipart; -import ic2.api.energy.tile.IEnergySource; +//import ic2.api.energy.tile.IEnergySource; import java.util.List; import java.util.Set; @@ -26,9 +26,17 @@ import buildcraft.api.power.PowerHandler; import buildcraft.api.power.PowerHandler.PowerReceiver; import codechicken.lib.vec.Vector3; import cofh.api.energy.IEnergyHandler; + +import cpw.mods.fml.common.Optional.Interface; +import cpw.mods.fml.common.Optional.InterfaceList; +import cpw.mods.fml.common.Optional.Method; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +@InterfaceList({ + @Interface(iface = "cofh.api.energy.IEnergyHandler", modid = "CoFHAPI|energy"), + @Interface(iface = "buildcraft.api.power.IPowerReceptor", modid = "BuildCraftAPI|power"), +}) public class PartUniversalCable extends PartTransmitter implements IStrictEnergyAcceptor, IEnergyHandler, IPowerReceptor { public Tier.CableTier tier; @@ -46,9 +54,13 @@ public class PartUniversalCable extends PartTransmitter implement public PartUniversalCable(Tier.CableTier cableTier) { tier = cableTier; - powerHandler = new PowerHandler(this, PowerHandler.Type.STORAGE); - powerHandler.configurePowerPerdition(0, 0); - powerHandler.configure(0, 0, 0, 0); + + if(MekanismUtils.useBuildCraft()) + { + powerHandler = new PowerHandler(this, PowerHandler.Type.STORAGE); + powerHandler.configurePowerPerdition(0, 0); + powerHandler.configure(0, 0, 0, 0); + } } @Override @@ -80,31 +92,34 @@ public class PartUniversalCable extends PartTransmitter implement cacheEnergy = 0; } - List sides = getConnections(ConnectionType.PULL); - if(!sides.isEmpty()) + /*if(MekanismUtils.useIC2()) { - TileEntity[] connectedAcceptors = CableUtils.getConnectedEnergyAcceptors(tile()); - - for(ForgeDirection side : sides) + List sides = getConnections(ConnectionType.PULL); + if(!sides.isEmpty()) { - if(connectedAcceptors[side.ordinal()] != null) + TileEntity[] connectedAcceptors = CableUtils.getConnectedEnergyAcceptors(tile()); + + for(ForgeDirection side : sides) { - TileEntity acceptor = connectedAcceptors[side.ordinal()]; - - if(acceptor instanceof IEnergySource) + if(connectedAcceptors[side.ordinal()] != null) { - double received = ((IEnergySource) acceptor).getOfferedEnergy()*Mekanism.FROM_IC2; - double toDraw = received; + TileEntity acceptor = connectedAcceptors[side.ordinal()]; - if(received > 0) + if(acceptor instanceof IEnergySource) { - toDraw -= getTransmitterNetwork().emit(received); + double received = ((IEnergySource) acceptor).getOfferedEnergy() * Mekanism.FROM_IC2; + double toDraw = received; + + if(received > 0) + { + toDraw -= getTransmitterNetwork().emit(received); + } + ((IEnergySource) acceptor).drawEnergy(toDraw * Mekanism.TO_IC2); } - ((IEnergySource) acceptor).drawEnergy(toDraw*Mekanism.TO_IC2); } } } - } + }*/ } super.update(); @@ -252,6 +267,7 @@ public class PartUniversalCable extends PartTransmitter implement } @Override + @Method(modid = "CoFHAPI|energy") public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) { if(!simulate) @@ -263,24 +279,28 @@ public class PartUniversalCable extends PartTransmitter implement } @Override + @Method(modid = "CoFHAPI|energy") public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) { return 0; } @Override + @Method(modid = "CoFHAPI|energy") public boolean canConnectEnergy(ForgeDirection from) { return true; } @Override + @Method(modid = "CoFHAPI|energy") public int getEnergyStored(ForgeDirection from) { return 0; } @Override + @Method(modid = "CoFHAPI|energy") public int getMaxEnergyStored(ForgeDirection from) { return (int)Math.round(getTransmitterNetwork().getEnergyNeeded()*Mekanism.TO_TE); @@ -331,6 +351,7 @@ public class PartUniversalCable extends PartTransmitter implement } @Override + @Method(modid = "BuildCraftAPI|power") public PowerReceiver getPowerReceiver(ForgeDirection side) { if(getTransmitterNetwork().getEnergyNeeded() == 0) @@ -342,6 +363,7 @@ public class PartUniversalCable extends PartTransmitter implement } @Override + @Method(modid = "BuildCraftAPI|power") public World getWorld() { return world(); diff --git a/src/main/java/mekanism/common/tile/TileEntityAdvancedBoundingBlock.java b/src/main/java/mekanism/common/tile/TileEntityAdvancedBoundingBlock.java index 48ec9e66c..7f4f0a1c5 100644 --- a/src/main/java/mekanism/common/tile/TileEntityAdvancedBoundingBlock.java +++ b/src/main/java/mekanism/common/tile/TileEntityAdvancedBoundingBlock.java @@ -1,7 +1,6 @@ package mekanism.common.tile; import ic2.api.energy.tile.IEnergySink; -import ic2.api.energy.tile.IEnergyTile; import mekanism.api.Coord4D; import mekanism.api.IFilterAccess; import mekanism.api.energy.IStrictEnergyAcceptor; @@ -15,6 +14,10 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; +import cpw.mods.fml.common.Optional.Interface; +import cpw.mods.fml.common.Optional.InterfaceList; +import cpw.mods.fml.common.Optional.Method; + import buildcraft.api.power.IPowerReceptor; import buildcraft.api.power.PowerHandler; import buildcraft.api.power.PowerHandler.PowerReceiver; @@ -23,7 +26,12 @@ import dan200.computercraft.api.lua.ILuaContext; import dan200.computercraft.api.peripheral.IComputerAccess; import dan200.computercraft.api.peripheral.IPeripheral; -public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock implements ISidedInventory, IEnergySink, IStrictEnergyAcceptor, IPowerReceptor, IEnergyTile, IStrictEnergyStorage, IEnergyHandler, IPeripheral, IFilterAccess +@InterfaceList({ + @Interface(iface = "buildcraft.api.power.IPowerReceptor", modid = "BuildCraftAPI|power"), + @Interface(iface = "ic2.api.energy.tile.IEnergySink", modid = "IC2API", striprefs = true), + @Interface(iface = "cofh.api.energy.IEnergyHandler", modid = "CoFHAPI|energy") +}) +public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock implements ISidedInventory, IEnergySink, IStrictEnergyAcceptor, IPowerReceptor, IStrictEnergyStorage, IEnergyHandler, IPeripheral, IFilterAccess { @Override public int getSizeInventory() @@ -186,6 +194,7 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp } @Override + @Method(modid = "IC2API") public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction) { if(getInv() == null) @@ -197,6 +206,7 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp } @Override + @Method(modid = "CoFHAPI|energy") public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) { if(getInv() == null) @@ -208,6 +218,7 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp } @Override + @Method(modid = "CoFHAPI|energy") public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) { if(getInv() == null) @@ -219,6 +230,7 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp } @Override + @Method(modid = "CoFHAPI|energy") public boolean canConnectEnergy(ForgeDirection from) { if(getInv() == null) @@ -230,6 +242,7 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp } @Override + @Method(modid = "CoFHAPI|energy") public int getEnergyStored(ForgeDirection from) { if(getInv() == null) @@ -241,6 +254,7 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp } @Override + @Method(modid = "CoFHAPI|energy") public int getMaxEnergyStored(ForgeDirection from) { if(getInv() == null) @@ -285,6 +299,7 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp } @Override + @Method(modid = "BuildCraftAPI|power") public PowerReceiver getPowerReceiver(ForgeDirection side) { if(getInv() == null) @@ -296,6 +311,7 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp } @Override + @Method(modid = "BuildCraftAPI|power") public void doWork(PowerHandler workProvider) { if(getInv() == null) @@ -307,6 +323,7 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp } @Override + @Method(modid = "BuildCraftAPI|power") public World getWorld() { if(getInv() == null) @@ -340,6 +357,7 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp } @Override + @Method(modid = "IC2API") public double demandedEnergyUnits() { if(getInv() == null) @@ -351,6 +369,7 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp } @Override + @Method(modid = "IC2API") public double injectEnergyUnits(ForgeDirection directionFrom, double amount) { if(getInv() == null) @@ -362,6 +381,7 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp } @Override + @Method(modid = "IC2API") public int getMaxSafeInput() { if(getInv() == null) diff --git a/src/main/java/mekanism/common/tile/TileEntityBasicBlock.java b/src/main/java/mekanism/common/tile/TileEntityBasicBlock.java index 7369929a7..3ac0e08f3 100644 --- a/src/main/java/mekanism/common/tile/TileEntityBasicBlock.java +++ b/src/main/java/mekanism/common/tile/TileEntityBasicBlock.java @@ -22,7 +22,10 @@ import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; +import cpw.mods.fml.common.Optional.Interface; +import cpw.mods.fml.common.Optional.Method; +@Interface(iface = "ic2.api.tile.IWrenchable", modid = "IC2API") public abstract class TileEntityBasicBlock extends TileEntity implements IWrenchable, ITileNetwork { /** The direction this block is facing. */ @@ -158,18 +161,21 @@ public abstract class TileEntityBasicBlock extends TileEntity implements IWrench } @Override + @Method(modid = "IC2API") public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) { return true; } @Override + @Method(modid = "IC2API") public short getFacing() { return (short)facing; } @Override + @Method(modid = "IC2API") public void setFacing(short direction) { if(canSetFacing(direction)) @@ -196,18 +202,21 @@ public abstract class TileEntityBasicBlock extends TileEntity implements IWrench } @Override + @Method(modid = "IC2API") public boolean wrenchCanRemove(EntityPlayer entityPlayer) { return true; } @Override + @Method(modid = "IC2API") public float getWrenchDropRate() { return 1.0F; } @Override + @Method(modid = "IC2API") public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { return getBlockType().getPickBlock(null, worldObj, xCoord, yCoord, zCoord); diff --git a/src/main/java/mekanism/common/tile/TileEntityBasicMachine.java b/src/main/java/mekanism/common/tile/TileEntityBasicMachine.java index 01bf1ee4d..4ba7768b5 100644 --- a/src/main/java/mekanism/common/tile/TileEntityBasicMachine.java +++ b/src/main/java/mekanism/common/tile/TileEntityBasicMachine.java @@ -21,9 +21,19 @@ import mekanism.common.tile.component.TileComponentUpgrade; import mekanism.common.util.MekanismUtils; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ResourceLocation; +import cpw.mods.fml.common.Optional.Interface; +import cpw.mods.fml.common.Optional.InterfaceList; + import dan200.computercraft.api.peripheral.IComputerAccess; import dan200.computercraft.api.peripheral.IPeripheral; +@InterfaceList({ + @Interface(iface = "ic2.api.energy.tile.IEnergySink", modid = "IC2API", striprefs = true), + @Interface(iface = "ic2.api.tile.IEnergyStorage", modid = "IC2API", striprefs = true), + @Interface(iface = "cofh.api.energy.IEnergyHandler", modid = "CoFHAPI|energy"), + @Interface(iface = "buildcraft.api.power.IPowerReceptor", modid = "BuildCraftAPI|power"), + @Interface(iface = "buildcraft.api.power.IPowerEmitter", modid = "BuildCraftAPI|power") +}) public abstract class TileEntityBasicMachine extends TileEntityElectricBlock implements IElectricMachine, IPeripheral, IActiveState, IInvConfiguration, IUpgradeTile, IHasSound, IRedstoneControl { /** This machine's side configuration. */ diff --git a/src/main/java/mekanism/common/tile/TileEntityChargepad.java b/src/main/java/mekanism/common/tile/TileEntityChargepad.java index cf97eaf57..1c62163ab 100644 --- a/src/main/java/mekanism/common/tile/TileEntityChargepad.java +++ b/src/main/java/mekanism/common/tile/TileEntityChargepad.java @@ -123,12 +123,12 @@ public class TileEntityChargepad extends TileEntityElectricBlock implements IAct { setEnergy(getEnergy() - EnergizedItemManager.charge(itemstack, getEnergy())); } - else if(Mekanism.hooks.IC2Loaded && itemstack.getItem() instanceof IElectricItem) + else if(MekanismUtils.useIC2() && itemstack.getItem() instanceof IElectricItem) { double sent = ElectricItem.manager.charge(itemstack, (int)(getEnergy()*Mekanism.TO_IC2), 4, true, false)*Mekanism.FROM_IC2; setEnergy(getEnergy() - sent); } - else if(itemstack.getItem() instanceof IEnergyContainerItem) + else if(MekanismUtils.useRF() && itemstack.getItem() instanceof IEnergyContainerItem) { IEnergyContainerItem item = (IEnergyContainerItem)itemstack.getItem(); diff --git a/src/main/java/mekanism/common/tile/TileEntityElectricBlock.java b/src/main/java/mekanism/common/tile/TileEntityElectricBlock.java index fdc8a13d9..54e542c54 100644 --- a/src/main/java/mekanism/common/tile/TileEntityElectricBlock.java +++ b/src/main/java/mekanism/common/tile/TileEntityElectricBlock.java @@ -3,7 +3,6 @@ package mekanism.common.tile; import ic2.api.energy.event.EnergyTileLoadEvent; import ic2.api.energy.event.EnergyTileUnloadEvent; import ic2.api.energy.tile.IEnergySink; -import ic2.api.energy.tile.IEnergyTile; import ic2.api.tile.IEnergyStorage; import io.netty.buffer.ByteBuf; @@ -23,13 +22,25 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.ForgeDirection; +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.Optional.Interface; +import cpw.mods.fml.common.Optional.InterfaceList; +import cpw.mods.fml.common.Optional.Method; + import buildcraft.api.power.IPowerEmitter; import buildcraft.api.power.IPowerReceptor; import buildcraft.api.power.PowerHandler; import buildcraft.api.power.PowerHandler.PowerReceiver; import cofh.api.energy.IEnergyHandler; -public abstract class TileEntityElectricBlock extends TileEntityContainerBlock implements ITileNetwork, IPowerEmitter, IPowerReceptor, IEnergyTile, IStrictEnergyStorage, IEnergyHandler, IEnergySink, IEnergyStorage, IStrictEnergyAcceptor, ICableOutputter +@InterfaceList({ + @Interface(iface = "ic2.api.energy.tile.IEnergySink", modid = "IC2API", striprefs = true), + @Interface(iface = "ic2.api.tile.IEnergyStorage", modid = "IC2API", striprefs = true), + @Interface(iface = "cofh.api.energy.IEnergyHandler", modid = "CoFHAPI|energy"), + @Interface(iface = "buildcraft.api.power.IPowerReceptor", modid = "BuildCraftAPI|power"), + @Interface(iface = "buildcraft.api.power.IPowerEmitter", modid = "BuildCraftAPI|power") +}) +public abstract class TileEntityElectricBlock extends TileEntityContainerBlock implements ITileNetwork, IPowerEmitter, IPowerReceptor, IStrictEnergyStorage, IEnergyHandler, IEnergySink, IEnergyStorage, IStrictEnergyAcceptor, ICableOutputter { /** How much energy is stored in this block. */ public double electricityStored; @@ -51,14 +62,17 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i super(name); MAX_ELECTRICITY = maxEnergy; - powerHandler = new PowerHandler(this, PowerHandler.Type.STORAGE); - powerHandler.configurePowerPerdition(0, 0); - powerHandler.configure(0, 0, 0, 0); + if(Loader.isModLoaded("BuildCraftAPI|power")) + { + powerHandler = new PowerHandler(this, PowerHandler.Type.STORAGE); + powerHandler.configurePowerPerdition(0, 0); + powerHandler.configure(0, 0, 0, 0); + } } public void register() { - if(!worldObj.isRemote) + if(!worldObj.isRemote && Loader.isModLoaded("IC2API")) { if(!Mekanism.ic2Registered.contains(Coord4D.get(this))) { @@ -70,7 +84,7 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i public void deregister() { - if(!worldObj.isRemote) + if(!worldObj.isRemote && Loader.isModLoaded("IC2API")) { if(Mekanism.ic2Registered.contains(Coord4D.get(this))) { @@ -171,6 +185,7 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i } @Override + @Method(modid = "BuildCraftAPI|power") public PowerReceiver getPowerReceiver(ForgeDirection side) { if(getConsumingSides().contains(side)) @@ -183,13 +198,14 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i protected void reconfigure() { - if(MekanismUtils.useBuildCraft()) + if(Loader.isModLoaded("BuildCraftAPI|power")) { powerHandler.configure(1, (float)((getMaxEnergy()-getEnergy())*Mekanism.TO_BC), 0, (float)(getMaxEnergy()*Mekanism.TO_BC)); } } @Override + @Method(modid = "BuildCraftAPI|power") public void doWork(PowerHandler workProvider) { if(powerHandler.getEnergyStored() > 0) @@ -206,6 +222,7 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i } @Override + @Method(modid = "BuildCraftAPI|power") public World getWorld() { return worldObj; @@ -222,6 +239,7 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i } @Override + @Method(modid = "CoFHAPI|energy") public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) { if(getConsumingSides().contains(from)) @@ -240,6 +258,7 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i } @Override + @Method(modid = "CoFHAPI|energy") public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) { if(getOutputtingSides().contains(from)) @@ -258,36 +277,42 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i } @Override + @Method(modid = "CoFHAPI|energy") public boolean canConnectEnergy(ForgeDirection from) { return getConsumingSides().contains(from) || getOutputtingSides().contains(from); } @Override + @Method(modid = "CoFHAPI|energy") public int getEnergyStored(ForgeDirection from) { return (int)Math.round(getEnergy()*Mekanism.TO_TE); } @Override + @Method(modid = "CoFHAPI|energy") public int getMaxEnergyStored(ForgeDirection from) { return (int)Math.round(getMaxEnergy()*Mekanism.TO_TE); } @Override + @Method(modid = "IC2API") public int getMaxSafeInput() { return Integer.MAX_VALUE; } @Override + @Method(modid = "IC2API") public void setStored(int energy) { setEnergy(energy*Mekanism.FROM_IC2); } @Override + @Method(modid = "IC2API") public int addEnergy(int amount) { setEnergy(getEnergy() + amount*Mekanism.FROM_IC2); @@ -295,6 +320,7 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i } @Override + @Method(modid = "IC2API") public boolean isTeleporterCompatible(ForgeDirection side) { return getOutputtingSides().contains(side); @@ -307,30 +333,35 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i } @Override + @Method(modid = "IC2API") public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction) { return !getOutputtingSides().contains(direction); } @Override + @Method(modid = "IC2API") public int getStored() { return (int)Math.round(getEnergy()*Mekanism.TO_IC2); } @Override + @Method(modid = "IC2API") public int getCapacity() { return (int)Math.round(getMaxEnergy()*Mekanism.TO_IC2); } @Override + @Method(modid = "IC2API") public int getOutput() { return (int)Math.round(getMaxOutput()*Mekanism.TO_IC2); } @Override + @Method(modid = "IC2API") public double demandedEnergyUnits() { return (getMaxEnergy() - getEnergy())*Mekanism.TO_IC2; @@ -343,12 +374,14 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i } @Override + @Method(modid = "IC2API") public double getOutputEnergyUnitsPerTick() { return getMaxOutput()*Mekanism.TO_IC2; } @Override + @Method(modid = "IC2API") public double injectEnergyUnits(ForgeDirection direction, double i) { if(Coord4D.get(this).getFromSide(direction).getTileEntity(worldObj) instanceof IGridTransmitter) @@ -374,6 +407,7 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i } @Override + @Method(modid = "BuildCraftAPI|power") public boolean canEmitPowerFrom(ForgeDirection side) { return getOutputtingSides().contains(side); diff --git a/src/main/java/mekanism/common/tile/TileEntityElectricMachine.java b/src/main/java/mekanism/common/tile/TileEntityElectricMachine.java index de0c50bf0..77ba72095 100644 --- a/src/main/java/mekanism/common/tile/TileEntityElectricMachine.java +++ b/src/main/java/mekanism/common/tile/TileEntityElectricMachine.java @@ -11,9 +11,19 @@ import mekanism.common.util.InventoryUtils; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.item.ItemStack; +import cpw.mods.fml.common.Optional.Interface; +import cpw.mods.fml.common.Optional.InterfaceList; + import dan200.computercraft.api.lua.ILuaContext; import dan200.computercraft.api.peripheral.IComputerAccess; +@InterfaceList({ + @Interface(iface = "ic2.api.energy.tile.IEnergySink", modid = "IC2API", striprefs = true), + @Interface(iface = "ic2.api.tile.IEnergyStorage", modid = "IC2API", striprefs = true), + @Interface(iface = "cofh.api.energy.IEnergyHandler", modid = "CoFHAPI|energy"), + @Interface(iface = "buildcraft.api.power.IPowerReceptor", modid = "BuildCraftAPI|power"), + @Interface(iface = "buildcraft.api.power.IPowerEmitter", modid = "BuildCraftAPI|power") +}) public abstract class TileEntityElectricMachine extends TileEntityBasicMachine { /** diff --git a/src/main/java/mekanism/common/tile/TileEntityEnergizedSmelter.java b/src/main/java/mekanism/common/tile/TileEntityEnergizedSmelter.java index 0a1d13fcd..c0b4735c0 100644 --- a/src/main/java/mekanism/common/tile/TileEntityEnergizedSmelter.java +++ b/src/main/java/mekanism/common/tile/TileEntityEnergizedSmelter.java @@ -7,7 +7,16 @@ import mekanism.client.gui.GuiProgress.ProgressBar; import mekanism.common.Mekanism; import mekanism.common.block.BlockMachine.MachineType; import net.minecraft.item.ItemStack; +import cpw.mods.fml.common.Optional.Interface; +import cpw.mods.fml.common.Optional.InterfaceList; +@InterfaceList({ + @Interface(iface = "ic2.api.energy.tile.IEnergySink", modid = "IC2API", striprefs = true), + @Interface(iface = "ic2.api.tile.IEnergyStorage", modid = "IC2API", striprefs = true), + @Interface(iface = "cofh.api.energy.IEnergyHandler", modid = "CoFHAPI|energy"), + @Interface(iface = "buildcraft.api.power.IPowerReceptor", modid = "BuildCraftAPI|power"), + @Interface(iface = "buildcraft.api.power.IPowerEmitter", modid = "BuildCraftAPI|power") +}) public class TileEntityEnergizedSmelter extends TileEntityElectricMachine { public static Map furnaceRecipes = new HashMap(); diff --git a/src/main/java/mekanism/common/util/CableUtils.java b/src/main/java/mekanism/common/util/CableUtils.java index efeb0d223..db63d4f24 100644 --- a/src/main/java/mekanism/common/util/CableUtils.java +++ b/src/main/java/mekanism/common/util/CableUtils.java @@ -59,9 +59,9 @@ public final class CableUtils public static boolean isEnergyAcceptor(TileEntity tileEntity) { return (tileEntity instanceof IStrictEnergyAcceptor || - tileEntity instanceof IEnergySink || - (tileEntity instanceof IPowerReceptor && !(tileEntity instanceof IGridTransmitter) && MekanismUtils.useBuildCraft()) || - tileEntity instanceof IEnergyHandler); + (MekanismUtils.useIC2() && tileEntity instanceof IEnergySink) || + (MekanismUtils.useBuildCraft() && tileEntity instanceof IPowerReceptor && !(tileEntity instanceof IGridTransmitter)) || + (MekanismUtils.useRF() && tileEntity instanceof IEnergyHandler)); } /** @@ -149,9 +149,9 @@ public final class CableUtils public static boolean isOutputter(TileEntity tileEntity, ForgeDirection side) { return (tileEntity instanceof ICableOutputter && ((ICableOutputter)tileEntity).canOutputTo(side.getOpposite())) || - (tileEntity instanceof IEnergySource && ((IEnergySource)tileEntity).emitsEnergyTo(tileEntity, side.getOpposite())) || - (tileEntity instanceof IEnergyHandler && ((IEnergyHandler)tileEntity).canConnectEnergy(side.getOpposite())) || - (tileEntity instanceof IPowerEmitter && ((IPowerEmitter)tileEntity).canEmitPowerFrom(side.getOpposite())); + (MekanismUtils.useIC2() && tileEntity instanceof IEnergySource && ((IEnergySource)tileEntity).emitsEnergyTo(tileEntity, side.getOpposite())) || + (MekanismUtils.useRF() && tileEntity instanceof IEnergyHandler && ((IEnergyHandler)tileEntity).canConnectEnergy(side.getOpposite())) || + (MekanismUtils.useBuildCraft() && tileEntity instanceof IPowerEmitter && ((IPowerEmitter)tileEntity).canEmitPowerFrom(side.getOpposite())); } /** @@ -186,7 +186,7 @@ public final class CableUtils return true; } } - else if(tileEntity instanceof IEnergyAcceptor) + else if(MekanismUtils.useIC2() && tileEntity instanceof IEnergyAcceptor) { if(((IEnergyAcceptor)tileEntity).acceptsEnergyFrom(orig, side.getOpposite())) { @@ -200,14 +200,14 @@ public final class CableUtils return true; } } - else if(tileEntity instanceof IEnergyHandler) + else if(MekanismUtils.useRF() && tileEntity instanceof IEnergyHandler) { if(((IEnergyHandler)tileEntity).canConnectEnergy(side.getOpposite())) { return true; } } - else if(tileEntity instanceof IPowerReceptor && MekanismUtils.useBuildCraft()) + else if(MekanismUtils.useBuildCraft() && tileEntity instanceof IPowerReceptor) { if(((IPowerReceptor)tileEntity).getPowerReceiver(side.getOpposite()) != null) { @@ -305,7 +305,7 @@ public final class CableUtils sent += acceptor.transferEnergyToAcceptor(side.getOpposite(), sendingEnergy); } } - else if(tileEntity instanceof IEnergyHandler) + else if(MekanismUtils.useRF() && tileEntity instanceof IEnergyHandler) { IEnergyHandler handler = (IEnergyHandler)tileEntity; @@ -315,7 +315,7 @@ public final class CableUtils sent += used*Mekanism.FROM_TE; } } - else if(tileEntity instanceof IEnergySink) + else if(MekanismUtils.useIC2() && tileEntity instanceof IEnergySink) { if(((IEnergySink)tileEntity).acceptsEnergyFrom(from, side.getOpposite())) { @@ -324,7 +324,7 @@ public final class CableUtils sent += (toSend - rejects); } } - else if(tileEntity instanceof IPowerReceptor && MekanismUtils.useBuildCraft()) + else if(MekanismUtils.useBuildCraft() && tileEntity instanceof IPowerReceptor) { PowerReceiver receiver = ((IPowerReceptor)tileEntity).getPowerReceiver(side.getOpposite()); diff --git a/src/main/java/mekanism/common/util/ChargeUtils.java b/src/main/java/mekanism/common/util/ChargeUtils.java index b03fa0eb6..3bd5a07c3 100644 --- a/src/main/java/mekanism/common/util/ChargeUtils.java +++ b/src/main/java/mekanism/common/util/ChargeUtils.java @@ -25,7 +25,7 @@ public final class ChargeUtils { storer.setEnergy(storer.getEnergy() + EnergizedItemManager.discharge(storer.inventory[slotID], storer.getMaxEnergy() - storer.getEnergy())); } - else if(Mekanism.hooks.IC2Loaded && storer.inventory[slotID].getItem() instanceof IElectricItem) + else if(MekanismUtils.useIC2() && storer.inventory[slotID].getItem() instanceof IElectricItem) { IElectricItem item = (IElectricItem)storer.inventory[slotID].getItem(); @@ -35,7 +35,7 @@ public final class ChargeUtils storer.setEnergy(storer.getEnergy() + gain); } } - else if(storer.inventory[slotID].getItem() instanceof IEnergyContainerItem) + else if(MekanismUtils.useRF() && storer.inventory[slotID].getItem() instanceof IEnergyContainerItem) { ItemStack itemStack = storer.inventory[slotID]; IEnergyContainerItem item = (IEnergyContainerItem)storer.inventory[slotID].getItem(); @@ -71,12 +71,12 @@ public final class ChargeUtils { storer.setEnergy(storer.getEnergy() - EnergizedItemManager.charge(storer.inventory[slotID], storer.getEnergy())); } - else if(Mekanism.hooks.IC2Loaded && storer.inventory[slotID].getItem() instanceof IElectricItem) + else if(Mekanism.hooks.IC2APILoaded && storer.inventory[slotID].getItem() instanceof IElectricItem) { double sent = ElectricItem.manager.charge(storer.inventory[slotID], (int)(storer.getEnergy()*Mekanism.TO_IC2), 4, true, false)*Mekanism.FROM_IC2; storer.setEnergy(storer.getEnergy() - sent); } - else if(storer.inventory[slotID].getItem() instanceof IEnergyContainerItem) + else if(MekanismUtils.useRF() && storer.inventory[slotID].getItem() instanceof IEnergyContainerItem) { ItemStack itemStack = storer.inventory[slotID]; IEnergyContainerItem item = (IEnergyContainerItem)storer.inventory[slotID].getItem(); @@ -96,9 +96,9 @@ public final class ChargeUtils */ public static boolean canBeDischarged(ItemStack itemstack) { - return (itemstack.getItem() instanceof IElectricItem && ((IElectricItem)itemstack.getItem()).canProvideEnergy(itemstack)) || + return (MekanismUtils.useIC2() && itemstack.getItem() instanceof IElectricItem && ((IElectricItem)itemstack.getItem()).canProvideEnergy(itemstack)) || (itemstack.getItem() instanceof IEnergizedItem && ((IEnergizedItem)itemstack.getItem()).canSend(itemstack)) || - (itemstack.getItem() instanceof IEnergyContainerItem && ((IEnergyContainerItem)itemstack.getItem()).extractEnergy(itemstack, 1, true) != 0) || + (MekanismUtils.useRF() && itemstack.getItem() instanceof IEnergyContainerItem && ((IEnergyContainerItem)itemstack.getItem()).extractEnergy(itemstack, 1, true) != 0) || itemstack.getItem() == Items.redstone; } @@ -109,9 +109,9 @@ public final class ChargeUtils */ public static boolean canBeCharged(ItemStack itemstack) { - return itemstack.getItem() instanceof IElectricItem || + return (MekanismUtils.useIC2() && itemstack.getItem() instanceof IElectricItem) || (itemstack.getItem() instanceof IEnergizedItem && ((IEnergizedItem)itemstack.getItem()).canReceive(itemstack)) || - (itemstack.getItem() instanceof IEnergyContainerItem && ((IEnergyContainerItem)itemstack.getItem()).receiveEnergy(itemstack, 1, true) != 0); + (MekanismUtils.useRF() && itemstack.getItem() instanceof IEnergyContainerItem && ((IEnergyContainerItem)itemstack.getItem()).receiveEnergy(itemstack, 1, true) != 0); } /** @@ -125,10 +125,10 @@ public final class ChargeUtils { if(chargeSlot) { - return itemstack.getItem() instanceof IElectricItem; + return MekanismUtils.useIC2() && itemstack.getItem() instanceof IElectricItem; } else { - return itemstack.getItem() instanceof IElectricItem && ((IElectricItem)itemstack.getItem()).canProvideEnergy(itemstack); + return MekanismUtils.useIC2() && itemstack.getItem() instanceof IElectricItem && ((IElectricItem)itemstack.getItem()).canProvideEnergy(itemstack); } } } diff --git a/src/main/java/mekanism/common/util/MekanismUtils.java b/src/main/java/mekanism/common/util/MekanismUtils.java index 0ccd506dc..2fa6f8c22 100644 --- a/src/main/java/mekanism/common/util/MekanismUtils.java +++ b/src/main/java/mekanism/common/util/MekanismUtils.java @@ -1173,13 +1173,33 @@ public final class MekanismUtils } /** - * Whether or not BuildCraft power should be used, taking into account both whether or not it is installed or if - * the player has configured the mod to do so. + * Whether or not BuildCraft power should be used, taking into account whether it is installed or another mod is + * providing its API. * @return if BuildCraft power should be used */ public static boolean useBuildCraft() { - return Mekanism.hooks.BuildCraftLoaded || Mekanism.forceBuildcraft; + return Mekanism.hooks.BuildCraftPowerLoaded; + } + + /** + * Whether or not IC2 power should be used, taking into account whether or not it is installed or another mod is + * providing its API. + * @return if IC2 power should be used + */ + public static boolean useIC2() + { + return Mekanism.hooks.IC2APILoaded; + } + + /** + * Whether or not RF power should be used, taking into account whether or not it is installed or another mod is + * providing its API. + * @return if RF power should be used + */ + public static boolean useRF() + { + return Mekanism.hooks.RedstoneFluxLoaded; } /** diff --git a/src/main/java/mekanism/generators/common/MekanismGenerators.java b/src/main/java/mekanism/generators/common/MekanismGenerators.java index d03d04e73..b19d06d8f 100644 --- a/src/main/java/mekanism/generators/common/MekanismGenerators.java +++ b/src/main/java/mekanism/generators/common/MekanismGenerators.java @@ -24,6 +24,8 @@ import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidRegistry; import buildcraft.api.fuels.IronEngineFuel; + +import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.Instance; @@ -61,17 +63,20 @@ public class MekanismGenerators implements IModule @EventHandler public void postInit(FMLPostInitializationEvent event) { - for(String s : IronEngineFuel.fuels.keySet()) + if(Loader.isModLoaded("BuildCraftAPI|fuels")) { - Fluid f = FluidRegistry.getFluid(s); - - if(!(f == null || GasRegistry.containsGas(s))) + for(String s : IronEngineFuel.fuels.keySet()) { - GasRegistry.register(new Gas(f)); - } - } + Fluid f = FluidRegistry.getFluid(s); - IronEngineFuel.addFuel("ethene", (float)(240*Mekanism.TO_BC), 40*FluidContainerRegistry.BUCKET_VOLUME); + if(!(f == null || GasRegistry.containsGas(s))) + { + GasRegistry.register(new Gas(f)); + } + } + + IronEngineFuel.addFuel("ethene", (float) (240 * Mekanism.TO_BC), 40 * FluidContainerRegistry.BUCKET_VOLUME); + } } @EventHandler diff --git a/src/main/java/mekanism/generators/common/block/BlockGenerator.java b/src/main/java/mekanism/generators/common/block/BlockGenerator.java index b9bba1b09..ecd24c201 100644 --- a/src/main/java/mekanism/generators/common/block/BlockGenerator.java +++ b/src/main/java/mekanism/generators/common/block/BlockGenerator.java @@ -39,6 +39,8 @@ import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; import buildcraft.api.tools.IToolWrench; + +import cpw.mods.fml.common.Loader; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -302,7 +304,7 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds if(entityplayer.getCurrentEquippedItem() != null) { - if(entityplayer.getCurrentEquippedItem().getItem() instanceof IToolWrench && !entityplayer.getCurrentEquippedItem().getUnlocalizedName().contains("omniwrench")) + if(Loader.isModLoaded("BuildCraftAPI|tools") && entityplayer.getCurrentEquippedItem().getItem() instanceof IToolWrench && !entityplayer.getCurrentEquippedItem().getUnlocalizedName().contains("omniwrench")) { if(entityplayer.isSneaking()) { diff --git a/src/main/java/mekanism/generators/common/item/ItemBlockGenerator.java b/src/main/java/mekanism/generators/common/item/ItemBlockGenerator.java index cca4b56a2..8db4b54ac 100644 --- a/src/main/java/mekanism/generators/common/item/ItemBlockGenerator.java +++ b/src/main/java/mekanism/generators/common/item/ItemBlockGenerator.java @@ -31,6 +31,10 @@ import net.minecraftforge.fluids.FluidStack; import org.lwjgl.input.Keyboard; import cofh.api.energy.IEnergyContainerItem; + +import cpw.mods.fml.common.Optional.Interface; +import cpw.mods.fml.common.Optional.InterfaceList; +import cpw.mods.fml.common.Optional.Method; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -45,6 +49,11 @@ import cpw.mods.fml.relauncher.SideOnly; * @author AidanBrady * */ + +@InterfaceList({ + @Interface(iface = "cofh.api.energy.IEnergyContainerItem", modid = "CoFHAPI|energy"), + @Interface(iface = "ic2.api.item.ISpecialElectricItem", modid = "IC2API") +}) public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, ISpecialElectricItem, ISustainedInventory, ISustainedTank, IEnergyContainerItem { public Block metaBlock; @@ -176,36 +185,42 @@ public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, ISp } @Override + @Method(modid = "IC2API") public boolean canProvideEnergy(ItemStack itemStack) { return canSend(itemStack); } @Override + @Method(modid = "IC2API") public Item getChargedItem(ItemStack itemStack) { return this; } @Override + @Method(modid = "IC2API") public Item getEmptyItem(ItemStack itemStack) { return this; } @Override + @Method(modid = "IC2API") public int getMaxCharge(ItemStack itemStack) { return 0; } @Override + @Method(modid = "IC2API") public int getTier(ItemStack itemStack) { return 4; } @Override + @Method(modid = "IC2API") public int getTransferLimit(ItemStack itemStack) { return 0; @@ -397,6 +412,7 @@ public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, ISp } @Override + @Method(modid = "IC2API") public IElectricItemManager getManager(ItemStack itemStack) { return IC2ItemManager.getManager(this); diff --git a/src/main/java/mekanism/generators/common/tile/TileEntityGenerator.java b/src/main/java/mekanism/generators/common/tile/TileEntityGenerator.java index 493edab28..9e062f9fe 100644 --- a/src/main/java/mekanism/generators/common/tile/TileEntityGenerator.java +++ b/src/main/java/mekanism/generators/common/tile/TileEntityGenerator.java @@ -17,13 +17,13 @@ import mekanism.common.util.MekanismUtils; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.AxisAlignedBB; import net.minecraftforge.common.util.ForgeDirection; -import buildcraft.api.power.IPowerReceptor; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import dan200.computercraft.api.peripheral.IComputerAccess; import dan200.computercraft.api.peripheral.IPeripheral; -public abstract class TileEntityGenerator extends TileEntityElectricBlock implements IPowerReceptor, IPeripheral, IActiveState, IHasSound, IRedstoneControl +public abstract class TileEntityGenerator extends TileEntityElectricBlock implements IPeripheral, IActiveState, IHasSound, IRedstoneControl { /** Output per tick this generator can transfer. */ public double output; @@ -44,7 +44,6 @@ public abstract class TileEntityGenerator extends TileEntityElectricBlock implem * Generator -- a block that produces energy. It has a certain amount of fuel it can store as well as an output rate. * @param name - full name of this generator * @param maxEnergy - how much energy this generator can store - * @param maxFuel - how much fuel this generator can store */ public TileEntityGenerator(String name, double maxEnergy, double out) {