Galacticraft and MFR API Optional-ing
This commit is contained in:
parent
8ddda5d0dc
commit
26463711de
8 changed files with 53 additions and 11 deletions
25
src/api/java/micdoodle8/mods/galacticraft/api/API-Usage.txt
Normal file
25
src/api/java/micdoodle8/mods/galacticraft/api/API-Usage.txt
Normal file
|
@ -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.
|
|
@ -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();
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
@API(apiVersion = "1.0", owner = "GalacticraftCore", provides = "Galacticraft API")
|
||||
package micdoodle8.mods.galacticraft.api;
|
||||
|
||||
import cpw.mods.fml.common.API;
|
||||
|
|
@ -14,5 +14,5 @@ package micdoodle8.mods.galacticraft.api.world;
|
|||
*/
|
||||
public interface ISolarLevel
|
||||
{
|
||||
public double getSolarEnergyMultiplier();
|
||||
public double getSolarEnergyMultiplier();
|
||||
}
|
|
@ -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();
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue