diff --git a/src/api/java/micdoodle8/mods/galacticraft/api/API-Usage.txt b/src/api/java/micdoodle8/mods/galacticraft/api/API-Usage.txt new file mode 100644 index 000000000..eb544af31 --- /dev/null +++ b/src/api/java/micdoodle8/mods/galacticraft/api/API-Usage.txt @@ -0,0 +1,25 @@ +A note to anyone looking to use this API: +This API should now be fairly stable and usable. You can use prefabs and core API classes to create your own galaxies. + +Please avoid including interfaces where possible... + +If you are creating your own addon you should be relying on Galacticraft: + + Use the following steps to allow Galacticraft compilation: + 1. Download the dev-deobf (deobfuscated development) version of Galacticraft. + 2. Place the jar file somewhere in your workspace, remember the location. + 3. In eclipse, right click on your project, click properties->Java Build Path->Libraries->Add External Jars and select the dev jar. + 4. Galacticraft will now compile properly. + + You can also download the source from github "https://github.com/micdoodle8" and add it to your development source. + + Release your addon without any API classes or prefabs. Users with Galacticraft installed will experience no issues. + +If you are implementing a few classes for compatibility, or checking inheritance: + + Try to use java reflection where performance is not mandatory. Google is your friend for learning reflection. + + Create multiple versions of a class implementing one of my interfaces. Check if Galacticraft is installed and invoke the appropriate class. + Crashes will only occur if you reference a class with a missing interface, so call the correct one and you won't have issues. + + If you must include interfaces, only include the ones you need and check for updates. \ No newline at end of file diff --git a/src/main/java/micdoodle8/mods/galacticraft/api/entity/IEntityBreathable.java b/src/api/java/micdoodle8/mods/galacticraft/api/entity/IEntityBreathable.java similarity index 54% rename from src/main/java/micdoodle8/mods/galacticraft/api/entity/IEntityBreathable.java rename to src/api/java/micdoodle8/mods/galacticraft/api/entity/IEntityBreathable.java index 618c4529a..21072cf81 100644 --- a/src/main/java/micdoodle8/mods/galacticraft/api/entity/IEntityBreathable.java +++ b/src/api/java/micdoodle8/mods/galacticraft/api/entity/IEntityBreathable.java @@ -5,9 +5,9 @@ package micdoodle8.mods.galacticraft.api.entity; */ public interface IEntityBreathable { - /** - * Whether or not this entity can currently breathe without oxygen in it's - * vicinity - */ - public boolean canBreath(); + /** + * Whether or not this entity can currently breathe without oxygen in it's + * vicinity + */ + public boolean canBreath(); } diff --git a/src/api/java/micdoodle8/mods/galacticraft/api/package-info.java b/src/api/java/micdoodle8/mods/galacticraft/api/package-info.java new file mode 100644 index 000000000..55ce1bae8 --- /dev/null +++ b/src/api/java/micdoodle8/mods/galacticraft/api/package-info.java @@ -0,0 +1,5 @@ +@API(apiVersion = "1.0", owner = "GalacticraftCore", provides = "Galacticraft API") +package micdoodle8.mods.galacticraft.api; + +import cpw.mods.fml.common.API; + diff --git a/src/main/java/micdoodle8/mods/galacticraft/api/world/ISolarLevel.java b/src/api/java/micdoodle8/mods/galacticraft/api/world/ISolarLevel.java similarity index 91% rename from src/main/java/micdoodle8/mods/galacticraft/api/world/ISolarLevel.java rename to src/api/java/micdoodle8/mods/galacticraft/api/world/ISolarLevel.java index e7314a2ad..9ec097988 100644 --- a/src/main/java/micdoodle8/mods/galacticraft/api/world/ISolarLevel.java +++ b/src/api/java/micdoodle8/mods/galacticraft/api/world/ISolarLevel.java @@ -14,5 +14,5 @@ package micdoodle8.mods.galacticraft.api.world; */ public interface ISolarLevel { - public double getSolarEnergyMultiplier(); + public double getSolarEnergyMultiplier(); } diff --git a/src/main/java/powercrystals/minefactoryreloaded/api/IDeepStorageUnit.java b/src/api/java/powercrystals/minefactoryreloaded/api/IDeepStorageUnit.java similarity index 65% rename from src/main/java/powercrystals/minefactoryreloaded/api/IDeepStorageUnit.java rename to src/api/java/powercrystals/minefactoryreloaded/api/IDeepStorageUnit.java index 2e34693bb..bc84d73cb 100644 --- a/src/main/java/powercrystals/minefactoryreloaded/api/IDeepStorageUnit.java +++ b/src/api/java/powercrystals/minefactoryreloaded/api/IDeepStorageUnit.java @@ -5,22 +5,25 @@ import net.minecraft.item.ItemStack; public interface IDeepStorageUnit { /** - * @return A populated ItemStack with stackSize for the full amount of materials in the DSU. May have a stackSize > getMaxStackSize(). + * @return A populated ItemStack with stackSize for the full amount of materials in the DSU. + * May have a stackSize > getMaxStackSize(). May have a stackSize of 0 (indicating locked contents). */ ItemStack getStoredItemType(); /** - * Sets the total amount of the item currently being stored, or zero if it wants to remove all items. + * Sets the total amount of the item currently being stored, or zero if all items are to be removed. */ void setStoredItemCount(int amount); /** - * Sets the type of the stored item and initializes the number of stored items to amount. Will overwrite any existing stored items. + * Sets the type of the stored item and initializes the number of stored items to amount. + * Will overwrite any existing stored items. */ void setStoredItemType(ItemStack type, int amount); /** * @return The maximum number of items the DSU can hold. + * May change based on the current type stored. */ int getMaxStoredCount(); -} \ No newline at end of file +} diff --git a/src/main/java/mekanism/common/entity/EntityRobit.java b/src/main/java/mekanism/common/entity/EntityRobit.java index 50f7be9ea..0e6788ce4 100644 --- a/src/main/java/mekanism/common/entity/EntityRobit.java +++ b/src/main/java/mekanism/common/entity/EntityRobit.java @@ -41,8 +41,12 @@ import net.minecraft.util.MathHelper; import net.minecraft.world.World; import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.common.util.Constants; +import cpw.mods.fml.common.Optional.Interface; +import cpw.mods.fml.common.Optional.Method; + import cofh.api.energy.IEnergyContainerItem; +@Interface(iface = "micdoodle8.mods.galacticraft.api.entity.IEntityBreathable", modid = "Galacticrat API") public class EntityRobit extends EntityCreature implements IInventory, ISustainedInventory, IEntityBreathable { public double MAX_ELECTRICITY = 100000; diff --git a/src/main/java/mekanism/common/tile/TileEntityBin.java b/src/main/java/mekanism/common/tile/TileEntityBin.java index adf5127e8..f79f0898a 100644 --- a/src/main/java/mekanism/common/tile/TileEntityBin.java +++ b/src/main/java/mekanism/common/tile/TileEntityBin.java @@ -24,8 +24,11 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; +import cpw.mods.fml.common.Optional.Interface; + import powercrystals.minefactoryreloaded.api.IDeepStorageUnit; +@Interface(iface = "powercrystals.minefactoryreloaded.api.IDeepStorageUnit", modid = "MineFactoryReloaded") public class TileEntityBin extends TileEntityBasicBlock implements ISidedInventory, IActiveState, IDeepStorageUnit, IConfigurable { public boolean isActive; diff --git a/src/main/java/mekanism/generators/common/tile/TileEntitySolarGenerator.java b/src/main/java/mekanism/generators/common/tile/TileEntitySolarGenerator.java index 651e78e6c..1a9bc0065 100644 --- a/src/main/java/mekanism/generators/common/tile/TileEntitySolarGenerator.java +++ b/src/main/java/mekanism/generators/common/tile/TileEntitySolarGenerator.java @@ -13,6 +13,8 @@ import micdoodle8.mods.galacticraft.api.world.ISolarLevel; import net.minecraft.item.ItemStack; import net.minecraft.world.biome.BiomeGenDesert; import net.minecraftforge.common.util.ForgeDirection; +import cpw.mods.fml.common.ModAPIManager; + import dan200.computercraft.api.lua.ILuaContext; import dan200.computercraft.api.peripheral.IComputerAccess; @@ -124,7 +126,7 @@ public class TileEntitySolarGenerator extends TileEntityGenerator { ret = GENERATION_RATE; - if(worldObj.provider instanceof ISolarLevel) + if(ModAPIManager.INSTANCE.hasAPI("Galacticraft API") && worldObj.provider instanceof ISolarLevel) { ret *= ((ISolarLevel)worldObj.provider).getSolarEnergyMultiplier(); }