Updated IC2 API, fixed integration

This commit is contained in:
aidancbrady committed 2016-06-30 11:07:52 -04:00
1 parent b77ca6ff0c
commit 0b9a71162a
35 files changed
+146 -30

No files matched your search

Binary file not shown.
+20 -2
View File
@@ -1,5 +1,8 @@
package ic2.api;
import java.util.EnumSet;
import java.util.Set;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
@@ -36,6 +39,15 @@ public enum Direction {
*/
ZP;
private Direction() {
int side = ordinal() / 2;
int sign = getSign();
xOffset = side == 0 ? sign : 0;
yOffset = side == 1 ? sign : 0;
zOffset = side == 2 ? sign : 0;
}
public static Direction fromSideValue(int side) {
return directions[(side + 2) % 6];
}
@@ -83,7 +95,7 @@ public enum Direction {
/**
* Get the inverse of this direction (XN -> XP, XP -> XN, etc.)
*
*
* @return Inverse direction
*/
public Direction getInverse() {
@@ -92,7 +104,7 @@ public enum Direction {
/**
* Convert this direction to a Minecraft side value.
*
*
* @return Minecraft side value
*/
public int toSideValue() {
@@ -112,6 +124,12 @@ public enum Direction {
return ForgeDirection.getOrientation(toSideValue());
}
public final int xOffset;
public final int yOffset;
public final int zOffset;
public static final Direction[] directions = Direction.values();
public static final Set<Direction> noDirections = EnumSet.noneOf(Direction.class);
public static final Set<Direction> allDirections = EnumSet.allOf(Direction.class);
}
Binary file not shown.
+20 -18
View File
@@ -37,13 +37,16 @@ public abstract class CropCard {
/**
* Determine the mod id owning this crop.
*
* It's recommended to hard code this to your mod id.
* The owner serves as a name space. With every mod using a different owner, a mod only has to
* make sure it doesn't have conflicts with name() in itself.
* It's recommended to hard code this to your mod id as specified in the @Mod annotation.
* Do not use IC2's mod id here.
*
* @note changing name or owner will cause existing crops in users' worlds to disappear.
*
* @return Mod id.
*/
public String owner() {
public String owner() { // TODO: make abstract
return modId;
}
@@ -100,7 +103,7 @@ public abstract class CropCard {
* @param crop reference to ICropTile
* @return roots lengt use in isBlockBelow
*/
public int getrootslength(ICropTile crop) {
public int getrootslength(ICropTile crop) { // TODO: camel case
return 1;
}
@@ -126,7 +129,7 @@ public abstract class CropCard {
* @param n index of the requested stat
* @return The requested value of the stats
*/
public abstract int stat(int n);
public abstract int stat(int n); // TODO: change to fixed property object or builder with other attributes like tier
/**
* Additional attributes of the plant, also influencing breeding.
@@ -134,7 +137,7 @@ public abstract class CropCard {
*
* @return Attributes as an array of strings
*/
public abstract String[] attributes();
public abstract String[] attributes(); // TODO: default to none
/**
* Determine the max crop size.
@@ -212,7 +215,7 @@ public abstract class CropCard {
* @return 0-30
*/
public int weightInfluences(ICropTile crop, float humidity, float nutrients, float air) {
return (int) (humidity+nutrients+air);
return (int) (humidity + nutrients + air);
}
/**
@@ -247,7 +250,7 @@ public abstract class CropCard {
* @return need crop size for best output.
*/
public abstract int getOptimalHavestSize(ICropTile crop);
public abstract int getOptimalHavestSize(ICropTile crop); // TODO: default to maxSize
/**
* Check whether the crop can be harvested.
@@ -255,7 +258,7 @@ public abstract class CropCard {
* @param crop reference to ICropTile
* @return Whether the crop can be harvested in its current state.
*/
public abstract boolean canBeHarvested(ICropTile crop);
public abstract boolean canBeHarvested(ICropTile crop); // TODO: default to maxSize check
/**
* Base chance for dropping the plant's gains, specify values greater than 1 for multiple drops.
@@ -263,10 +266,8 @@ public abstract class CropCard {
*
* @return Chance to drop the gains
*/
public float dropGainChance() {
float base = 1F;
for (int i = 0; i < tier(); i++) {base*=0.95;}
return base;
public float dropGainChance() { // TODO: change to double
return (float) Math.pow(0.95, tier());
}
/**
@@ -284,20 +285,20 @@ public abstract class CropCard {
* @param crop reference to ICropTile
* @return Plant size after harvesting
*/
public byte getSizeAfterHarvest(ICropTile crop) {return 1;}
public byte getSizeAfterHarvest(ICropTile crop) {return 1;} // TODO: change to int
/**
* Called when the plant is leftclicked by a player.
* Called when the plant is left clicked by a player.
* Default action is picking the plant.
*
* Only called Serverside.
* Only called server side.
*
* @param crop reference to ICropTile
* @param player player leftclicked the crop
* @param player player left clicked the crop
* @return Whether the plant has changed
*/
public boolean leftclick(ICropTile crop, EntityPlayer player) {
public boolean leftclick(ICropTile crop, EntityPlayer player) { // TODO: camel case
return crop.pick(true);
}
@@ -398,7 +399,7 @@ public abstract class CropCard {
*/
public boolean isWeed(ICropTile crop) {
return crop.getSize() >= 2 &&
(crop == Crops.weed || crop.getGrowth() >= 24);
(crop.getCrop() == Crops.weed || crop.getGrowth() >= 24);
}
@@ -430,4 +431,5 @@ public abstract class CropCard {
protected IIcon textures[];
private final String modId; // TODO: make owner abstract, remove modId auto detection
// TODO: add a clean way to obtain world reference and position
}
Binary file not shown.
@@ -260,6 +260,15 @@ public interface ICropTile {
*/
public boolean isBlockBelow(Block block);
/**
* Check if a block is under the farmland containing the crop.
* Searches up to 2 blocks below the farmland or an air space, whichever appears first.
*
* @param oreDictionaryName blocks to search
* @return Whether the blocks were found
*/
public boolean isBlockBelow(String oreDictionaryName);
/**
* Generate plant seeds with the given parameters.
*
Binary file not shown.
Binary file not shown.
Binary file not shown.
+7
View File
@@ -1,5 +1,6 @@
package ic2.api.info;
import net.minecraft.potion.Potion;
import net.minecraft.util.DamageSource;
import cpw.mods.fml.common.Loader;
@@ -16,6 +17,12 @@ public class Info {
*/
public static DamageSource DMG_ELECTRIC, DMG_NUKE_EXPLOSION, DMG_RADIATION;
/**
* Potions used by IC2.
* Getting assigned in preload.
*/
public static Potion POTION_RADIATION;
public static boolean isIc2Available() {
if (ic2Available != null) return ic2Available;
Binary file not shown.
Binary file not shown.
+3 -1
View File
@@ -39,7 +39,9 @@ public interface IElectricItem {
/**
* Get the item's tier, lower tiers can't send energy to higher ones.
* Batteries are Tier 1, Energy Crystals are Tier 2, Lapotron Crystals are Tier 3.
*
* Batteries are Tier 1, Advanced Batteries are Tier 2, Energy Crystals are Tier 3, Lapotron
* Crystals are Tier 4.
*
* @return Item's tier
*/
Binary file not shown.
@@ -3,7 +3,7 @@ package ic2.api.item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
public interface IKineticWindRotor {
public interface IKineticRotor {
int getDiameter(ItemStack stack);
ResourceLocation getRotorRenderTexture(ItemStack stack);
@@ -13,4 +13,11 @@ public interface IKineticWindRotor {
int getMinWindStrength(ItemStack stack);
int getMaxWindStrength(ItemStack stack);
boolean isAcceptedType(ItemStack stack, GearboxType type);
public static enum GearboxType {
WATER,
WIND,
}
}
Binary file not shown.
Binary file not shown.
+23
View File
@@ -6,6 +6,9 @@ import net.minecraft.util.ResourceLocation;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
/**
* Interface used for Items that can be processed in the Turning Table
*/
public interface ILatheItem {
/**
@@ -44,4 +47,24 @@ public interface ILatheItem {
@SideOnly(Side.CLIENT)
ResourceLocation getTexture(ItemStack stack);
/**
* This is similar to the Block HarvestLevel. Requires a different tool for a different hardness
* for ex. the Iron Turning Blank has a Hardness of 2 (Like Iron Ore (Harvest Level)).
* In this case however it requires a Tool hardness of one above (3)
*/
int getHardness(ItemStack stack);
/**
* Interface used for Tools that can be used to modify {@link ILatheItem}
*/
public static interface ILatheTool extends ICustomDamageItem {
/**
* This is similar to the Tool HarvestLevel. Requires a different tool for a different hardness
* for ex. the Iron Turning Blank has a Hardness of 2 (Like Iron Ore (Harvest Level)).
* The tool requires a hardness of one level above (in this case 3)
*/
int getHardness(ItemStack stack);
}
}
Binary file not shown.
Binary file not shown.
@@ -178,7 +178,7 @@ public final class NetworkHelper {
*/
private static Object getInstance() {
try {
return Class.forName(getPackage() + ".core.IC2").getDeclaredField("network").get(null);
return Class.forName(getPackage() + ".core.util.SideGateway").getMethod("get").invoke(Class.forName(getPackage() + ".core.IC2").getDeclaredField("network").get(null));
} catch (Throwable e) {
throw new RuntimeException(e);
}
@@ -0,0 +1,39 @@
package ic2.api.recipe;
import java.util.Map;
import net.minecraftforge.fluids.Fluid;
public interface ILiquidHeatExchangerManager extends ILiquidAcceptManager {
/**
* Add a new fluid heatup/cooldown recipe.
*
* @param fluidName the fluid to heat up/cool down
* @param fluidOutput the fluid the above fluid turns into
* @param huPerMB the Thermal Energy difference in hU for the conversion of one mB fluid
*/
void addFluid(String fluidName, String fluidOutput, int huPerMB);
HeatExchangeProperty getHeatExchangeProperty(Fluid fluid);
Map<String, HeatExchangeProperty> getHeatExchangeProperties();
/**
* This returns an ILiquidAcceptManager that only accepts fluids, that can be heated up / cooled down, but not both.
* You can basically use this to check if the liquid resulting from this conversion can be reprocessed into the first one.
* @return Returns the SingleDirectionManager.
*/
ILiquidAcceptManager getSingleDirectionLiquidManager();
public static class HeatExchangeProperty {
public HeatExchangeProperty(Fluid outputFluid, int huPerMB) {
this.outputFluid = outputFluid;
this.huPerMB = huPerMB;
}
public final Fluid outputFluid;
public final int huPerMB;
}
}
Binary file not shown.
Binary file not shown.
@@ -25,8 +25,7 @@ public final class RecipeOutput {
RecipeOutput ro = (RecipeOutput) obj;
if (items.size() == ro.items.size() &&
(metadata == null && ro.metadata == null || metadata != null && ro.metadata != null) &&
metadata.equals(ro.metadata)) {
(metadata == null && ro.metadata == null || metadata != null && ro.metadata != null && metadata.equals(ro.metadata))) {
Iterator<ItemStack> itA = items.iterator();
Iterator<ItemStack> itB = ro.items.iterator();
Binary file not shown.
+12 -4
View File
@@ -3,7 +3,7 @@ package ic2.api.recipe;
/**
* General recipe registry.
*
*
* @author Richard
*/
public class Recipes {
@@ -23,12 +23,12 @@ public class Recipes {
/**
* Reference amplifier values:
*
*
* 5000: Scrap
* 45000: Scrapbox
*
*
* As Parameter for the Amplification Value you have to use the NBTTagCompound
*
*
* NBTTagCompound nbt = new NBTTagCompound();
* nbt.setInteger("amplification", aValue);
* matterAmplifier.addRecipe(yourStack, nbt);
@@ -57,4 +57,12 @@ public class Recipes {
public static ISemiFluidFuelManager semiFluidGenerator;
public static IFluidHeatManager FluidHeatGenerator;
/**
* Used by the Liquid Heat Exchanger to cool down liquids and determine the amount of hu generated for every mb.
*/
public static ILiquidHeatExchangerManager liquidCooldownManager;
/**
* Opposite of {@link #liquidCooldownManager}. This is for Liquids that can be heated up again.
*/
public static ILiquidHeatExchangerManager liquidHeatupManager;
}