Update lots of APIs, most notably BC and an actual 1.7 version of CC

Conflicts:
	build.properties
	src/api/java/buildcraft/api/core/BlockIndex.java
	src/api/java/buildcraft/api/core/BuildCraftAPI.java
	src/api/java/buildcraft/api/fuels/IFuel.java
	src/api/java/buildcraft/api/mj/BatteryObject.java
	src/api/java/buildcraft/api/mj/IBatteryIOObject.java
	src/api/java/buildcraft/api/mj/IBatteryObject.java
	src/api/java/buildcraft/api/mj/IOMode.java
	src/api/java/buildcraft/api/mj/MjAPI.java
	src/api/java/buildcraft/api/mj/MjBattery.java
	src/api/java/buildcraft/api/power/PowerHandler.java
	src/api/java/buildcraft/api/recipes/CraftingResult.java
	src/api/java/buildcraft/api/recipes/IAssemblyRecipeManager.java
	src/api/java/buildcraft/api/recipes/IFlexibleRecipe.java
	src/api/java/buildcraft/api/recipes/IRefineryRecipeManager.java
	src/api/java/buildcraft/api/transport/IPipe.java
	src/main/java/mekanism/common/CommonProxy.java
	src/main/java/mekanism/common/EnergyNetwork.java
	src/main/java/mekanism/common/FuelHandler.java
	src/main/java/mekanism/common/Mekanism.java
	src/main/java/mekanism/common/base/IAdvancedBoundingBlock.java
	src/main/java/mekanism/common/multipart/MultipartMekanism.java
	src/main/java/mekanism/common/multipart/PartLogisticalTransporter.java
	src/main/java/mekanism/common/multipart/PartUniversalCable.java
	src/main/java/mekanism/common/network/PacketConfigSync.java
	src/main/java/mekanism/common/tile/TileEntityAdvancedBoundingBlock.java
	src/main/java/mekanism/common/tile/TileEntityElectricBlock.java
	src/main/java/mekanism/common/util/CableUtils.java
	src/main/java/mekanism/common/util/MekanismUtils.java
	src/main/java/mekanism/common/util/TransporterUtils.java
	src/main/java/mekanism/generators/common/MekanismGenerators.java
	src/main/java/mekanism/generators/common/tile/TileEntityBioGenerator.java
	src/main/java/mekanism/generators/common/tile/TileEntityGasGenerator.java
	src/main/java/mekanism/generators/common/tile/TileEntityGenerator.java
	src/main/java/mekanism/generators/common/tile/TileEntityHeatGenerator.java
	src/main/java/mekanism/generators/common/tile/TileEntitySolarGenerator.java
	src/main/java/mekanism/generators/common/tile/TileEntityWindTurbine.java
This commit is contained in:
Ben Spiers 2014-11-10 21:51:37 +00:00
parent 21dc5253a4
commit b31aa92844
99 changed files with 1628 additions and 1939 deletions

View file

@ -1,6 +1,6 @@
minecraft_version=1.7.10
forge_version=10.13.0.1208
FMP_version=1.1.0.297
CCLIB_version=1.1.1.93
NEI_version=1.0.2.15
FMP_version=1.1.0.314
CCLIB_version=1.1.1.106
NEI_version=1.0.3.67
mod_version=8.0.0

View file

@ -9,12 +9,14 @@
package buildcraft.api.core;
import java.lang.reflect.Method;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public final class BCLog {
public static final Logger logger = Logger.getLogger("Buildcraft");
public static final Logger logger = LogManager.getLogger("BuildCraft");
/**
* Deactivate constructor
@ -23,11 +25,9 @@ public final class BCLog {
}
public static void initLog() {
// TODO: check if the code below is still useful and remove otherwise.
//logger.setParent(FMLLog.getLogger());
logger.info("Starting BuildCraft " + getVersion());
logger.info("Copyright (c) SpaceToad, 2011");
logger.info("Copyright (c) SpaceToad, 2011-2014");
logger.info("http://www.mod-buildcraft.com");
}
@ -39,12 +39,12 @@ public final class BCLog {
msg.append(", ").append(stackTrace[0]);
}
logger.log(Level.SEVERE, msg.toString());
logger.log(Level.ERROR, msg.toString());
if (classFile != null) {
msg = new StringBuilder(mod);
msg.append(" API error: ").append(classFile.getSimpleName()).append(" is loaded from ").append(classFile.getProtectionDomain().getCodeSource().getLocation());
logger.log(Level.SEVERE, msg.toString());
logger.log(Level.ERROR, msg.toString());
}
}

View file

@ -0,0 +1,115 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.api.core;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
/**
* This class is a comparable container for block positions. TODO: should this be merged with position?
*/
public class BlockIndex implements Comparable<BlockIndex> {
public int x;
public int y;
public int z;
public BlockIndex() {
}
/**
* Creates an index for a block located on x, y. z
*/
public BlockIndex(int x, int y, int z) {
this.x = x;
this.y = y;
this.z = z;
}
public BlockIndex(NBTTagCompound c) {
this.x = c.getInteger("i");
this.y = c.getInteger("j");
this.z = c.getInteger("k");
}
public BlockIndex(Entity entity) {
x = (int) Math.floor(entity.posX);
y = (int) Math.floor(entity.posY);
z = (int) Math.floor(entity.posZ);
}
public BlockIndex(TileEntity entity) {
this(entity.xCoord, entity.yCoord, entity.zCoord);
}
/**
* Provides a deterministic and complete ordering of block positions.
*/
@Override
public int compareTo(BlockIndex o) {
if (o.x < x) {
return 1;
} else if (o.x > x) {
return -1;
} else if (o.z < z) {
return 1;
} else if (o.z > z) {
return -1;
} else if (o.y < y) {
return 1;
} else if (o.y > y) {
return -1;
} else {
return 0;
}
}
public void writeTo(NBTTagCompound c) {
c.setInteger("i", x);
c.setInteger("j", y);
c.setInteger("k", z);
}
public Block getBlock(World world) {
return world.getBlock(x, y, z);
}
@Override
public String toString() {
return "{" + x + ", " + y + ", " + z + "}";
}
@Override
public boolean equals(Object obj) {
if (obj instanceof BlockIndex) {
BlockIndex b = (BlockIndex) obj;
return b.x == x && b.y == y && b.z == z;
}
return super.equals(obj);
}
@Override
public int hashCode() {
return (x * 37 + y) * 37 + z;
}
public boolean nextTo(BlockIndex blockIndex) {
return (Math.abs(blockIndex.x - x) <= 1 && blockIndex.y == y && blockIndex.z == z)
|| (blockIndex.x == x && Math.abs(blockIndex.y - y) <= 1 && blockIndex.z == z)
|| (blockIndex.x == x && blockIndex.y == y && Math.abs(blockIndex.z - z) <= 1);
}
}

View file

@ -12,7 +12,7 @@ import java.util.HashSet;
import java.util.Set;
import net.minecraft.block.Block;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public final class BuildCraftAPI {
@ -20,18 +20,23 @@ public final class BuildCraftAPI {
public static final Set<Block> softBlocks = new HashSet<Block>();
public static IWorldProperty isSoftProperty;
public static IWorldProperty isWoodProperty;
public static IWorldProperty isLeavesProperty;
public static IWorldProperty[] isOreProperty;
public static IWorldProperty isHarvestableProperty;
public static IWorldProperty isFarmlandProperty;
public static IWorldProperty isDirtProperty;
public static IWorldProperty isShoveled;
public static IWorldProperty isFluidSource;
/**
* Deactivate constructor
*/
private BuildCraftAPI() {
}
public static boolean isSoftBlock(IBlockAccess world, int x, int y, int z) {
return isSoftBlock(world.getBlock(x, y, z), world, x, y, z);
public static boolean isSoftBlock(World world, int x, int y, int z) {
return isSoftProperty.get(world, x, y, z);
}
public static boolean isSoftBlock(Block block, IBlockAccess world, int x, int y, int z) {
return block == null || BuildCraftAPI.softBlocks.contains(block) || block.isReplaceable(world, x, y, z) || block.isAir(world, x, y, z);
}
}

View file

@ -0,0 +1,207 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.api.core;
import java.util.Locale;
import java.util.Random;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon;
import net.minecraft.util.StatCollector;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public enum EnumColor {
BLACK,
RED,
GREEN,
BROWN,
BLUE,
PURPLE,
CYAN,
LIGHT_GRAY,
GRAY,
PINK,
LIME,
YELLOW,
LIGHT_BLUE,
MAGENTA,
ORANGE,
WHITE;
public static final EnumColor[] VALUES = values();
public static final String[] DYES = {
"dyeBlack",
"dyeRed",
"dyeGreen",
"dyeBrown",
"dyeBlue",
"dyePurple",
"dyeCyan",
"dyeLightGray",
"dyeGray",
"dyePink",
"dyeLime",
"dyeYellow",
"dyeLightBlue",
"dyeMagenta",
"dyeOrange",
"dyeWhite"};
public static final String[] NAMES = {
"Black",
"Red",
"Green",
"Brown",
"Blue",
"Purple",
"Cyan",
"LightGray",
"Gray",
"Pink",
"Lime",
"Yellow",
"LightBlue",
"Magenta",
"Orange",
"White"};
public static final int[] DARK_HEX = {
0x2D2D2D,
0xA33835,
0x394C1E,
0x5C3A24,
0x3441A2,
0x843FBF,
0x36809E,
0x888888,
0x444444,
0xE585A0,
0x3FAA36,
0xCFC231,
0x7F9AD1,
0xFF64FF,
0xFF6A00,
0xFFFFFF};
public static final int[] LIGHT_HEX = {
0x181414,
0xBE2B27,
0x007F0E,
0x89502D,
0x253193,
0x7e34bf,
0x299799,
0xa0a7a7,
0x7A7A7A,
0xD97199,
0x39D52E,
0xFFD91C,
0x66AAFF,
0xD943C6,
0xEA7835,
0xe4e4e4};
@SideOnly(Side.CLIENT)
private static IIcon[] brushIcons;
public int getDarkHex() {
return DARK_HEX[ordinal()];
}
public int getLightHex() {
return LIGHT_HEX[ordinal()];
}
public static EnumColor fromId(int id) {
if (id < 0 || id >= VALUES.length) {
return WHITE;
}
return VALUES[id];
}
public static EnumColor fromDye(String dyeTag) {
for (int id = 0; id < DYES.length; id++) {
if (DYES[id].equals(dyeTag)) {
return VALUES[id];
}
}
return null;
}
public static EnumColor fromName(String name) {
for (int id = 0; id < NAMES.length; id++) {
if (NAMES[id].equals(name)) {
return VALUES[id];
}
}
return null;
}
public static EnumColor getRand() {
return VALUES[new Random().nextInt(VALUES.length)];
}
public EnumColor getNext() {
EnumColor next = VALUES[(ordinal() + 1) % VALUES.length];
return next;
}
public EnumColor getPrevious() {
EnumColor previous = VALUES[(ordinal() + VALUES.length - 1) % VALUES.length];
return previous;
}
public EnumColor inverse() {
return EnumColor.VALUES[15 - ordinal()];
}
public String getTag() {
return "color." + name().replace("_", ".").toLowerCase(Locale.ENGLISH);
}
public String getBasicTag() {
return name().replace("_", ".").toLowerCase(Locale.ENGLISH);
}
public String getName() {
return NAMES[ordinal()];
}
public String getLocalizedName() {
return StatCollector.translateToLocal(getTag());
}
public String getDye() {
return DYES[ordinal()];
}
@Override
public String toString() {
String s = name().replace("_", " ");
String[] words = s.split(" ");
StringBuilder b = new StringBuilder();
for (String word : words) {
b.append(word.charAt(0)).append(word.substring(1).toLowerCase(Locale.ENGLISH)).append(" ");
}
return b.toString().trim();
}
@SideOnly(Side.CLIENT)
public static void registerIcons(IIconRegister iconRegister) {
brushIcons = new IIcon[16];
for (EnumColor c : values()) {
brushIcons[c.ordinal()] = iconRegister.registerIcon("buildcraft:triggers/color_"
+ c.name().toLowerCase(Locale.ENGLISH));
}
}
@SideOnly(Side.CLIENT)
public IIcon getIcon() {
return brushIcons [ordinal()];
}
}

View file

@ -8,14 +8,12 @@
*/
package buildcraft.api.core;
public interface IBox {
public interface IBox extends IZone {
IBox expand(int amount);
IBox contract(int amount);
boolean contains(double x, double y, double z);
Position pMin();
Position pMax();

View file

@ -0,0 +1,21 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.api.core;
import java.util.Random;
public interface IZone {
double distanceTo(BlockIndex index);
boolean contains(double x, double y, double z);
BlockIndex getRandomBlockIndex(Random rand);
}

View file

@ -64,6 +64,13 @@ public class Position {
orientation = ForgeDirection.UNKNOWN;
}
public Position(BlockIndex index) {
x = index.x;
y = index.y;
z = index.z;
orientation = ForgeDirection.UNKNOWN;
}
public void moveRight(double step) {
switch (orientation) {
case SOUTH:
@ -171,5 +178,4 @@ public class Position {
return !(sqrDis > f * f);
}
}

View file

@ -8,49 +8,127 @@
*/
package buildcraft.api.core;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack;
/**
* This class is used whenever stacks needs to be stored as keys.
*/
public class StackKey {
public final class StackKey {
public final ItemStack stack;
public final FluidStack fluidStack;
public StackKey(FluidStack fluidStack) {
this(null, fluidStack);
}
public StackKey(ItemStack stack) {
this(stack, null);
}
public StackKey(ItemStack stack, FluidStack fluidStack) {
this.stack = stack;
this.fluidStack = fluidStack;
}
public static StackKey stack(Item item, int amount, int damage) {
return new StackKey(new ItemStack(item, amount, damage));
}
public static StackKey stack(Block block, int amount, int damage) {
return new StackKey(new ItemStack(block, amount, damage));
}
public static StackKey stack(Item item) {
return new StackKey(new ItemStack(item, 1, 0));
}
public static StackKey stack(Block block) {
return new StackKey(new ItemStack(block, 1, 0));
}
public static StackKey stack(ItemStack itemStack) {
return new StackKey(itemStack);
}
public static StackKey fluid(Fluid fluid, int amount) {
return new StackKey(new FluidStack(fluid, amount));
}
public static StackKey fluid(Fluid fluid) {
return new StackKey(new FluidStack(fluid, FluidContainerRegistry.BUCKET_VOLUME));
}
public static StackKey fluid(FluidStack fluidStack) {
return new StackKey(fluidStack);
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || o.getClass() != StackKey.class) {
return false;
}
StackKey k = (StackKey) o;
if ((stack == null ^ k.stack == null) || (fluidStack == null ^ k.fluidStack == null)) {
return false;
}
if (stack != null) {
if (stack.getItem() != k.stack.getItem() ||
stack.getHasSubtypes() && stack.getItemDamage() != k.stack.getItemDamage() ||
!objectsEqual(stack.getTagCompound(), k.stack.getTagCompound())) {
return false;
}
}
if (fluidStack != null) {
if (fluidStack.fluidID != k.fluidStack.fluidID ||
fluidStack.amount != k.fluidStack.amount ||
!objectsEqual(fluidStack.tag, k.fluidStack.tag)) {
return false;
}
}
return true;
}
@Override
public int hashCode() {
int hash = 5;
hash = 67 * hash + stack.getItem().hashCode();
hash = 67 * hash + stack.getItemDamage();
if (stack.stackTagCompound != null) {
hash = 67 * hash + stack.stackTagCompound.hashCode();
int result = 7;
if (stack != null) {
result = 31 * result + stack.getItem().hashCode();
result = 31 * result + stack.getItemDamage();
result = 31 * result + objectHashCode(stack.getTagCompound());
}
return hash;
result = 31 * result + 7;
if (fluidStack != null) {
result = 31 * result + fluidStack.fluidID;
result = 31 * result + fluidStack.amount;
result = 31 * result + objectHashCode(fluidStack.tag);
}
return result;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
} else if (getClass() != obj.getClass()) {
return false;
}
final StackKey other = (StackKey) obj;
if (stack.getItem() != other.stack.getItem()) {
return false;
} else if (stack.getHasSubtypes() && stack.getItemDamage() != other.stack.getItemDamage()) {
private boolean objectsEqual(Object o1, Object o2) {
if (o1 == null && o2 == null) {
return true;
} else if (o1 == null || o2 == null) {
return false;
} else {
return !(stack.stackTagCompound != null && !stack.stackTagCompound.equals(other.stack.stackTagCompound));
return o1.equals(o2);
}
}
private int objectHashCode(Object o) {
return o != null ? o.hashCode() : 0;
}
public StackKey copy() {
return new StackKey(stack != null ? stack.copy() : null,
fluidStack != null ? fluidStack.copy() : null);
}
}

View file

@ -0,0 +1,108 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.api.core;
import net.minecraft.entity.Entity;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
/**
* This class is a comparable container for block positions. TODO: should this be merged with position?
*/
public class WorldBlockIndex implements Comparable<WorldBlockIndex> {
public int x;
public int y;
public int z;
public int dimension;
public WorldBlockIndex() {
}
/**
* Creates an index for a block located on x, y. z
*/
public WorldBlockIndex(World world, int x, int y, int z) {
dimension = world.provider.dimensionId;
this.x = x;
this.y = y;
this.z = z;
}
public WorldBlockIndex(NBTTagCompound c) {
dimension = c.getInteger("dimension");
x = c.getInteger("x");
y = c.getInteger("y");
z = c.getInteger("z");
}
public WorldBlockIndex(Entity entity) {
dimension = entity.worldObj.provider.dimensionId;
x = (int) Math.floor(entity.posX);
y = (int) Math.floor(entity.posY);
z = (int) Math.floor(entity.posZ);
}
/**
* Provides a deterministic and complete ordering of block positions.
*/
@Override
public int compareTo(WorldBlockIndex o) {
if (o.dimension < dimension) {
return 1;
} else if (o.dimension > dimension) {
return -1;
} else if (o.x < x) {
return 1;
} else if (o.x > x) {
return -1;
} else if (o.z < z) {
return 1;
} else if (o.z > z) {
return -1;
} else if (o.y < y) {
return 1;
} else if (o.y > y) {
return -1;
} else {
return 0;
}
}
public void writeTo(NBTTagCompound c) {
c.setInteger("dimension", dimension);
c.setInteger("x", x);
c.setInteger("y", y);
c.setInteger("z", z);
}
@Override
public String toString() {
return "{" + dimension + ":" + x + ", " + y + ", " + z + "}";
}
@Override
public boolean equals(Object obj) {
if (obj instanceof WorldBlockIndex) {
WorldBlockIndex b = (WorldBlockIndex) obj;
return b.dimension == dimension && b.x == x && b.y == y && b.z == z;
}
return super.equals(obj);
}
@Override
public int hashCode() {
return (dimension * 37 + (x * 37 + y)) * 37 + z;
}
}

View file

@ -6,6 +6,12 @@
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
@API(apiVersion = "1.1", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|power")
package buildcraft.api.power;
import cpw.mods.fml.common.API;
package buildcraft.api.fuels;
public final class BuildcraftFuelRegistry {
public static IFuelManager fuel;
public static ICoolantManager coolant;
private BuildcraftFuelRegistry() {
}
}

View file

@ -6,12 +6,12 @@
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.api.mj;
package buildcraft.api.fuels;
public interface IBatteryIOObject extends IBatteryObject {
IOMode mode();
import net.minecraftforge.fluids.Fluid;
boolean canSend();
public interface ICoolant {
Fluid getFluid();
boolean canReceive();
float getDegreesCoolingPerMB(float heat);
}

View file

@ -0,0 +1,33 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.api.fuels;
import java.util.Collection;
import net.minecraftforge.fluids.Fluid;
import buildcraft.api.core.StackKey;
public interface ICoolantManager {
ICoolant addCoolant(ICoolant coolant);
ICoolant addCoolant(Fluid fluid, float degreesCoolingPerMB);
ISolidCoolant addSolidCoolant(ISolidCoolant solidCoolant);
ISolidCoolant addSolidCoolant(StackKey solid, StackKey liquid, float multiplier);
Collection<ICoolant> getCoolants();
Collection<ISolidCoolant> getSolidCoolants();
ICoolant getCoolant(Fluid fluid);
ISolidCoolant getSolidCoolant(StackKey solid);
}

View file

@ -6,8 +6,14 @@
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.api.mj;
package buildcraft.api.fuels;
public interface IBatteryProvider {
IBatteryObject getMjBattery(String kind);
}
import net.minecraftforge.fluids.Fluid;
public interface IFuel {
Fluid getFluid();
int getTotalBurningTime();
int getPowerPerCycle();
}

View file

@ -6,15 +6,18 @@
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.api.mj;
package buildcraft.api.fuels;
public enum IOMode {
Both(true, true), Receive(true, false), Send(false, true), None(false, false);
import java.util.Collection;
public final boolean canReceive, canSend;
import net.minecraftforge.fluids.Fluid;
IOMode(boolean canReceive, boolean canSend) {
this.canReceive = canReceive;
this.canSend = canSend;
}
public interface IFuelManager {
IFuel addFuel(IFuel fuel);
IFuel addFuel(Fluid fluid, int powerPerCycle, int totalBurningTime);
Collection<IFuel> getFuels();
IFuel getFuel(Fluid fluid);
}

View file

@ -0,0 +1,16 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.api.fuels;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
public interface ISolidCoolant {
FluidStack getFluidFromSolidCoolant(ItemStack stack);
}

View file

@ -1,92 +0,0 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.api.fuels;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import buildcraft.api.core.StackKey;
public final class IronEngineCoolant {
public static Map<String, Coolant> liquidCoolants = new HashMap<String, Coolant>();
public static Map<StackKey, FluidStack> solidCoolants = new HashMap<StackKey, FluidStack>();
private IronEngineCoolant() {
}
public static FluidStack getFluidCoolant(ItemStack stack) {
return solidCoolants.get(new StackKey(stack));
}
public static Coolant getCoolant(ItemStack stack) {
return getCoolant(getFluidCoolant(stack));
}
public static Coolant getCoolant(FluidStack fluidStack) {
return fluidStack != null && fluidStack.getFluid() != null ? liquidCoolants.get(fluidStack.getFluid().getName()) : null;
}
public interface Coolant {
float getDegreesCoolingPerMB(float currentHeat);
}
public static void addCoolant(final Fluid fluid, final float degreesCoolingPerMB) {
if (fluid != null) {
liquidCoolants.put(fluid.getName(), new Coolant() {
@Override
public float getDegreesCoolingPerMB(float currentHeat) {
return degreesCoolingPerMB;
}
});
}
}
/**
* Adds a solid coolant like Ice Blocks. The FluidStack must contain a registered
* Coolant Fluid or nothing will happen. You do not need to call this for
* Fluid Containers.
*
* @param stack
* @param coolant
*/
public static void addCoolant(final ItemStack stack, final FluidStack coolant) {
if (stack != null && stack.getItem() != null && coolant != null) {
solidCoolants.put(new StackKey(stack), coolant);
}
}
/**
* Adds a solid coolant like Ice Blocks. The FluidStack must contain a
* registered Coolant Fluid or nothing will happen. You do not need to call
* this for Fluid Containers.
*
* @param item
* @param coolant
*/
public static void addCoolant(final Item item, final int metadata, final FluidStack coolant) {
addCoolant(new ItemStack(item, 1, metadata), coolant);
}
public static void addCoolant(final Block block, final int metadata, final FluidStack coolant) {
addCoolant(new ItemStack(block, 1, metadata), coolant);
}
public static boolean isCoolant(Fluid fluid) {
return liquidCoolants.containsKey(fluid.getName());
}
}

View file

@ -1,52 +0,0 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.api.fuels;
import java.util.HashMap;
import java.util.Map;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
public final class IronEngineFuel {
public static Map<String, Fuel> fuels = new HashMap<String, Fuel>();
private IronEngineFuel() {
}
public static Fuel getFuelForFluid(Fluid liquid) {
return liquid == null ? null : fuels.get(liquid.getName());
}
public static final class Fuel {
public final Fluid liquid;
public final float powerPerCycle;
public final int totalBurningTime;
private Fuel(String fluidName, float powerPerCycle, int totalBurningTime) {
this(FluidRegistry.getFluid(fluidName), powerPerCycle, totalBurningTime);
}
private Fuel(Fluid liquid, float powerPerCycle, int totalBurningTime) {
this.liquid = liquid;
this.powerPerCycle = powerPerCycle;
this.totalBurningTime = totalBurningTime;
}
}
public static void addFuel(Fluid fluid, float powerPerCycle, int totalBurningTime) {
fuels.put(fluid.getName(), new Fuel(fluid, powerPerCycle, totalBurningTime));
}
public static void addFuel(String fluidName, float powerPerCycle, int totalBurningTime) {
fuels.put(fluidName, new Fuel(fluidName, powerPerCycle, totalBurningTime));
}
}

View file

@ -6,6 +6,6 @@
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
@API(apiVersion = "1.0", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|fuels")
@API(apiVersion = "2.0", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|fuels")
package buildcraft.api.fuels;
import cpw.mods.fml.common.API;

View file

@ -6,10 +6,17 @@
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.api.mj;
package buildcraft.api.gates;
import net.minecraftforge.common.util.ForgeDirection;
public interface ISidedBatteryProvider {
IBatteryObject getMjBattery(String kind, ForgeDirection direction);
import buildcraft.api.transport.IPipe;
public interface IGate {
@Deprecated
void setPulsing(boolean pulse);
ForgeDirection getSide();
IPipe getPipe();
}

View file

@ -1,200 +0,0 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.api.mj;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.util.logging.Level;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.core.BCLog;
import buildcraft.api.core.JavaTools;
/**
* A battery object is a wrapper around a battery field in an object. This
* battery field is of type double, and is the only piece of data specific to
* this object. Others are class-wide.
*/
public class BatteryObject implements IBatteryIOObject {
protected Field energyStored;
protected Object obj;
protected MjBattery batteryData;
/**
* {@inheritDoc}
*/
@Override
public double getEnergyRequested() {
if (!batteryData.mode().canReceive) {
return 0;
}
try {
return JavaTools.bounds(batteryData.maxCapacity() - energyStored.getDouble(obj),
batteryData.minimumConsumption(), batteryData.maxReceivedPerCycle());
} catch (IllegalAccessException e) {
BCLog.logger.log(Level.WARNING, "can't get energy requested", e);
}
return 0;
}
/**
* {@inheritDoc}
*/
@Override
public double addEnergy(double mj) {
return addEnergy(mj, false);
}
/**
* {@inheritDoc}
*/
@Override
public double addEnergy(double mj, boolean ignoreCycleLimit) {
if (!batteryData.mode().canReceive) {
return 0;
}
try {
double contained = energyStored.getDouble(obj);
double maxAccepted = batteryData.maxCapacity() - contained + batteryData.minimumConsumption();
if (!ignoreCycleLimit && maxAccepted > batteryData.maxReceivedPerCycle()) {
maxAccepted = batteryData.maxReceivedPerCycle();
}
double used = Math.min(maxAccepted, mj);
if (used > 0) {
energyStored.setDouble(obj, Math.min(contained + used, batteryData.maxCapacity()));
return used;
}
} catch (IllegalAccessException e) {
BCLog.logger.log(Level.WARNING, "can't add energy", e);
}
return 0;
}
/**
* {@inheritDoc}
*/
@Override
public double getEnergyStored() {
try {
return energyStored.getDouble(obj);
} catch (IllegalAccessException e) {
BCLog.logger.log(Level.WARNING, "can't get return energy stored", e);
return 0;
}
}
/**
* {@inheritDoc}
*/
@Override
public void setEnergyStored(double mj) {
try {
energyStored.setDouble(obj, mj);
} catch (IllegalAccessException e) {
BCLog.logger.log(Level.WARNING, "can't set energy stored", e);
throw new RuntimeException(e);
}
}
/**
* {@inheritDoc}
*/
@Override
public double maxCapacity() {
return batteryData.maxCapacity();
}
/**
* {@inheritDoc}
*/
@Override
public double minimumConsumption() {
return batteryData.minimumConsumption();
}
/**
* {@inheritDoc}
*/
@Override
public double maxReceivedPerCycle() {
return batteryData.maxReceivedPerCycle();
}
/**
* {@inheritDoc}
*/
@Override
public BatteryObject reconfigure(double maxCapacity, double maxReceivedPerCycle, double minimumConsumption) {
overrideBattery(maxCapacity, maxReceivedPerCycle, minimumConsumption,
batteryData.kind(), batteryData.sides(), batteryData.mode());
return this;
}
public void overrideBattery(final double maxCapacity, final double maxReceivedPerCycle, final double minimumConsumption,
final String kind, final ForgeDirection[] sides, final IOMode mode) {
batteryData = new MjBattery() {
@Override
public double maxCapacity() {
return maxCapacity;
}
@Override
public double maxReceivedPerCycle() {
return maxReceivedPerCycle;
}
@Override
public double minimumConsumption() {
return minimumConsumption;
}
@Override
public Class<? extends Annotation> annotationType() {
return MjBattery.class;
}
@Override
public String kind() {
return kind;
}
@Override
public ForgeDirection[] sides() {
return sides;
}
@Override
public IOMode mode() {
return mode;
}
};
}
@Override
public String kind() {
return batteryData.kind();
}
@Override
public IOMode mode() {
return batteryData.mode();
}
@Override
public boolean canSend() {
return batteryData.mode().canSend;
}
@Override
public boolean canReceive() {
return batteryData.mode().canReceive;
}
}

View file

@ -1,83 +0,0 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.api.mj;
public interface IBatteryObject {
/**
* @return Current energy requirement for keeping machine state
*/
double getEnergyRequested();
/**
* Add energy to this battery
*
* @param mj Energy amount
* @return Used energy
*/
double addEnergy(double mj);
/**
* Add energy to this battery
*
* @param mj Energy amount
* @param ignoreCycleLimit Force add all energy even if "maxReceivedPerCycle" limit is reached
* @return Used energy
*/
double addEnergy(double mj, boolean ignoreCycleLimit);
/**
* @return Current stored energy amount in this battery
*/
double getEnergyStored();
/**
* Set current stored energy amount.
* Doesn't use it for your machines! Decrease your battery field directly.
*
* @param mj New energy amount
*/
void setEnergyStored(double mj);
/**
* Can be overrided via {@link #reconfigure(double, double, double)}
*
* @return Maximal energy amount for this battery.
*/
double maxCapacity();
/**
* Can be overrided via {@link #reconfigure(double, double, double)}
*
* @return Minimal energy amount for keep your machine in active state
*/
double minimumConsumption();
/**
* Can be overrided via {@link #reconfigure(double, double, double)}
*
* @return Maximal energy received per one tick
*/
double maxReceivedPerCycle();
/**
* Allow to dynamically reconfigure your battery.
* Usually it's not very good change battery parameters for already present machines, but if you want...
*
* @param maxCapacity {@link #maxCapacity()}
* @param maxReceivedPerCycle {@link #maxReceivedPerCycle()}
* @param minimumConsumption {@link #minimumConsumption()}
* @return Current battery object instance
*/
IBatteryObject reconfigure(double maxCapacity, double maxReceivedPerCycle, double minimumConsumption);
/**
* @return kind of this energy battery
*/
String kind();
}

View file

@ -1,241 +0,0 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.api.mj;
import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.core.BCLog;
import buildcraft.api.core.JavaTools;
/**
* The class MjAPI provides services to the Minecraft Joules power framework.
* BuildCraft implements a default power model on top of this, the "kinesis"
* power model. Third party mods may provide they own version of Minecraft
* Joules batteries and provide different models.
*/
public final class MjAPI {
public static final String DEFAULT_POWER_FRAMEWORK = "buildcraft.kinesis";
private static Map<BatteryHolder, BatteryField> mjBatteries = new HashMap<BatteryHolder, BatteryField>();
private static Map<String, Class<? extends BatteryObject>> mjBatteryKinds = new HashMap<String, Class<? extends BatteryObject>>();
private static final BatteryField invalidBatteryField = new BatteryField();
/**
* Deactivate constructor
*/
private MjAPI() {
}
/**
* Returns the default battery related to the object given in parameter. For
* performance optimization, it's good to cache this object in the providing
* power framework if possible.
*/
public static IBatteryObject getMjBattery(Object o) {
return getMjBattery(o, DEFAULT_POWER_FRAMEWORK);
}
/**
* Returns the battery related to the object given in parameter. For
* performance optimization, it's good to cache this object in the providing
* power framework if possible.
*/
public static IBatteryObject getMjBattery(Object o, String kind) {
return getMjBattery(o, kind, ForgeDirection.UNKNOWN);
}
/**
* Returns the battery related to the object given in parameter. For
* performance optimization, it's good to cache this object in the providing
* power framework if possible.
*/
public static IBatteryObject getMjBattery(Object o, String kind, ForgeDirection side) {
if (o == null) {
return null;
}
IBatteryObject battery = null;
if (o instanceof ISidedBatteryProvider) {
battery = ((ISidedBatteryProvider) o).getMjBattery(kind, side);
if (battery == null && side != ForgeDirection.UNKNOWN) {
battery = ((ISidedBatteryProvider) o).getMjBattery(kind, ForgeDirection.UNKNOWN);
}
}
if (o instanceof IBatteryProvider) {
battery = ((IBatteryProvider) o).getMjBattery(kind);
}
if (battery != null) {
return battery;
}
BatteryField f = getMjBatteryField(o.getClass(), kind, side);
if (f == null && side != ForgeDirection.UNKNOWN) {
f = getMjBatteryField(o.getClass(), kind, ForgeDirection.UNKNOWN);
}
if (f == null) {
return null;
} else if (!mjBatteryKinds.containsKey(kind)) {
return null;
} else if (f.kind == BatteryKind.Value) {
try {
BatteryObject obj = mjBatteryKinds.get(kind).newInstance();
obj.obj = o;
obj.energyStored = f.field;
obj.batteryData = f.battery;
return obj;
} catch (InstantiationException e) {
BCLog.logger.log(Level.WARNING, "can't instantiate class for energy kind \"" + kind + "\"");
return null;
} catch (IllegalAccessException e) {
BCLog.logger.log(Level.WARNING, "can't instantiate class for energy kind \"" + kind + "\"");
return null;
}
} else {
try {
return getMjBattery(f.field.get(o), kind, side);
} catch (IllegalAccessException e) {
e.printStackTrace();
return null;
}
}
}
public static IBatteryObject[] getAllMjBatteries(Object o) {
return getAllMjBatteries(o, ForgeDirection.UNKNOWN);
}
public static IBatteryObject[] getAllMjBatteries(Object o, ForgeDirection direction) {
IBatteryObject[] result = new IBatteryObject[mjBatteries.size()];
int id = 0;
for (String kind : mjBatteryKinds.keySet()) {
result[id] = getMjBattery(o, kind, direction);
if (result[id] != null) {
id++;
}
}
return Arrays.copyOfRange(result, 0, id);
}
public static void registerMJBatteryKind(String kind, Class<? extends BatteryObject> clas) {
if (!mjBatteryKinds.containsKey(kind)) {
mjBatteryKinds.put(kind, clas);
} else {
BCLog.logger.log(Level.WARNING,
"energy kind \"" + kind + "\" already registered with " + clas.getCanonicalName());
}
}
private enum BatteryKind {
Value, Container
}
private static final class BatteryHolder {
private String kind;
private ForgeDirection side;
private Class clazz;
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
BatteryHolder that = (BatteryHolder) o;
return kind.equals(that.kind) && clazz.equals(that.clazz) && side.equals(that.side);
}
@Override
public int hashCode() {
int result = kind.hashCode();
result = 31 * result + clazz.hashCode();
result = 31 * result + side.hashCode();
return result;
}
}
private static class BatteryField {
public Field field;
public MjBattery battery;
public BatteryKind kind;
}
private static BatteryField getMjBatteryField(Class c, String kind, ForgeDirection side) {
BatteryHolder holder = new BatteryHolder();
holder.clazz = c;
holder.kind = kind;
holder.side = side;
BatteryField bField = mjBatteries.get(holder);
if (bField == null) {
for (Field f : JavaTools.getAllFields(c)) {
MjBattery battery = f.getAnnotation(MjBattery.class);
if (battery != null && kind.equals(battery.kind())) {
if (!contains(battery.sides(), side) && !contains(battery.sides(), ForgeDirection.UNKNOWN)) {
continue;
}
f.setAccessible(true);
bField = new BatteryField();
bField.field = f;
bField.battery = battery;
if (double.class.equals(f.getType())) {
bField.kind = BatteryKind.Value;
} else if (f.getType().isPrimitive()) {
throw new RuntimeException(
"MJ battery needs to be object or double type");
} else {
bField.kind = BatteryKind.Container;
}
mjBatteries.put(holder, bField);
return bField;
}
}
mjBatteries.put(holder, invalidBatteryField);
}
return bField == invalidBatteryField ? null : bField;
}
private static <T> boolean contains(T[] array, T value) {
for (T t : array) {
if (t == value) {
return true;
}
}
return false;
}
static {
mjBatteryKinds.put(MjAPI.DEFAULT_POWER_FRAMEWORK, BatteryObject.class);
}
}

View file

@ -1,60 +0,0 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.api.mj;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.power.IPowerReceptor;
import buildcraft.api.power.PowerHandler;
public class MjAPILegacy implements IPowerReceptor {
private final PowerHandler powerHandler;
private final World world;
protected MjAPILegacy(World world, IBatteryObject battery, PowerHandler.Type type) {
if (battery == null) {
throw new NullPointerException();
}
this.world = world;
this.powerHandler = new PowerHandler(this, type, battery);
}
public static MjAPILegacy from(World world, IBatteryObject battery, PowerHandler.Type type) {
if (battery == null) {
return null;
}
return new MjAPILegacy(world, battery, type);
}
public static MjAPILegacy from(World world, Object object, PowerHandler.Type type) {
return from(world, MjAPI.getMjBattery(object), type);
}
public static MjAPILegacy from(TileEntity tileEntity, PowerHandler.Type type) {
return from(tileEntity.getWorldObj(), MjAPI.getMjBattery(tileEntity), type);
}
@Override
public PowerHandler.PowerReceiver getPowerReceiver(ForgeDirection side) {
return powerHandler.getPowerReceiver();
}
@Override
public void doWork(PowerHandler workProvider) {
}
@Override
public World getWorld() {
return world;
}
}

View file

@ -1,73 +0,0 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.api.mj;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import net.minecraftforge.common.util.ForgeDirection;
/**
* This annotation is used for tiles that need to interface with BuildCraft
* energy framework, a.k.a MinecraftJoule or MJ. In order to receive power,
* tiles, need to declare a double field, with the annotation MjBattery. MJ
* provider machines able to provide power will then connect to these tiles, and
* feed energy up to max capacity. It's the responsibility of the implementer to
* manually decrease the value of the energy, as he simulates energy
* consumption. On each cycle, per power input, machines can receive up to
* "maxReceivedPerCycle" units of energy. As an optional behavior, the system
* can have a minimum amount of energy consumed even if the system is at max
* capacity, modelized by the "minimumConsumption" value.
*
* If the field designated by MjBattery is an object, then it will be considered
* as a nested battery, and will look for the field in the designated object.
*
* All the properties defined in this annotation are class wide. If you need to
* change them on a tile by tile basis, you will need to use interfaces, either
* {@link IBatteryProvider} or {@link ISidedBatteryProvider}
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
@Inherited
public @interface MjBattery {
/**
* @return Max energy capacity of battery
*/
double maxCapacity() default 100.0;
/**
* @return Max energy received per one tick
*/
double maxReceivedPerCycle() default 10.0;
/**
* @return Minimal energy for keep machine is active
*/
double minimumConsumption() default 0.1;
/**
* @return The kind of battery stored. Specific power systems can be created
* through this system, as several battery of different kind can
* coexist in the same tile.
*/
String kind() default MjAPI.DEFAULT_POWER_FRAMEWORK;
/**
* @return Sides on which this battery should works.
*/
ForgeDirection[] sides() default { ForgeDirection.UNKNOWN };
/**
* @return Current battery input/output mode
*/
IOMode mode() default IOMode.Receive;
}

View file

@ -1,41 +0,0 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.api.power;
public interface ILaserTarget {
/**
* Returns true if the target currently needs power. For example, if the Advanced
* Crafting Table has work to do.
*
* @return true if needs power
*/
boolean requiresLaserEnergy();
/**
* Transfers energy from the laser to the target.
*
* @param energy
*/
void receiveLaserEnergy(double energy);
/**
* Return true if the Tile Entity object is no longer a valid target. For
* example, if its been invalidated.
*
* @return true if no longer a valid target object
*/
boolean isInvalidTarget();
int getXCoord();
int getYCoord();
int getZCoord();
}

View file

@ -1,45 +0,0 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.api.power;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
/**
* This interface should be implemented by any Tile Entity that wishes to be
* able to receive power.
*/
public interface IPowerReceptor {
/**
* Get the PowerReceiver for this side of the block. You can return the same
* PowerReceiver for all sides or one for each side.
*
* You should NOT return null to this method unless you mean to NEVER
* receive power from that side. Returning null, after previous returning a
* PowerReceiver, will most likely cause pipe connections to derp out and
* engines to eventually explode.
*
* @param side
*/
PowerHandler.PowerReceiver getPowerReceiver(ForgeDirection side);
/**
* Call back from the PowerHandler that is called when the stored power
* exceeds the activation power.
*
* It can be triggered by update() calls or power modification calls.
*
* @param workProvider
*/
void doWork(PowerHandler workProvider);
World getWorld();
}

View file

@ -1,510 +0,0 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.api.power;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.core.SafeTimeTracker;
import buildcraft.api.mj.BatteryObject;
import buildcraft.api.mj.IBatteryObject;
import buildcraft.api.mj.IBatteryProvider;
import buildcraft.api.mj.MjAPI;
import buildcraft.api.mj.MjBattery;
/**
* The PowerHandler is similar to FluidTank in that it holds your power and
* allows standardized interaction between machines.
* <p/>
* To receive power to your machine you needs create an instance of PowerHandler
* and implement IPowerReceptor on the TileEntity.
* <p/>
* If you plan emit power, you need only implement IPowerEmitter. You do not
* need a PowerHandler. Engines have a PowerHandler because they can also
* receive power from other Engines.
* <p/>
* See TileRefinery for a simple example of a power using machine.
*
* @see IPowerReceptor
* @see IPowerEmitter
*/
public final class PowerHandler implements IBatteryProvider {
public static enum Type {
ENGINE, GATE, MACHINE, PIPE, STORAGE;
public boolean canReceiveFromPipes() {
switch (this) {
case MACHINE:
case STORAGE:
return true;
default:
return false;
}
}
public boolean eatsEngineExcess() {
switch (this) {
case MACHINE:
case STORAGE:
return true;
default:
return false;
}
}
}
/**
* Extend this class to create custom Perdition algorithms (its not final).
* <p/>
* NOTE: It is not possible to create a Zero perdition algorithm.
*/
public static class PerditionCalculator {
public static final float DEFAULT_POWERLOSS = 1F;
public static final float MIN_POWERLOSS = 0.01F;
private final double powerLoss;
public PerditionCalculator() {
powerLoss = DEFAULT_POWERLOSS;
}
/**
* Simple constructor for simple Perdition per tick.
*
* @param powerLoss power loss per tick
*/
public PerditionCalculator(double powerLoss) {
if (powerLoss < MIN_POWERLOSS) {
this.powerLoss = MIN_POWERLOSS;
} else {
this.powerLoss = powerLoss;
}
}
/**
* Apply the perdition algorithm to the current stored energy. This
* function can only be called once per tick, but it might not be called
* every tick. It is triggered by any manipulation of the stored energy.
*
* @param powerHandler the PowerHandler requesting the perdition update
* @param current the current stored energy
* @param ticksPassed ticks since the last time this function was called
*/
public double applyPerdition(PowerHandler powerHandler, double current, long ticksPassed) {
double newPower = current - powerLoss * ticksPassed;
if (newPower < 0) {
newPower = 0;
}
return newPower;
}
/**
* Taxes a flat rate on all incoming power.
* <p/>
* Defaults to 0% tax rate.
*
* @return percent of input to tax
*/
public double getTaxPercent() {
return 0;
}
}
public static final PerditionCalculator DEFAULT_PERDITION = new PerditionCalculator();
public static final double ROLLING_AVERAGE_WEIGHT = 100.0;
public static final double ROLLING_AVERAGE_NUMERATOR = ROLLING_AVERAGE_WEIGHT - 1;
public static final double ROLLING_AVERAGE_DENOMINATOR = 1.0 / ROLLING_AVERAGE_WEIGHT;
public final int[] powerSources = new int[6];
public final IPowerReceptor receptor;
private double activationEnergy;
private final SafeTimeTracker doWorkTracker = new SafeTimeTracker(1);
private final SafeTimeTracker sourcesTracker = new SafeTimeTracker(1);
private final SafeTimeTracker perditionTracker = new SafeTimeTracker(1);
private PerditionCalculator perdition;
private final PowerReceiver receiver;
private final Type type;
private IBatteryObject battery;
// Tracking
private double averageLostPower = 0;
private double averageReceivedPower = 0;
private double averageUsedPower = 0;
public PowerHandler(IPowerReceptor receptor, Type type) {
this(receptor, type, null);
}
public PowerHandler(IPowerReceptor receptor, Type type, Object battery) {
this.receptor = receptor;
this.type = type;
this.receiver = new PowerReceiver();
this.perdition = DEFAULT_PERDITION;
if (battery instanceof IBatteryObject) {
this.battery = (BatteryObject) battery;
} else if (battery != null) {
this.battery = MjAPI.getMjBattery(battery);
} else {
this.battery = MjAPI.getMjBattery(new AnonymousBattery());
}
}
public PowerReceiver getPowerReceiver() {
return receiver;
}
public double getMinEnergyReceived() {
return battery.minimumConsumption();
}
public double getMaxEnergyReceived() {
return battery.getEnergyRequested();
}
public double getMaxEnergyStored() {
return battery.maxCapacity();
}
public double getActivationEnergy() {
return activationEnergy;
}
public double getEnergyStored() {
return battery.getEnergyStored();
}
@Override
public IBatteryObject getMjBattery(String kind) {
return battery.kind().equals(kind) ? battery : null;
}
/**
* Setup your PowerHandler's settings.
*
* @param minEnergyReceived
* This is the minimum about of power that will be accepted by
* the PowerHandler. This should generally be greater than the
* activationEnergy if you plan to use the doWork() callback.
* Anything greater than 1 will prevent Redstone Engines from
* powering this Provider.
* @param maxEnergyReceived
* The maximum amount of power accepted by the PowerHandler. This
* should generally be less than 500. Too low and larger engines
* will overheat while trying to power the machine. Too high, and
* the engines will never warm up. Greater values also place
* greater strain on the power net.
* @param activationEnergy
* If the stored energy is greater than this value, the doWork()
* callback is called (once per tick).
* @param maxStoredEnergy
* The maximum amount of power this PowerHandler can store.
* Values tend to range between 100 and 5000. With 1000 and 1500
* being common.
*/
public void configure(double minEnergyReceived, double maxEnergyReceived, double activationEnergy,
double maxStoredEnergy) {
double localMaxEnergyReceived = maxEnergyReceived;
if (minEnergyReceived > localMaxEnergyReceived) {
localMaxEnergyReceived = minEnergyReceived;
}
this.activationEnergy = activationEnergy;
battery.reconfigure(maxStoredEnergy, localMaxEnergyReceived, minEnergyReceived);
}
/**
* Allows you define perdition in terms of loss/ticks.
* <p/>
* This function is mostly for legacy implementations. See
* PerditionCalculator for more complex perdition formulas.
*
* @param powerLoss
* @param powerLossRegularity
* @see PerditionCalculator
*/
public void configurePowerPerdition(int powerLoss, int powerLossRegularity) {
if (powerLoss == 0 || powerLossRegularity == 0) {
perdition = new PerditionCalculator(0);
return;
}
perdition = new PerditionCalculator((float) powerLoss / (float) powerLossRegularity);
}
/**
* Allows you to define a new PerditionCalculator class to handler perdition
* calculations.
* <p/>
* For example if you want exponentially increasing loss based on amount
* stored.
*
* @param perdition
*/
public void setPerdition(PerditionCalculator perdition) {
if (perdition == null) {
this.perdition = DEFAULT_PERDITION;
} else {
this.perdition = perdition;
}
}
public PerditionCalculator getPerdition() {
if (perdition == null) {
return DEFAULT_PERDITION;
} else {
return perdition;
}
}
/**
* Ticks the power handler. You should call this if you can, but its not
* required.
* <p/>
* If you don't call it, the possibility exists for some weirdness with the
* perdition algorithm and work callback as its possible they will not be
* called on every tick they otherwise would be. You should be able to
* design around this though if you are aware of the limitations.
*/
public void update() {
applyPerdition();
applyWork();
validateEnergy();
}
private void applyPerdition() {
double energyStored = getEnergyStored();
if (perditionTracker.markTimeIfDelay(receptor.getWorld()) && energyStored > 0) {
double prev = energyStored;
double newEnergy = getPerdition().applyPerdition(this, energyStored, perditionTracker.durationOfLastDelay());
if (newEnergy == 0 || newEnergy < energyStored) {
battery.setEnergyStored(energyStored = newEnergy);
} else {
battery.setEnergyStored(energyStored = DEFAULT_PERDITION.applyPerdition(this, energyStored, perditionTracker.durationOfLastDelay()));
}
validateEnergy();
averageLostPower = (averageLostPower * ROLLING_AVERAGE_NUMERATOR + (prev - energyStored)) * ROLLING_AVERAGE_DENOMINATOR;
}
}
private void applyWork() {
if (getEnergyStored() >= activationEnergy) {
if (doWorkTracker.markTimeIfDelay(receptor.getWorld())) {
receptor.doWork(this);
}
}
}
private void updateSources(ForgeDirection source) {
if (sourcesTracker.markTimeIfDelay(receptor.getWorld())) {
for (int i = 0; i < 6; ++i) {
powerSources[i] -= sourcesTracker.durationOfLastDelay();
if (powerSources[i] < 0) {
powerSources[i] = 0;
}
}
}
if (source != null) {
powerSources[source.ordinal()] = 10;
}
}
/**
* Extract energy from the PowerHandler. You must call this even if doWork()
* triggers.
*
* @param min
* @param max
* @param doUse
* @return amount used
*/
public double useEnergy(double min, double max, boolean doUse) {
applyPerdition();
double result = 0;
double energyStored = getEnergyStored();
if (energyStored >= min) {
if (energyStored <= max) {
result = energyStored;
if (doUse) {
energyStored = 0;
}
} else {
result = max;
if (doUse) {
energyStored -= max;
}
}
}
if (energyStored != getEnergyStored()) {
battery.setEnergyStored(energyStored);
}
validateEnergy();
if (doUse) {
averageUsedPower = (averageUsedPower * ROLLING_AVERAGE_NUMERATOR + result) * ROLLING_AVERAGE_DENOMINATOR;
}
return result;
}
public void readFromNBT(NBTTagCompound data) {
readFromNBT(data, "powerProvider");
}
public void readFromNBT(NBTTagCompound data, String tag) {
NBTTagCompound nbt = data.getCompoundTag(tag);
battery.setEnergyStored(nbt.getDouble("energyStored"));
}
public void writeToNBT(NBTTagCompound data) {
writeToNBT(data, "powerProvider");
}
public void writeToNBT(NBTTagCompound data, String tag) {
NBTTagCompound nbt = new NBTTagCompound();
nbt.setDouble("energyStored", battery.getEnergyStored());
data.setTag(tag, nbt);
}
public final class PowerReceiver {
private PowerReceiver() {
}
public double getMinEnergyReceived() {
return PowerHandler.this.getMinEnergyReceived();
}
public double getMaxEnergyReceived() {
return PowerHandler.this.getMaxEnergyReceived();
}
public double getMaxEnergyStored() {
return PowerHandler.this.getMaxEnergyStored();
}
public double getActivationEnergy() {
return activationEnergy;
}
public double getEnergyStored() {
return PowerHandler.this.getEnergyStored();
}
public double getAveragePowerReceived() {
return averageReceivedPower;
}
public double getAveragePowerUsed() {
return averageUsedPower;
}
public double getAveragePowerLost() {
return averageLostPower;
}
public Type getType() {
return type;
}
public void update() {
PowerHandler.this.update();
}
/**
* The amount of power that this PowerHandler currently needs.
*/
public double powerRequest() {
update();
return battery.getEnergyRequested();
}
/**
* Add power to the PowerReceiver from an external source.
* <p/>
* IPowerEmitters are responsible for calling this themselves.
*
* @param quantity
* @param from
* @return the amount of power used
*/
public double receiveEnergy(Type source, final double quantity, ForgeDirection from) {
double used = quantity;
if (source == Type.ENGINE) {
if (used < getMinEnergyReceived()) {
return 0;
} else if (used > getMaxEnergyReceived()) {
used = getMaxEnergyReceived();
}
}
updateSources(from);
used -= used * getPerdition().getTaxPercent();
used = addEnergy(used);
applyWork();
if (source == Type.ENGINE && type.eatsEngineExcess()) {
used = Math.min(quantity, getMaxEnergyReceived());
}
averageReceivedPower = (averageReceivedPower * ROLLING_AVERAGE_NUMERATOR + used) * ROLLING_AVERAGE_DENOMINATOR;
return used;
}
}
/**
* @return the amount the power changed by
*/
public double addEnergy(double quantity) {
final double used = battery.addEnergy(quantity);
applyPerdition();
return used;
}
public void setEnergy(double quantity) {
battery.setEnergyStored(quantity);
validateEnergy();
}
public boolean isPowerSource(ForgeDirection from) {
return powerSources[from.ordinal()] != 0;
}
private void validateEnergy() {
double energyStored = getEnergyStored();
double maxEnergyStored = getMaxEnergyStored();
if (energyStored < 0) {
energyStored = 0;
}
if (energyStored > maxEnergyStored) {
energyStored = maxEnergyStored;
}
if (energyStored != battery.getEnergyStored()) {
battery.setEnergyStored(energyStored);
}
}
private static class AnonymousBattery {
@MjBattery
public double mjStored;
}
}

View file

@ -8,33 +8,30 @@
*/
package buildcraft.api.recipes;
import java.util.List;
import java.util.Collection;
import net.minecraft.item.ItemStack;
public interface IAssemblyRecipeManager {
public interface IAssemblyRecipe {
ItemStack getOutput();
Object[] getInputs();
double getEnergyCost();
}
/**
* Add an Assembly Table recipe.
*
*
* @param input
* Object... containing either an ItemStack, or a paired string
* and integer(ex: "dyeBlue", 1)
* @param energyCost
* MJ cost to produce
* RF cost to produce
* @param output
* resulting ItemStack
*/
void addRecipe(double energyCost, ItemStack output, Object... input);
void addRecipe(String id, int energyCost, ItemStack output, Object... input);
List<? extends IAssemblyRecipe> getRecipes();
void addRecipe(IFlexibleRecipe<ItemStack> recipe);
void removeRecipe(String id);
void removeRecipe(IFlexibleRecipe<ItemStack> recipe);
Collection<IFlexibleRecipe<ItemStack>> getRecipes();
}

View file

@ -0,0 +1,22 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.api.recipes;
import net.minecraft.item.ItemStack;
public interface IFlexibleRecipe<T> {
boolean canBeCrafted(IFlexibleCrafter crafter);
CraftingResult<T> craft(IFlexibleCrafter crafter, boolean preview);
CraftingResult<T> canCraft(ItemStack expectedOutput);
String getId();
}

View file

@ -0,0 +1,27 @@
package buildcraft.api.recipes;
import java.util.Collection;
/**
* This class is intended for mods such as Not Enough Items
* in order for them to be able to look inside a recipe.
*
* It is intentionally left as a separate interface, so that
* it remains possible to register a "dynamic" flexible
* recipe which does not have static inputs and outputs.
*
* @author asie
*/
public interface IFlexibleRecipeViewable {
Object getOutput();
/**
* With BuildCraft's implementation (as of 6.1.3), this might
* contain either an ItemStack, a List<ItemStack> or a FluidStack.
*/
Collection<Object> getInputs();
long getCraftingTime();
int getEnergyCost();
}

View file

@ -8,30 +8,22 @@
*/
package buildcraft.api.recipes;
import java.util.SortedSet;
import java.util.Collection;
import net.minecraftforge.fluids.FluidStack;
public interface IRefineryRecipeManager {
void addRecipe(FluidStack ingredient, FluidStack result, int energy, int delay);
void addRecipe(String id, FluidStack ingredient, FluidStack result, int energy, int delay);
void addRecipe(FluidStack ingredient1, FluidStack ingredient2, FluidStack result, int energy, int delay);
void addRecipe(String id, FluidStack ingredient1, FluidStack ingredient2, FluidStack result, int energy, int delay);
SortedSet<? extends IRefineryRecipe> getRecipes();
void removeRecipe(String id);
void removeRecipe(IFlexibleRecipe<FluidStack> recipe);
IRefineryRecipe findRefineryRecipe(FluidStack ingredient1, FluidStack ingredient2);
Collection<IFlexibleRecipe<FluidStack>> getRecipes();
public interface IRefineryRecipe {
IFlexibleRecipe<FluidStack> getRecipe(String currentRecipeId);
FluidStack getIngredient1();
FluidStack getIngredient2();
FluidStack getResult();
int getEnergyCost();
int getTimeRequired();
}
}

View file

@ -6,16 +6,26 @@
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.api.power;
package buildcraft.api.transport;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.gates.IGate;
/**
* Essentially only used for Wooden Power Pipe connection rules.
*
* This Tile Entity interface allows you to indicate that a block can emit power
* from a specific side.
*/
public interface IPowerEmitter {
boolean canEmitPowerFrom(ForgeDirection side);
public interface IPipe {
int x();
int y();
int z();
IPipeTile getTile();
IGate getGate(ForgeDirection side);
boolean hasGate(ForgeDirection side);
boolean isWired(PipeWire wire);
boolean isWireActive(PipeWire wire);
}

View file

@ -9,8 +9,9 @@
package buildcraft.api.transport;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.core.EnumColor;
public interface IPipeTile {
@ -29,8 +30,16 @@ public interface IPipeTile {
* @param doAdd If false no actual addition should take place. Implementors
* should simulate.
* @param from Orientation the ItemStack is offered from.
* @param color The color of the item to be added to the pipe, or null for no color.
* @return Amount of items used from the passed stack.
*/
int injectItem(ItemStack stack, boolean doAdd, ForgeDirection from, EnumColor color);
/**
* Same as
* {@link #injectItem(ItemStack, boolean, ForgeDirection, EnumColor)}
* but with no color attribute.
*/
int injectItem(ItemStack stack, boolean doAdd, ForgeDirection from);
/**
@ -41,11 +50,7 @@ public interface IPipeTile {
*/
boolean isPipeConnected(ForgeDirection with);
/**
* True if the pipe has a powered wire of the specified color.
*
* @param wire
* @return true if powered
*/
boolean isWireActive(PipeWire wire);
TileEntity getAdjacentTile(ForgeDirection dir);
IPipe getPipe();
}

View file

@ -0,0 +1,20 @@
package buildcraft.api.transport;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public interface IStripesHandler {
public static enum StripesHandlerType {
ITEM_USE,
BLOCK_BREAK
}
StripesHandlerType getType();
boolean shouldHandle(ItemStack stack);
boolean handle(World world, int x, int y, int z, ForgeDirection direction,
ItemStack stack, EntityPlayer player, IStripesPipe pipe);
}

View file

@ -0,0 +1,9 @@
package buildcraft.api.transport;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.ForgeDirection;
public interface IStripesPipe extends IPipe {
void sendItem(ItemStack itemStack, ForgeDirection direction);
void dropItem(ItemStack itemStack, ForgeDirection direction);
}

View file

@ -15,11 +15,16 @@ import net.minecraft.world.World;
public abstract class PipeManager {
public static List<IStripesHandler> stripesHandlers = new ArrayList<IStripesHandler>();
public static List<IExtractionHandler> extractionHandlers = new ArrayList<IExtractionHandler>();
public static void registerExtractionHandler(IExtractionHandler handler) {
extractionHandlers.add(handler);
}
public static void registerStripesHandler(IStripesHandler handler) {
stripesHandlers.add(handler);
}
/**
* param extractor can be null

View file

@ -6,7 +6,7 @@
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
@API(apiVersion = "2.0", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|transport")
@API(apiVersion = "2.1", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|transport")
package buildcraft.api.transport;
import cpw.mods.fml.common.API;

View file

@ -0,0 +1,11 @@
package cofh.api;
public class CoFHAPIProps {
private CoFHAPIProps() {
}
public static final String VERSION = "1.7.10R1.0.1";
}

View file

@ -0,0 +1,158 @@
package cofh.api.energy;
import net.minecraft.nbt.NBTTagCompound;
/**
* Reference implementation of {@link IEnergyStorage}. Use/extend this or implement your own.
*
* @author King Lemming
*
*/
public class EnergyStorage implements IEnergyStorage {
protected int energy;
protected int capacity;
protected int maxReceive;
protected int maxExtract;
public EnergyStorage(int capacity) {
this(capacity, capacity, capacity);
}
public EnergyStorage(int capacity, int maxTransfer) {
this(capacity, maxTransfer, maxTransfer);
}
public EnergyStorage(int capacity, int maxReceive, int maxExtract) {
this.capacity = capacity;
this.maxReceive = maxReceive;
this.maxExtract = maxExtract;
}
public EnergyStorage readFromNBT(NBTTagCompound nbt) {
this.energy = nbt.getInteger("Energy");
if (energy > capacity) {
energy = capacity;
}
return this;
}
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
if (energy < 0) {
energy = 0;
}
nbt.setInteger("Energy", energy);
return nbt;
}
public void setCapacity(int capacity) {
this.capacity = capacity;
if (energy > capacity) {
energy = capacity;
}
}
public void setMaxTransfer(int maxTransfer) {
setMaxReceive(maxTransfer);
setMaxExtract(maxTransfer);
}
public void setMaxReceive(int maxReceive) {
this.maxReceive = maxReceive;
}
public void setMaxExtract(int maxExtract) {
this.maxExtract = maxExtract;
}
public int getMaxReceive() {
return maxReceive;
}
public int getMaxExtract() {
return maxExtract;
}
/**
* This function is included to allow for server -&gt; client sync. Do not call this externally to the containing Tile Entity, as not all IEnergyHandlers
* are guaranteed to have it.
*
* @param energy
*/
public void setEnergyStored(int energy) {
this.energy = energy;
if (this.energy > capacity) {
this.energy = capacity;
} else if (this.energy < 0) {
this.energy = 0;
}
}
/**
* This function is included to allow the containing tile to directly and efficiently modify the energy contained in the EnergyStorage. Do not rely on this
* externally, as not all IEnergyHandlers are guaranteed to have it.
*
* @param energy
*/
public void modifyEnergyStored(int energy) {
this.energy += energy;
if (this.energy > capacity) {
this.energy = capacity;
} else if (this.energy < 0) {
this.energy = 0;
}
}
/* IEnergyStorage */
@Override
public int receiveEnergy(int maxReceive, boolean simulate) {
int energyReceived = Math.min(capacity - energy, Math.min(this.maxReceive, maxReceive));
if (!simulate) {
energy += energyReceived;
}
return energyReceived;
}
@Override
public int extractEnergy(int maxExtract, boolean simulate) {
int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract));
if (!simulate) {
energy -= energyExtracted;
}
return energyExtracted;
}
@Override
public int getEnergyStored() {
return energy;
}
@Override
public int getMaxEnergyStored() {
return capacity;
}
}

View file

@ -5,7 +5,7 @@ import net.minecraftforge.common.util.ForgeDirection;
/**
* Implement this interface on TileEntities which should connect to energy transportation blocks. This is intended for blocks which generate energy but do not
* accept it; otherwise just use IEnergyHandler.
*
* <p>
* Note that {@link IEnergyHandler} is an extension of this.
*
* @author King Lemming

View file

@ -4,7 +4,7 @@ import net.minecraft.item.ItemStack;
/**
* Implement this interface on Item classes that support external manipulation of their internal energy storages.
*
* <p>
* A reference implementation is provided {@link ItemEnergyContainer}.
*
* @author King Lemming

View file

@ -4,17 +4,19 @@ import net.minecraftforge.common.util.ForgeDirection;
/**
* Implement this interface on Tile Entities which should handle energy, generally storing it in one or more internal {@link IEnergyStorage} objects.
*
* <p>
* A reference implementation is provided {@link TileEnergyHandler}.
*
*
* @author King Lemming
*
*
*/
public interface IEnergyHandler extends IEnergyConnection {
public interface IEnergyHandler extends IEnergyProvider, IEnergyReceiver {
// merely a convenience interface (remove these methods in 1.8; provided here for back-compat via compiler doing things)
/**
* Add energy to an IEnergyHandler, internal distribution is left entirely to the IEnergyHandler.
*
* Add energy to an IEnergyReceiver, internal distribution is left entirely to the IEnergyReceiver.
*
* @param from
* Orientation the energy is received from.
* @param maxReceive
@ -23,11 +25,12 @@ public interface IEnergyHandler extends IEnergyConnection {
* If TRUE, the charge will only be simulated.
* @return Amount of energy that was (or would have been, if simulated) received.
*/
@Override
int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate);
/**
* Remove energy from an IEnergyHandler, internal distribution is left entirely to the IEnergyHandler.
*
* Remove energy from an IEnergyProvider, internal distribution is left entirely to the IEnergyProvider.
*
* @param from
* Orientation the energy is extracted from.
* @param maxExtract
@ -36,16 +39,20 @@ public interface IEnergyHandler extends IEnergyConnection {
* If TRUE, the extraction will only be simulated.
* @return Amount of energy that was (or would have been, if simulated) extracted.
*/
@Override
int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate);
/**
* Returns the amount of energy currently stored.
*/
@Override
int getEnergyStored(ForgeDirection from);
/**
* Returns the maximum amount of energy that can be stored.
*/
@Override
int getMaxEnergyStored(ForgeDirection from);
}

View file

@ -0,0 +1,38 @@
package cofh.api.energy;
import net.minecraftforge.common.util.ForgeDirection;
/**
* Implement this interface on Tile Entities which should provide energy, generally storing it in one or more internal {@link IEnergyStorage} objects.
* <p>
* A reference implementation is provided {@link TileEnergyHandler}.
*
* @author King Lemming
*
*/
public interface IEnergyProvider extends IEnergyConnection {
/**
* Remove energy from an IEnergyProvider, internal distribution is left entirely to the IEnergyProvider.
*
* @param from
* Orientation the energy is extracted from.
* @param maxExtract
* Maximum amount of energy to extract.
* @param simulate
* If TRUE, the extraction will only be simulated.
* @return Amount of energy that was (or would have been, if simulated) extracted.
*/
int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate);
/**
* Returns the amount of energy currently stored.
*/
int getEnergyStored(ForgeDirection from);
/**
* Returns the maximum amount of energy that can be stored.
*/
int getMaxEnergyStored(ForgeDirection from);
}

View file

@ -0,0 +1,38 @@
package cofh.api.energy;
import net.minecraftforge.common.util.ForgeDirection;
/**
* Implement this interface on Tile Entities which should receive energy, generally storing it in one or more internal {@link IEnergyStorage} objects.
* <p>
* A reference implementation is provided {@link TileEnergyHandler}.
*
* @author King Lemming
*
*/
public interface IEnergyReceiver extends IEnergyConnection {
/**
* Add energy to an IEnergyReceiver, internal distribution is left entirely to the IEnergyReceiver.
*
* @param from
* Orientation the energy is received from.
* @param maxReceive
* Maximum amount of energy to receive.
* @param simulate
* If TRUE, the charge will only be simulated.
* @return Amount of energy that was (or would have been, if simulated) received.
*/
int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate);
/**
* Returns the amount of energy currently stored.
*/
int getEnergyStored(ForgeDirection from);
/**
* Returns the maximum amount of energy that can be stored.
*/
int getMaxEnergyStored(ForgeDirection from);
}

View file

@ -0,0 +1,46 @@
package cofh.api.energy;
/**
* An energy storage is the unit of interaction with Energy inventories.<br>
* This is not to be implemented on TileEntities. This is for internal use only.
* <p>
* A reference implementation can be found at {@link EnergyStorage}.
*
* @author King Lemming
*
*/
public interface IEnergyStorage {
/**
* Adds energy to the storage. Returns quantity of energy that was accepted.
*
* @param maxReceive
* Maximum amount of energy to be inserted.
* @param simulate
* If TRUE, the insertion will only be simulated.
* @return Amount of energy that was (or would have been, if simulated) accepted by the storage.
*/
int receiveEnergy(int maxReceive, boolean simulate);
/**
* Removes energy from the storage. Returns quantity of energy that was removed.
*
* @param maxExtract
* Maximum amount of energy to be extracted.
* @param simulate
* If TRUE, the extraction will only be simulated.
* @return Amount of energy that was (or would have been, if simulated) extracted from the storage.
*/
int extractEnergy(int maxExtract, boolean simulate);
/**
* Returns the amount of energy currently stored.
*/
int getEnergyStored();
/**
* Returns the maximum amount of energy that can be stored.
*/
int getMaxEnergyStored();
}

View file

@ -0,0 +1,110 @@
package cofh.api.energy;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
/**
* Reference implementation of {@link IEnergyContainerItem}. Use/extend this or implement your own.
*
* @author King Lemming
*
*/
public class ItemEnergyContainer extends Item implements IEnergyContainerItem {
protected int capacity;
protected int maxReceive;
protected int maxExtract;
public ItemEnergyContainer() {
}
public ItemEnergyContainer(int capacity) {
this(capacity, capacity, capacity);
}
public ItemEnergyContainer(int capacity, int maxTransfer) {
this(capacity, maxTransfer, maxTransfer);
}
public ItemEnergyContainer(int capacity, int maxReceive, int maxExtract) {
this.capacity = capacity;
this.maxReceive = maxReceive;
this.maxExtract = maxExtract;
}
public ItemEnergyContainer setCapacity(int capacity) {
this.capacity = capacity;
return this;
}
public void setMaxTransfer(int maxTransfer) {
setMaxReceive(maxTransfer);
setMaxExtract(maxTransfer);
}
public void setMaxReceive(int maxReceive) {
this.maxReceive = maxReceive;
}
public void setMaxExtract(int maxExtract) {
this.maxExtract = maxExtract;
}
/* IEnergyContainerItem */
@Override
public int receiveEnergy(ItemStack container, int maxReceive, boolean simulate) {
if (container.stackTagCompound == null) {
container.stackTagCompound = new NBTTagCompound();
}
int energy = container.stackTagCompound.getInteger("Energy");
int energyReceived = Math.min(capacity - energy, Math.min(this.maxReceive, maxReceive));
if (!simulate) {
energy += energyReceived;
container.stackTagCompound.setInteger("Energy", energy);
}
return energyReceived;
}
@Override
public int extractEnergy(ItemStack container, int maxExtract, boolean simulate) {
if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("Energy")) {
return 0;
}
int energy = container.stackTagCompound.getInteger("Energy");
int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract));
if (!simulate) {
energy -= energyExtracted;
container.stackTagCompound.setInteger("Energy", energy);
}
return energyExtracted;
}
@Override
public int getEnergyStored(ItemStack container) {
if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("Energy")) {
return 0;
}
return container.stackTagCompound.getInteger("Energy");
}
@Override
public int getMaxEnergyStored(ItemStack container) {
return capacity;
}
}

View file

@ -0,0 +1,65 @@
package cofh.api.energy;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
/**
* Reference implementation of {@link IEnergyHandler}. Use/extend this or implement your own.
*
* @author King Lemming
*
*/
public class TileEnergyHandler extends TileEntity implements IEnergyHandler {
protected EnergyStorage storage = new EnergyStorage(32000);
@Override
public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
storage.readFromNBT(nbt);
}
@Override
public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
storage.writeToNBT(nbt);
}
/* IEnergyConnection */
@Override
public boolean canConnectEnergy(ForgeDirection from) {
return true;
}
/* IEnergyReceiver */
@Override
public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) {
return storage.receiveEnergy(maxReceive, simulate);
}
/* IEnergyProvider */
@Override
public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) {
return storage.extractEnergy(maxExtract, simulate);
}
/* IEnergyReceiver and IEnergyProvider */
@Override
public int getEnergyStored(ForgeDirection from) {
return storage.getEnergyStored();
}
@Override
public int getMaxEnergyStored(ForgeDirection from) {
return storage.getMaxEnergyStored();
}
}

View file

@ -2,8 +2,9 @@
* (C) 2014 Team CoFH / CoFH / Cult of the Full Hub
* http://www.teamcofh.com
*/
@API(apiVersion = "1.7.10R1.0.0", owner = "CoFHAPI", provides = "CoFHAPI|energy")
@API(apiVersion = CoFHAPIProps.VERSION, owner = "CoFHAPI", provides = "CoFHAPI|energy")
package cofh.api.energy;
import cofh.api.CoFHAPIProps;
import cpw.mods.fml.common.API;

View file

@ -1,9 +0,0 @@
/**
* (C) 2014 Team CoFH / CoFH / Cult of the Full Hub
* http://www.teamcofh.com
*/
@API(apiVersion = "1.0", owner = "CoFHLib", provides = "CoFHAPI")
package cofh.api;
import cpw.mods.fml.common.API;

View file

@ -154,7 +154,7 @@ public final class ComputerCraftAPI
{
try {
computerCraft_registerBundledRedstoneProvider.invoke( null, handler );
} catch (Exception e){
} catch (Exception e) {
// It failed
}
}
@ -241,7 +241,11 @@ public final class ComputerCraftAPI
private static Method findCCMethod( String name, Class[] args )
{
try {
return computerCraft.getMethod( name, args );
if( computerCraft != null )
{
return computerCraft.getMethod( name, args );
}
return null;
} catch( NoSuchMethodException e ) {
System.out.println( "ComputerCraftAPI: ComputerCraft method " + name + " not found." );
return null;

View file

@ -0,0 +1,10 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2014. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
@API( owner="ComputerCraft", provides="ComputerCraft|API|FileSystem", apiVersion="1.65" )
package dan200.computercraft.api.filesystem;
import cpw.mods.fml.common.API;

View file

@ -22,7 +22,7 @@ public interface ILuaContext
* Do not attempt to common this exception, unless you wish to prevent termination, which is not recommended.
* @throws InterruptedException If the user shuts down or reboots the computercraft while pullEvent() is waiting for an event, InterruptedException will be thrown. This exception must not be caught or intercepted, or the computercraft will leak memory and end up in a broken state.
*/
public Object[] pullEvent( String filter ) throws Exception, InterruptedException;
public Object[] pullEvent( String filter ) throws LuaException, InterruptedException;
/**
* The same as pullEvent(), except "terminated" events are ignored. Only use this if you want to prevent program termination, which is not recommended. This method is exactly equivalent to os.pullEventRaw() in lua.
@ -32,7 +32,6 @@ public interface ILuaContext
* @see #pullEvent(String)
*/
public Object[] pullEventRaw( String filter ) throws InterruptedException;
/**
* Yield the current coroutine with some arguments until it is resumed. This method is exactly equivalent to coroutine.yield() in lua. Use pullEvent() if you wish to wait for events.

View file

@ -22,5 +22,5 @@ public interface ILuaObject
* Called when a user calls one of the methods that this object implements. This works the same as IPeripheral.callMethod(). See that method for detailed documentation.
* @see dan200.computercraft.api.peripheral.IPeripheral#callMethod(dan200.computercraft.api.peripheral.IComputerAccess, ILuaContext, int, Object[])
*/
public Object[] callMethod( ILuaContext context, int method, Object[] arguments ) throws Exception;
public Object[] callMethod( ILuaContext context, int method, Object[] arguments ) throws LuaException, InterruptedException;
}

View file

@ -0,0 +1,31 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2014. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
package dan200.computercraft.api.lua;
/**
* An exception representing an error in Lua, like that raised by the error() function
*/
public class LuaException extends Exception
{
private final int m_level;
public LuaException( String message )
{
this( message, 1 );
}
public LuaException( String message, int level )
{
super( message );
m_level = level;
}
public int getLevel()
{
return m_level;
}
}

View file

@ -0,0 +1,10 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2014. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
@API( owner="ComputerCraft", provides="ComputerCraft|API|Lua", apiVersion="1.65" )
package dan200.computercraft.api.lua;
import cpw.mods.fml.common.API;

View file

@ -0,0 +1,10 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2014. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
@API( owner="ComputerCraft", provides="ComputerCraft|API|Media", apiVersion="1.65" )
package dan200.computercraft.api.media;
import cpw.mods.fml.common.API;

View file

@ -0,0 +1,10 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2014. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
@API( owner="ComputerCraft", provides="ComputerCraft|API", apiVersion="1.65" )
package dan200.computercraft.api;
import cpw.mods.fml.common.API;

View file

@ -28,7 +28,12 @@ public interface IComputerAccess
* @see dan200.computercraft.api.filesystem.IMount
*/
public String mount( String desiredLocation, IMount mount );
/**
* TODO: Document me
*/
public String mount( String desiredLocation, IMount mount, String driveName );
/**
* Mount a mount onto the computers' file system in a writable mode.<br>
* @param desiredLocation The location on the computercraft's file system where you would like the mount to be mounted.
@ -41,7 +46,12 @@ public interface IComputerAccess
* @see IMount
*/
public String mountWritable( String desiredLocation, IWritableMount mount );
/**
* TODO: Document me
*/
public String mountWritable( String desiredLocation, IWritableMount mount, String driveName );
/**
* Unmounts a directory previously mounted onto the computers file system by mount() or mountWritable().<br>
* When a directory is unmounted, it will disappear from the computers file system, and the user will no longer be able to

View file

@ -7,6 +7,7 @@
package dan200.computercraft.api.peripheral;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.lua.LuaException;
/**
* The interface that defines a peripheral. This should be implemented by the
@ -59,7 +60,7 @@ public interface IPeripheral
* arguments are supplied to your method.
* @see #getMethodNames
*/
public Object[] callMethod( IComputerAccess computer, ILuaContext context, int method, Object[] arguments ) throws Exception;
public Object[] callMethod( IComputerAccess computer, ILuaContext context, int method, Object[] arguments ) throws LuaException, InterruptedException;
/**
* Is called when canAttachToSide has returned true, and a computercraft is attaching to the peripheral.

View file

@ -0,0 +1,10 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2014. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
@API( owner="ComputerCraft", provides="ComputerCraft|API|Peripheral", apiVersion="1.65" )
package dan200.computercraft.api.peripheral;
import cpw.mods.fml.common.API;

View file

@ -0,0 +1,10 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2014. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
@API( owner="ComputerCraft", provides="ComputerCraft|API|Redstone", apiVersion="1.65" )
package dan200.computercraft.api.redstone;
import cpw.mods.fml.common.API;

View file

@ -7,6 +7,7 @@
package dan200.computercraft.api.turtle;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.lua.LuaException;
import dan200.computercraft.api.peripheral.IPeripheral;
import net.minecraft.inventory.IInventory;
import net.minecraft.nbt.NBTTagCompound;
@ -119,7 +120,7 @@ public interface ITurtleAccess
* unchanged if called from a peripheral method.
* @see ITurtleCommand
*/
public Object[] executeCommand( ILuaContext context, ITurtleCommand command ) throws Exception;
public Object[] executeCommand( ILuaContext context, ITurtleCommand command ) throws LuaException, InterruptedException;
/**
* TODO: Document me

View file

@ -8,7 +8,7 @@ package dan200.computercraft.api.turtle;
/**
* An interface for objects executing custom turtle commands, used with ITurtleAccess.issueCommand
* @see ITurtleAccess#issueCommand(ITurtleCommand)
* @see ITurtleAccess#executeCommand(dan200.computercraft.api.lua.ILuaContext,ITurtleCommand)
*/
public interface ITurtleCommand
{
@ -18,7 +18,7 @@ public interface ITurtleCommand
* failure with an error message to indicate the command cannot be executed at this time.
* @param turtle access to the turtle for whom the command was issued
* @return TurtleCommandResult.success() or TurtleCommandResult.failure( errorMessage )
* @see ITurtleAccess#issueCommand(ITurtleCommand)
* @see ITurtleAccess#executeCommand(dan200.computercraft.api.lua.ILuaContext,ITurtleCommand)
* @see dan200.computercraft.api.turtle.TurtleCommandResult
*/
public TurtleCommandResult execute( ITurtleAccess turtle );

View file

@ -13,7 +13,7 @@ import net.minecraft.util.IIcon;
/**
* The primary interface for defining an turtle for Turtles. A turtle turtle
* can either be a new tool, or a new peripheral.
* @see dan200.computercraft.api.ComputerCraftAPI#registerUpgrade( ITurtleUpgrade )
* @see dan200.computercraft.api.ComputerCraftAPI#registerTurtleUpgrade( dan200.computercraft.api.turtle.ITurtleUpgrade )
*/
public interface ITurtleUpgrade
{
@ -24,7 +24,7 @@ public interface ITurtleUpgrade
* The ID must be in the range 64 to 255, as the ID is stored as an 8-bit value,
* and 0-64 is reserved for future use by ComputerCraft. The turtle will
* fail registration if an already used ID is specified.
* @see dan200.computercraft.api.ComputerCraftAPI#registerUpgrade( ITurtleUpgrade )
* @see dan200.computercraft.api.ComputerCraftAPI#registerTurtleUpgrade( dan200.computercraft.api.turtle.ITurtleUpgrade )
*/
public int getUpgradeID();
@ -32,7 +32,7 @@ public interface ITurtleUpgrade
* Return a String to describe this type of turtle in turtle item names.
* Examples of built-in adjectives are "Wireless", "Mining" and "Crafty".
*/
public String getAdjective();
public String getUnlocalisedAdjective();
/**
* Return whether this turtle adds a tool or a peripheral to the turtle.
@ -78,12 +78,12 @@ public interface ITurtleUpgrade
public TurtleCommandResult useTool( ITurtleAccess turtle, TurtleSide side, TurtleVerb verb, int direction );
/**
* Called to obtain the Icon to be used when rendering a turtle peripheral. Needs to be a "common"
* type Icon for now, as there is no way to determine which texture sheet an Icon is from by the
* Icon itself.
* Called to obtain the IIcon to be used when rendering a turtle peripheral. Needs to be a "common"
* type IIcon for now, as there is no way to determine which texture sheet an IIcon is from by the
* IIcon itself.
* @param turtle Access to the turtle that the peripheral resides on.
* @param side Which side of the turtle (left or right) the peripheral resides on.
* @return The Icon that you wish to be used to render your turtle peripheral.
* @return The IIcon that you wish to be used to render your turtle peripheral.
*/
public IIcon getIcon( ITurtleAccess turtle, TurtleSide side );

View file

@ -8,12 +8,24 @@ package dan200.computercraft.api.turtle;
public final class TurtleCommandResult
{
private static final TurtleCommandResult s_success = new TurtleCommandResult( true, null );
private static final TurtleCommandResult s_emptyFailure = new TurtleCommandResult( false, null );
private static final TurtleCommandResult s_success = new TurtleCommandResult( true, null, null );
private static final TurtleCommandResult s_emptyFailure = new TurtleCommandResult( false, null, null );
public static TurtleCommandResult success()
{
return s_success;
return success( null );
}
public static TurtleCommandResult success( Object[] results )
{
if( results == null || results.length == 0 )
{
return s_success;
}
else
{
return new TurtleCommandResult( true, null, results );
}
}
public static TurtleCommandResult failure()
@ -23,23 +35,25 @@ public final class TurtleCommandResult
public static TurtleCommandResult failure( String errorMessage )
{
if( errorMessage != null )
if( errorMessage == null )
{
return new TurtleCommandResult( false, errorMessage );
return s_emptyFailure;
}
else
{
return s_emptyFailure;
return new TurtleCommandResult( false, errorMessage, null );
}
}
private final boolean m_success;
private final String m_errorMessage;
private final Object[] m_results;
private TurtleCommandResult( boolean success, String errorMessage )
private TurtleCommandResult( boolean success, String errorMessage, Object[] results )
{
m_success = success;
m_errorMessage = errorMessage;
m_results = results;
}
public boolean isSuccess()
@ -51,4 +65,9 @@ public final class TurtleCommandResult
{
return m_errorMessage;
}
public Object[] getResults()
{
return m_results;
}
}

View file

@ -0,0 +1,4 @@
@API( owner="ComputerCraft", provides="ComputerCraft|API|Turtle", apiVersion="1.65" )
package dan200.computercraft.api.turtle;
import cpw.mods.fml.common.API;

View file

@ -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();
}

View file

@ -2,17 +2,17 @@ package micdoodle8.mods.galacticraft.api.world;
/**
* Used to change the solar multiplier of certain world providers
*
* <p/>
* If you have a solar feature in your mod, check whether the world's provider
* inherits this class and multiply the solar generation by the solar multiplier
* double
*
* <p/>
* for example:
*
* <p/>
* if (worldObj.provider instanceof ISolarLevel) solarStrength *= ((ISolarLevel)
* worldObj.provider).getSolarEnergyMultiplier();
*/
public interface ISolarLevel
{
public double getSolarEnergyMultiplier();
public double getSolarEnergyMultiplier();
}

View file

@ -89,6 +89,7 @@ import mekanism.common.tile.TileEntityRotaryCondensentrator;
import mekanism.common.tile.TileEntitySalinationController;
import mekanism.common.tile.TileEntitySeismicVibrator;
import mekanism.common.tile.TileEntityTeleporter;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Blocks;
@ -207,8 +208,8 @@ public class CommonProxy
general.userWorldGenVersion = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "WorldRegenVersion", 0).getInt();
general.FROM_IC2 = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "JoulesToEU", 10D).getDouble(10D);
general.TO_IC2 = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "EUToJoules", .1D).getDouble(.1D);
general.FROM_BC = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "JoulesToMJ", 25D).getDouble(25D);
general.TO_BC = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "MJToJoules", .04D).getDouble(.04D);
general.FROM_TE = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "JoulesToRF", 2.5D).getDouble(2.5D);
general.TO_TE = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "RFToJoules", 0.4D).getDouble(0.4D);
general.FROM_H2 = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "HydrogenEnergyDensity", 200D, "Determines Electrolytic Separator usage").getDouble(200D);
general.ENERGY_PER_REDSTONE = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "EnergyPerRedstone", 10000D).getDouble(10000D);
general.VOICE_PORT = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "VoicePort", 36123, null, 1, 65535).getInt();
@ -216,7 +217,6 @@ public class CommonProxy
general.maxUpgradeMultiplier = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "UpgradeModifier", 10, null, 1, Integer.MAX_VALUE).getInt();
general.minerSilkMultiplier = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "MinerSilkMultiplier", 6).getDouble();
general.blacklistBC = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "BlacklistBuildCraftPower", false).getBoolean();
general.blacklistIC2 = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "BlacklistIC2Power", false).getBoolean();
general.blacklistRF = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "BlacklistRFPower", false).getBoolean();
@ -242,9 +242,6 @@ public class CommonProxy
}
}
general.TO_TE = general.TO_BC*10;
general.FROM_TE = general.FROM_BC/10;
general.laserRange = Mekanism.configuration.get("general", "LaserRange", 64).getInt(64);
general.laserEnergyNeededPerHardness = Mekanism.configuration.get("general", "LaserDiggingEnergy", 100000).getInt(100000);

View file

@ -26,9 +26,7 @@ import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.eventhandler.Event;
import buildcraft.api.mj.IBatteryObject;
import buildcraft.api.mj.MjAPI;
import cofh.api.energy.IEnergyHandler;
import cofh.api.energy.IEnergyReceiver;
import ic2.api.energy.EnergyNet;
import ic2.api.energy.tile.IEnergySink;
@ -157,10 +155,13 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork>
return sent;
}
public synchronized double emit(double energyToSend)
public synchronized double emit(double energyToSend, boolean doEmit)
{
double toUse = Math.min(getEnergyNeeded(), energyToSend);
electricityStored += toUse;
if(doEmit)
{
electricityStored += toUse;
}
return energyToSend-toUse;
}
@ -202,9 +203,9 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork>
{
sent += ((IStrictEnergyAcceptor)acceptor).transferEnergyToAcceptor(side.getOpposite(), currentSending);
}
else if(MekanismUtils.useRF() && acceptor instanceof IEnergyHandler)
else if(MekanismUtils.useRF() && acceptor instanceof IEnergyReceiver)
{
IEnergyHandler handler = (IEnergyHandler)acceptor;
IEnergyReceiver handler = (IEnergyReceiver)acceptor;
int used = handler.receiveEnergy(side.getOpposite(), (int)Math.round(currentSending*general.TO_TE), false);
sent += used*general.FROM_TE;
}
@ -214,12 +215,6 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork>
toSend = Math.min(toSend, ((IEnergySink)acceptor).getDemandedEnergy()*general.FROM_IC2);
sent += (toSend - (((IEnergySink)acceptor).injectEnergy(side.getOpposite(), toSend*general.TO_IC2, 0)*general.FROM_IC2));
}
else if(MekanismUtils.useBuildCraft() && MjAPI.getMjBattery(acceptor, MjAPI.DEFAULT_POWER_FRAMEWORK, side.getOpposite()) != null && !tryAgain)
{
IBatteryObject battery = MjAPI.getMjBattery(acceptor, MjAPI.DEFAULT_POWER_FRAMEWORK, side.getOpposite());
double toSend = battery.addEnergy(Math.min(battery.getEnergyRequested(), currentSending*general.TO_BC));
sent += toSend*general.FROM_BC;
}
if(sent > prev)
{
@ -268,9 +263,9 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork>
}
}
}
else if(MekanismUtils.useRF() && acceptor instanceof IEnergyHandler)
else if(MekanismUtils.useRF() && acceptor instanceof IEnergyReceiver)
{
IEnergyHandler handler = (IEnergyHandler)acceptor;
IEnergyReceiver handler = (IEnergyReceiver)acceptor;
if(handler.canConnectEnergy(side.getOpposite()))
{
@ -298,16 +293,6 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork>
}
}
}
else if(MekanismUtils.useBuildCraft() && MjAPI.getMjBattery(acceptor, MjAPI.DEFAULT_POWER_FRAMEWORK, side.getOpposite()) != null)
{
IBatteryObject battery = MjAPI.getMjBattery(acceptor, MjAPI.DEFAULT_POWER_FRAMEWORK, side.getOpposite());
if(battery.getEnergyRequested() > 0)
{
toReturn.add(acceptor);
break;
}
}
}
}

View file

@ -8,8 +8,8 @@ import mekanism.api.gas.Gas;
import net.minecraftforge.fluids.FluidContainerRegistry;
import cpw.mods.fml.common.ModAPIManager;
import buildcraft.api.fuels.IronEngineFuel;
import buildcraft.api.fuels.IronEngineFuel.Fuel;
import buildcraft.api.fuels.BuildcraftFuelRegistry;
import buildcraft.api.fuels.IFuel;
public class FuelHandler
{
@ -29,7 +29,7 @@ public class FuelHandler
if(ModAPIManager.INSTANCE.hasAPI("BuildCraftAPI|fuels") && gas.hasFluid())
{
Fuel bcFuel = IronEngineFuel.getFuelForFluid(gas.getFluid());
IFuel bcFuel = BuildcraftFuelRegistry.fuel.getFuel(gas.getFluid());
if(bcFuel != null)
{
@ -54,10 +54,10 @@ public class FuelHandler
energyPerTick = energyDensity / duration;
}
public FuelGas(Fuel bcFuel)
public FuelGas(IFuel bcFuel)
{
burnTicks = bcFuel.totalBurningTime / FluidContainerRegistry.BUCKET_VOLUME;
energyPerTick = bcFuel.powerPerCycle * general.FROM_BC;
burnTicks = bcFuel.getTotalBurningTime() / FluidContainerRegistry.BUCKET_VOLUME;
energyPerTick = bcFuel.getPowerPerCycle() * general.FROM_TE;
}
}
}

View file

@ -11,18 +11,16 @@ 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;
import ic2.api.energy.tile.IEnergySink;
@InterfaceList({
@Interface(iface = "buildcraft.api.power.IPowerReceptor", modid = "BuildCraftAPI|power"),
@Interface(iface = "ic2.api.energy.tile.IEnergySink", modid = "IC2"),
@Interface(iface = "cofh.api.energy.IEnergyHandler", modid = "CoFHAPI|energy"),
@Interface(iface = "dan200.computercraft.api.peripheral.IPeripheral", modid = "ComputerCraft")
})
public interface IAdvancedBoundingBlock extends IBoundingBlock, ISidedInventory, IEnergySink, IStrictEnergyAcceptor, IPowerReceptor, IStrictEnergyStorage, IEnergyHandler, IPeripheral, IFilterAccess, IConfigurable
public interface IAdvancedBoundingBlock extends IBoundingBlock, ISidedInventory, IEnergySink, IStrictEnergyAcceptor, IStrictEnergyStorage, IEnergyHandler, IPeripheral, IFilterAccess, IConfigurable
{
public int[] getBoundSlots(Coord4D location, int side);

View file

@ -39,7 +39,6 @@ public class MultipartMekanism implements IPartFactory
MultipartGenerator.registerPassThroughInterface("mekanism.api.energy.IStrictEnergyAcceptor");
MultipartGenerator.registerPassThroughInterface("mekanism.api.transmitters.IGridTransmitter");
MultipartGenerator.registerPassThroughInterface("mekanism.common.base.ILogisticalTransporter");
MultipartGenerator.registerPassThroughInterface("buildcraft.api.power.IPowerReceptor");
MultipartGenerator.registerPassThroughInterface("cofh.api.energy.IEnergyHandler");
MultipartGenerator.registerPassThroughInterface("mekanism.api.IConfigurable");
MultipartGenerator.registerPassThroughInterface("mekanism.common.base.ITileNetwork");

View file

@ -44,6 +44,8 @@ import cpw.mods.fml.relauncher.SideOnly;
import io.netty.buffer.ByteBuf;
import buildcraft.api.gates.IGate;
import buildcraft.api.transport.IPipe;
import buildcraft.api.transport.IPipeTile;
import buildcraft.api.transport.PipeWire;
import codechicken.lib.vec.Vector3;
@ -63,6 +65,8 @@ public class PartLogisticalTransporter extends PartTransmitter<InventoryNetwork>
public Set<TransporterStack> needsSync = new HashSet<TransporterStack>();
public TransporterPipeProxy pipe = new TransporterPipeProxy();
@Override
public String getType()
{
@ -651,6 +655,11 @@ public class PartLogisticalTransporter extends PartTransmitter<InventoryNetwork>
return PipeType.ITEM;
}
@Override
public int injectItem(ItemStack stack, boolean doAdd, ForgeDirection from, buildcraft.api.core.EnumColor color) {
return 0;
}
@Override
public int injectItem(ItemStack stack, boolean doAdd, ForgeDirection from)
{
@ -665,12 +674,6 @@ public class PartLogisticalTransporter extends PartTransmitter<InventoryNetwork>
return 0;
}
@Override
public boolean isPipeConnected(ForgeDirection with)
{
return true;
}
@Override
protected boolean onConfigure(EntityPlayer player, int part, int side)
{
@ -754,9 +757,65 @@ public class PartLogisticalTransporter extends PartTransmitter<InventoryNetwork>
@Override
@Method(modid = "BuildCraftAPI|transport")
public boolean isWireActive(PipeWire wire)
public boolean isPipeConnected(ForgeDirection with)
{
return false;
return connectionMapContainsSide(getAllCurrentConnections(), with);
}
@Override
@Method(modid = "BuildCraftAPI|transport")
public TileEntity getAdjacentTile(ForgeDirection dir) {
return Coord4D.get(tile()).getFromSide(dir).getTileEntity(world());
}
@Override
@Method(modid = "BuildCraftAPI|transport")
public IPipe getPipe() {
return pipe;
}
public class TransporterPipeProxy implements IPipe
{
@Override
public int x() {
return PartLogisticalTransporter.this.x();
}
@Override
public int y() {
return PartLogisticalTransporter.this.y();
}
@Override
public int z() {
return PartLogisticalTransporter.this.y();
}
@Override
public IPipeTile getTile() {
return (IPipeTile)tile();
}
@Override
public IGate getGate(ForgeDirection side) {
return null;
}
@Override
public boolean hasGate(ForgeDirection side) {
return false;
}
@Override
public boolean isWired(PipeWire wire) {
return false;
}
@Override
public boolean isWireActive(PipeWire wire) {
return false;
}
}
@Override

View file

@ -18,7 +18,6 @@ import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
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;
@ -26,24 +25,17 @@ import cpw.mods.fml.common.Optional.Method;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import buildcraft.api.power.IPowerReceptor;
import buildcraft.api.power.PowerHandler;
import buildcraft.api.power.PowerHandler.PowerReceiver;
import codechicken.lib.vec.Vector3;
import cofh.api.energy.IEnergyHandler;
import ic2.api.energy.tile.IEnergySource;
@InterfaceList({
@Interface(iface = "cofh.api.energy.IEnergyHandler", modid = "CoFHAPI|energy"),
@Interface(iface = "buildcraft.api.power.IPowerReceptor", modid = "BuildCraftAPI|power"),
})
public class PartUniversalCable extends PartTransmitter<EnergyNetwork> implements IStrictEnergyAcceptor, IEnergyHandler, IPowerReceptor
public class PartUniversalCable extends PartTransmitter<EnergyNetwork> implements IStrictEnergyAcceptor, IEnergyHandler
{
public Tier.CableTier tier;
/** A fake power handler used to initiate energy transfer calculations. */
public PowerHandler powerHandler;
public static TransmitterIcons cableIcons = new TransmitterIcons(4, 2);
public double currentPower = 0;
@ -54,11 +46,6 @@ public class PartUniversalCable extends PartTransmitter<EnergyNetwork> implement
public PartUniversalCable(Tier.CableTier cableTier)
{
tier = cableTier;
if(MekanismUtils.useBuildCraft())
{
configure();
}
}
@Override
@ -111,7 +98,7 @@ public class PartUniversalCable extends PartTransmitter<EnergyNetwork> implement
if(received > 0)
{
toDraw -= getTransmitterNetwork().emit(received);
toDraw -= getTransmitterNetwork().emit(received, true);
}
((IEnergySource)acceptor).drawEnergy(toDraw*general.TO_IC2);
@ -130,17 +117,6 @@ public class PartUniversalCable extends PartTransmitter<EnergyNetwork> implement
return EnergyNetwork.round(getTransmitterNetwork().electricityStored*(1F/getTransmitterNetwork().transmitters.size()));
}
@Override
public void refreshTransmitterNetwork()
{
super.refreshTransmitterNetwork();
if(MekanismUtils.useBuildCraft())
{
reconfigure();
}
}
@Override
public TransmitterType getTransmitter()
{
@ -279,12 +255,7 @@ public class PartUniversalCable extends PartTransmitter<EnergyNetwork> implement
@Method(modid = "CoFHAPI|energy")
public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate)
{
if(!simulate)
{
return maxReceive - (int)Math.round(getTransmitterNetwork().emit(maxReceive* general.FROM_TE)* general.TO_TE);
}
return 0;
return maxReceive - (int)Math.round(getTransmitterNetwork().emit(maxReceive * general.FROM_TE, !simulate)*general.TO_TE);
}
@Override
@ -298,7 +269,7 @@ public class PartUniversalCable extends PartTransmitter<EnergyNetwork> implement
@Method(modid = "CoFHAPI|energy")
public boolean canConnectEnergy(ForgeDirection from)
{
return canReceiveEnergy(from);
return canConnect(from);
}
@Override
@ -358,51 +329,4 @@ public class PartUniversalCable extends PartTransmitter<EnergyNetwork> implement
{
getTransmitterNetwork().electricityStored = energy;
}
@Override
@Method(modid = "BuildCraftAPI|power")
public PowerReceiver getPowerReceiver(ForgeDirection side)
{
if(getTransmitterNetwork().getEnergyNeeded() == 0)
{
return null;
}
return powerHandler.getPowerReceiver();
}
@Override
@Method(modid = "BuildCraftAPI|power")
public World getWorld()
{
return world();
}
@Method(modid = "BuildCraftAPI|power")
private void configure()
{
powerHandler = new PowerHandler(this, PowerHandler.Type.STORAGE);
powerHandler.configurePowerPerdition(0, 0);
powerHandler.configure(0, 0, 0, 0);
}
@Method(modid = "BuildCraftAPI|power")
private void reconfigure()
{
float needed = (float)(getTransmitterNetwork().getEnergyNeeded()*general.TO_BC);
powerHandler.configure(1, needed, 0, needed);
}
@Override
@Method(modid = "BuildCraftAPI|power")
public void doWork(PowerHandler workProvider)
{
if(powerHandler.getEnergyStored() > 0)
{
getTransmitterNetwork().emit(powerHandler.getEnergyStored()*general.FROM_BC);
}
powerHandler.setEnergy(0);
reconfigure();
}
}

View file

@ -41,15 +41,14 @@ public class PacketConfigSync implements IMessageHandler<ConfigSyncMessage, IMes
dataStream.writeInt(general.UPDATE_DELAY);
dataStream.writeDouble(general.FROM_IC2);
dataStream.writeDouble(general.TO_IC2);
dataStream.writeDouble(general.FROM_BC);
dataStream.writeDouble(general.TO_BC);
dataStream.writeDouble(general.FROM_TE);
dataStream.writeDouble(general.TO_TE);
dataStream.writeDouble(general.FROM_H2);
dataStream.writeDouble(general.ENERGY_PER_REDSTONE);
dataStream.writeInt(general.VOICE_PORT);
dataStream.writeInt(general.maxUpgradeMultiplier);
dataStream.writeInt(general.activeType.ordinal());
dataStream.writeDouble(general.minerSilkMultiplier);
dataStream.writeBoolean(general.blacklistBC);
dataStream.writeBoolean(general.blacklistIC2);
dataStream.writeBoolean(general.blacklistRF);
@ -101,21 +100,17 @@ public class PacketConfigSync implements IMessageHandler<ConfigSyncMessage, IMes
general.UPDATE_DELAY = dataStream.readInt();
general.FROM_IC2 = dataStream.readDouble();
general.TO_IC2 = dataStream.readDouble();
general.FROM_BC = dataStream.readDouble();
general.TO_BC = dataStream.readDouble();
general.FROM_TE = dataStream.readDouble();
general.TO_TE = dataStream.readDouble();
general.FROM_H2 = dataStream.readDouble();
general.ENERGY_PER_REDSTONE = dataStream.readDouble();
general.VOICE_PORT = dataStream.readInt();
general.maxUpgradeMultiplier = dataStream.readInt();
general.activeType = EnergyType.values()[dataStream.readInt()];
general.minerSilkMultiplier = dataStream.readDouble();
general.blacklistBC = dataStream.readBoolean();
general.blacklistIC2 = dataStream.readBoolean();
general.blacklistRF = dataStream.readBoolean();
general.TO_TE = general.TO_BC*10;
general.FROM_TE = general.FROM_BC/10;
usage.enrichmentChamberUsage = dataStream.readDouble();
usage.osmiumCompressorUsage = dataStream.readDouble();
usage.combinerUsage = dataStream.readDouble();

View file

@ -12,28 +12,24 @@ import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
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;
import cofh.api.energy.IEnergyHandler;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.lua.LuaException;
import dan200.computercraft.api.peripheral.IComputerAccess;
import dan200.computercraft.api.peripheral.IPeripheral;
import ic2.api.energy.tile.IEnergySink;
@InterfaceList({
@Interface(iface = "buildcraft.api.power.IPowerReceptor", modid = "BuildCraftAPI|power"),
@Interface(iface = "ic2.api.energy.tile.IEnergySink", modid = "IC2"),
@Interface(iface = "cofh.api.energy.IEnergyHandler", modid = "CoFHAPI|energy"),
@Interface(iface = "dan200.computercraft.api.peripheral.IPeripheral", modid = "ComputerCraft")
})
public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock implements ISidedInventory, IEnergySink, IPowerReceptor, IStrictEnergyAcceptor, IEnergyHandler, IPeripheral, IFilterAccess, IConfigurable
public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock implements ISidedInventory, IEnergySink, IStrictEnergyAcceptor, IEnergyHandler, IPeripheral, IFilterAccess, IConfigurable
{
@Override
public int getSizeInventory()
@ -300,42 +296,6 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp
return getInv().getMaxEnergy();
}
@Override
@Method(modid = "BuildCraftAPI|power")
public PowerReceiver getPowerReceiver(ForgeDirection side)
{
if(getInv() == null)
{
return new PowerHandler(this, PowerHandler.Type.STORAGE).getPowerReceiver();
}
return getInv().getPowerReceiver(side);
}
@Override
@Method(modid = "BuildCraftAPI|power")
public void doWork(PowerHandler workProvider)
{
if(getInv() == null)
{
return;
}
getInv().doWork(workProvider);
}
@Override
@Method(modid = "BuildCraftAPI|power")
public World getWorld()
{
if(getInv() == null)
{
return worldObj;
}
return getInv().getWorld();
}
@Override
public double transferEnergyToAcceptor(ForgeDirection side, double amount)
{
@ -460,7 +420,7 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp
@Override
@Method(modid = "ComputerCraft")
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws Exception
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws LuaException, InterruptedException
{
if(getInv() == null)
{

View file

@ -3,6 +3,7 @@ package mekanism.common.tile;
import java.util.ArrayList;
import mekanism.api.EnumColor;
import mekanism.api.StackUtils;
import mekanism.api.gas.Gas;
import mekanism.api.gas.GasStack;
import mekanism.api.gas.GasTank;
@ -31,6 +32,7 @@ import cpw.mods.fml.common.Optional.Method;
import io.netty.buffer.ByteBuf;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.lua.LuaException;
import dan200.computercraft.api.peripheral.IComputerAccess;
public abstract class TileEntityAdvancedElectricMachine<RECIPE extends AdvancedMachineRecipe<RECIPE>> extends TileEntityBasicMachine<AdvancedMachineInput, ItemStackOutput, RECIPE> implements IGasHandler, ITubeConnection
@ -341,7 +343,7 @@ public abstract class TileEntityAdvancedElectricMachine<RECIPE extends AdvancedM
@Override
@Method(modid = "ComputerCraft")
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws Exception
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws LuaException, InterruptedException
{
switch(method)
{

View file

@ -20,6 +20,7 @@ import net.minecraft.util.ResourceLocation;
import cpw.mods.fml.common.Optional.Method;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.lua.LuaException;
import dan200.computercraft.api.peripheral.IComputerAccess;
@ -168,7 +169,7 @@ public abstract class TileEntityChanceMachine<RECIPE extends ChanceMachineRecipe
@Override
@Method(modid = "ComputerCraft")
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws Exception
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws LuaException, InterruptedException
{
return null;
}

View file

@ -60,6 +60,7 @@ import cpw.mods.fml.relauncher.SideOnly;
import io.netty.buffer.ByteBuf;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.lua.LuaException;
import dan200.computercraft.api.peripheral.IComputerAccess;
import dan200.computercraft.api.peripheral.IPeripheral;
@ -1219,7 +1220,7 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I
@Override
@Method(modid = "ComputerCraft")
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws Exception
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws LuaException, InterruptedException
{
if(arguments.length > 0)
{

View file

@ -1,15 +1,5 @@
package mekanism.common.tile;
import ic2.api.energy.EnergyNet;
import ic2.api.energy.event.EnergyTileLoadEvent;
import ic2.api.energy.event.EnergyTileUnloadEvent;
import ic2.api.energy.tile.IEnergyConductor;
import ic2.api.energy.tile.IEnergySink;
import ic2.api.energy.tile.IEnergySource;
import ic2.api.energy.tile.IEnergyTile;
import ic2.api.tile.IEnergyStorage;
import io.netty.buffer.ByteBuf;
import java.util.ArrayList;
import java.util.EnumSet;
@ -23,29 +13,33 @@ import mekanism.common.Upgrade;
import mekanism.common.base.ITileNetwork;
import mekanism.common.base.IUpgradeTile;
import mekanism.common.util.MekanismUtils;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.ForgeDirection;
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;
import cpw.mods.fml.common.Optional.Interface;
import cpw.mods.fml.common.Optional.InterfaceList;
import cpw.mods.fml.common.Optional.Method;
import io.netty.buffer.ByteBuf;
import cofh.api.energy.IEnergyHandler;
import ic2.api.energy.EnergyNet;
import ic2.api.energy.event.EnergyTileLoadEvent;
import ic2.api.energy.event.EnergyTileUnloadEvent;
import ic2.api.energy.tile.IEnergyConductor;
import ic2.api.energy.tile.IEnergySink;
import ic2.api.energy.tile.IEnergySource;
import ic2.api.energy.tile.IEnergyTile;
import ic2.api.tile.IEnergyStorage;
@InterfaceList({
@Interface(iface = "ic2.api.energy.tile.IEnergySink", modid = "IC2"),
@Interface(iface = "ic2.api.tile.IEnergyStorage", modid = "IC2"),
@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, IEnergySource, IEnergyStorage, IStrictEnergyAcceptor, ICableOutputter
public abstract class TileEntityElectricBlock extends TileEntityContainerBlock implements ITileNetwork, IStrictEnergyStorage, IEnergyHandler, IEnergySink, IEnergySource, IEnergyStorage, IStrictEnergyAcceptor, ICableOutputter
{
/** How much energy is stored in this block. */
public double electricityStored;
@ -56,9 +50,6 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
/** Actual maximum energy storage, including upgrades */
public double maxEnergy;
/** BuildCraft power handler. */
public PowerHandler powerHandler;
/** Is this registered with IC2 */
public boolean ic2Registered = false;
@ -73,22 +64,8 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
super(name);
BASE_MAX_ENERGY = baseMaxEnergy;
maxEnergy = BASE_MAX_ENERGY;
if(MekanismUtils.useBuildCraft())
{
configure();
}
}
@Method(modid = "BuildCraftAPI|power")
public void configure()
{
powerHandler = new PowerHandler(this, PowerHandler.Type.STORAGE);
powerHandler.configurePowerPerdition(0, 0);
powerHandler.configure(0, 0, 0, 0);
}
@Method(modid = "IC2")
public void register()
{
@ -128,11 +105,6 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
@Override
public void onUpdate()
{
if(MekanismUtils.useBuildCraft())
{
reconfigure();
}
if(!ic2Registered && MekanismUtils.useIC2())
{
register();
@ -229,11 +201,6 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
super.readFromNBT(nbtTags);
electricityStored = nbtTags.getDouble("electricityStored");
if(MekanismUtils.useBuildCraft())
{
reconfigure();
}
}
@Override
@ -244,57 +211,6 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
nbtTags.setDouble("electricityStored", getEnergy());
}
@Override
public void recalculateUpgradables(Upgrade upgrade)
{
if(this instanceof IUpgradeTile && upgrade == Upgrade.ENERGY)
{
maxEnergy = MekanismUtils.getMaxEnergy(((IUpgradeTile)this), BASE_MAX_ENERGY);
}
}
@Override
@Method(modid = "BuildCraftAPI|power")
public PowerReceiver getPowerReceiver(ForgeDirection side)
{
if(getConsumingSides().contains(side))
{
return powerHandler.getPowerReceiver();
}
return null;
}
@Method(modid = "BuildCraftAPI|power")
protected void reconfigure()
{
powerHandler.configure(0, (float)((getMaxEnergy()-getEnergy())*general.TO_BC), 0, (float)(getMaxEnergy()*general.TO_BC));
}
@Override
@Method(modid = "BuildCraftAPI|power")
public void doWork(PowerHandler workProvider)
{
if(powerHandler.getEnergyStored() > 0)
{
if(getEnergy() < getMaxEnergy())
{
setEnergy(getEnergy() + powerHandler.useEnergy(0, (float)((getMaxEnergy()-getEnergy())* general.TO_BC), true)* general.FROM_BC);
}
powerHandler.setEnergy(0);
}
reconfigure();
}
@Override
@Method(modid = "BuildCraftAPI|power")
public World getWorld()
{
return worldObj;
}
/**
* Gets the scaled energy level for the GUI.
* @param i - multiplier
@ -500,11 +416,4 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
return toUse;
}
@Override
@Method(modid = "BuildCraftAPI|power")
public boolean canEmitPowerFrom(ForgeDirection side)
{
return getOutputtingSides().contains(side);
}
}

View file

@ -19,6 +19,7 @@ import net.minecraft.item.ItemStack;
import cpw.mods.fml.common.Optional.Method;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.lua.LuaException;
import dan200.computercraft.api.peripheral.IComputerAccess;
public abstract class TileEntityElectricMachine<RECIPE extends BasicMachineRecipe<RECIPE>> extends TileEntityBasicMachine<ItemStackInput, ItemStackOutput, RECIPE>
@ -173,7 +174,7 @@ public abstract class TileEntityElectricMachine<RECIPE extends BasicMachineRecip
@Override
@Method(modid = "ComputerCraft")
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws Exception
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws LuaException, InterruptedException
{
switch(method)
{

View file

@ -44,6 +44,7 @@ import cpw.mods.fml.common.Optional.Method;
import io.netty.buffer.ByteBuf;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.lua.LuaException;
import dan200.computercraft.api.peripheral.IComputerAccess;
import dan200.computercraft.api.peripheral.IPeripheral;
@ -493,7 +494,7 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp
@Override
@Method(modid = "ComputerCraft")
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws Exception
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws LuaException, InterruptedException
{
switch(method)
{

View file

@ -24,6 +24,7 @@ import cpw.mods.fml.common.Optional.Method;
import io.netty.buffer.ByteBuf;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.lua.LuaException;
import dan200.computercraft.api.peripheral.IComputerAccess;
import dan200.computercraft.api.peripheral.IPeripheral;
@ -170,7 +171,7 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements IPe
@Override
@Method(modid = "ComputerCraft")
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws Exception
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws LuaException, InterruptedException
{
switch(method)
{

View file

@ -8,6 +8,7 @@ import mekanism.api.EnumColor;
import mekanism.api.MekanismConfig.general;
import mekanism.api.MekanismConfig.usage;
import mekanism.api.Range4D;
import mekanism.api.StackUtils;
import mekanism.api.gas.Gas;
import mekanism.api.gas.GasStack;
import mekanism.api.gas.GasTank;
@ -48,6 +49,7 @@ import cpw.mods.fml.common.Optional.Method;
import io.netty.buffer.ByteBuf;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.lua.LuaException;
import dan200.computercraft.api.peripheral.IComputerAccess;
import dan200.computercraft.api.peripheral.IPeripheral;
@ -720,7 +722,7 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
@Override
@Method(modid = "ComputerCraft")
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws Exception
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws LuaException, InterruptedException
{
switch(method)
{

View file

@ -39,6 +39,7 @@ import cpw.mods.fml.common.Optional.Method;
import io.netty.buffer.ByteBuf;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.lua.LuaException;
import dan200.computercraft.api.peripheral.IComputerAccess;
import dan200.computercraft.api.peripheral.IPeripheral;
@ -397,7 +398,7 @@ public class TileEntityMetallurgicInfuser extends TileEntityNoisyElectricBlock i
@Override
@Method(modid = "ComputerCraft")
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws Exception
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws LuaException, InterruptedException
{
switch(method)
{

View file

@ -43,6 +43,7 @@ import cpw.mods.fml.common.Optional.Method;
import io.netty.buffer.ByteBuf;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.lua.LuaException;
import dan200.computercraft.api.peripheral.IComputerAccess;
public class TileEntityPRC extends TileEntityBasicMachine<PressurizedInput, PressurizedProducts, PressurizedRecipe> implements IFluidHandler, IGasHandler, ITubeConnection, ISustainedData
@ -307,7 +308,7 @@ public class TileEntityPRC extends TileEntityBasicMachine<PressurizedInput, Pres
@Override
@Method(modid = "ComputerCraft")
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws Exception
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws LuaException, InterruptedException
{
return null;
}

View file

@ -38,6 +38,7 @@ import cpw.mods.fml.relauncher.SideOnly;
import io.netty.buffer.ByteBuf;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.lua.LuaException;
import dan200.computercraft.api.peripheral.IComputerAccess;
import dan200.computercraft.api.peripheral.IPeripheral;
@ -541,7 +542,7 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe
@Override
@Method(modid = "ComputerCraft")
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws Exception
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws LuaException, InterruptedException
{
switch(method)
{

View file

@ -16,11 +16,9 @@ import mekanism.common.tile.TileEntityElectricBlock;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.mj.IBatteryObject;
import buildcraft.api.mj.MjAPI;
import buildcraft.api.power.IPowerEmitter;
import cofh.api.energy.IEnergyConnection;
import cofh.api.energy.IEnergyHandler;
import cofh.api.energy.IEnergyProvider;
import cofh.api.energy.IEnergyReceiver;
import ic2.api.energy.EnergyNet;
import ic2.api.energy.tile.IEnergyAcceptor;
import ic2.api.energy.tile.IEnergySink;
@ -56,8 +54,7 @@ public final class CableUtils
{
return (tileEntity instanceof IStrictEnergyAcceptor ||
(MekanismUtils.useIC2() && tileEntity instanceof IEnergySink) ||
(MekanismUtils.useBuildCraft() && MjAPI.getMjBattery(tileEntity) != null && !(tileEntity instanceof IGridTransmitter)) ||
(MekanismUtils.useRF() && tileEntity instanceof IEnergyHandler));
(MekanismUtils.useRF() && tileEntity instanceof IEnergyReceiver));
}
/**
@ -146,9 +143,7 @@ public final class CableUtils
{
return (tileEntity instanceof ICableOutputter && ((ICableOutputter)tileEntity).canOutputTo(side.getOpposite())) ||
(MekanismUtils.useIC2() && tileEntity instanceof IEnergySource && ((IEnergySource)tileEntity).emitsEnergyTo(null, side.getOpposite())) ||
(MekanismUtils.useRF() && tileEntity instanceof IEnergyHandler && ((IEnergyHandler)tileEntity).canConnectEnergy(side.getOpposite())) ||
(MekanismUtils.useRF() && tileEntity instanceof IEnergyConnection && ((IEnergyConnection)tileEntity).canConnectEnergy(side.getOpposite())) ||
(MekanismUtils.useBuildCraft() && tileEntity instanceof IPowerEmitter && ((IPowerEmitter)tileEntity).canEmitPowerFrom(side.getOpposite()));
(MekanismUtils.useRF() && tileEntity instanceof IEnergyProvider && ((IEnergyConnection)tileEntity).canConnectEnergy(side.getOpposite()));
}
/**
@ -197,16 +192,9 @@ public final class CableUtils
return true;
}
}
else if(MekanismUtils.useRF() && tileEntity instanceof IEnergyHandler)
else if(MekanismUtils.useRF() && tileEntity instanceof IEnergyConnection)
{
if(((IEnergyHandler)tileEntity).canConnectEnergy(side.getOpposite()))
{
return true;
}
}
else if(MekanismUtils.useBuildCraft())
{
if(MjAPI.getMjBattery(tileEntity, MjAPI.DEFAULT_POWER_FRAMEWORK, side.getOpposite()) != null)
if(((IEnergyConnection)tileEntity).canConnectEnergy(side.getOpposite()))
{
return true;
}
@ -299,9 +287,9 @@ public final class CableUtils
sent += acceptor.transferEnergyToAcceptor(side.getOpposite(), currentSending);
}
}
else if(MekanismUtils.useRF() && tileEntity instanceof IEnergyHandler)
else if(MekanismUtils.useRF() && tileEntity instanceof IEnergyReceiver)
{
IEnergyHandler handler = (IEnergyHandler)tileEntity;
IEnergyReceiver handler = (IEnergyReceiver)tileEntity;
if(handler.canConnectEnergy(side.getOpposite()))
{
@ -318,12 +306,6 @@ public final class CableUtils
sent += (toSend - (((IEnergySink)tileEntity).injectEnergy(side.getOpposite(), toSend*general.TO_IC2, 0)*general.FROM_IC2));
}
}
else if(MekanismUtils.useBuildCraft() && MjAPI.getMjBattery(tileEntity, MjAPI.DEFAULT_POWER_FRAMEWORK, side.getOpposite()) != null && !tryAgain)
{
IBatteryObject battery = MjAPI.getMjBattery(tileEntity, MjAPI.DEFAULT_POWER_FRAMEWORK, side.getOpposite());
double toSend = battery.addEnergy(Math.min(battery.getEnergyRequested(), currentSending*general.TO_BC));
sent += toSend*general.FROM_BC;
}
return sent;
}

View file

@ -48,6 +48,7 @@ import mekanism.common.network.PacketElectricChest.ElectricChestPacketType;
import mekanism.common.tile.TileEntityAdvancedBoundingBlock;
import mekanism.common.tile.TileEntityBoundingBlock;
import mekanism.common.tile.TileEntityElectricChest;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
@ -1110,7 +1111,7 @@ public final class MekanismUtils
case EU:
return EnergyUtils.getDisplayShort(energy * general.TO_IC2, ElectricUnit.ELECTRICAL_UNITS, 0);
case MJ:
return EnergyUtils.getDisplayShort(energy * general.TO_BC, ElectricUnit.MINECRAFT_JOULES);
return EnergyUtils.getDisplayShort(energy * general.TO_TE / 10, ElectricUnit.MINECRAFT_JOULES);
}
return "error";

View file

@ -20,9 +20,6 @@ import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.power.IPowerReceptor;
import buildcraft.api.power.PowerHandler.Type;
public final class TransporterUtils
{
public static List<EnumColor> colors = ListUtils.asList(EnumColor.DARK_BLUE, EnumColor.DARK_GREEN, EnumColor.DARK_AQUA, EnumColor.DARK_RED, EnumColor.PURPLE,
@ -80,16 +77,6 @@ public final class TransporterUtils
ForgeDirection forgeSide = ForgeDirection.getOrientation(side).getOpposite();
//Immature BuildCraft inv check
if(MekanismUtils.useBuildCraft() && inventory instanceof IPowerReceptor)
{
if(((IPowerReceptor)inventory).getPowerReceiver(forgeSide) != null && ((IPowerReceptor)inventory).getPowerReceiver(forgeSide).getType() == Type.MACHINE)
{
connectable[side] = true;
continue;
}
}
if(inventory.getSizeInventory() > 0)
{
if(inventory instanceof ISidedInventory)

View file

@ -1,7 +1,5 @@
package mekanism.generators.common;
import io.netty.buffer.ByteBuf;
import java.io.IOException;
import mekanism.api.MekanismConfig.general;
@ -22,7 +20,6 @@ import net.minecraft.item.crafting.CraftingManager;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidRegistry;
import buildcraft.api.fuels.IronEngineFuel;
import cpw.mods.fml.client.event.ConfigChangedEvent.OnConfigChangedEvent;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Mod;
@ -36,6 +33,11 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.network.NetworkRegistry;
import io.netty.buffer.ByteBuf;
import buildcraft.api.fuels.BuildcraftFuelRegistry;
import buildcraft.api.fuels.IFuel;
@Mod(modid = "MekanismGenerators", name = "MekanismGenerators", version = "8.0.0", dependencies = "required-after:Mekanism", guiFactory = "mekanism.generators.client.gui.GeneratorsGuiFactory")
public class MekanismGenerators implements IModule
{
@ -85,22 +87,21 @@ public class MekanismGenerators implements IModule
@EventHandler
public void postInit(FMLPostInitializationEvent event)
{
if(ModAPIManager.INSTANCE.hasAPI("BuildCraftAPI|fuels"))
if(ModAPIManager.INSTANCE.hasAPI("BuildCraftAPI|fuels") && BuildcraftFuelRegistry.fuel != null)
{
for(String s : IronEngineFuel.fuels.keySet())
for(IFuel s : BuildcraftFuelRegistry.fuel.getFuels())
{
Fluid f = FluidRegistry.getFluid(s);
if(!(f == null || GasRegistry.containsGas(s)))
if(!(s.getFluid() == null || GasRegistry.containsGas(s.getFluid().getName())))
{
GasRegistry.register(new Gas(f));
GasRegistry.register(new Gas(s.getFluid()));
}
}
IronEngineFuel.addFuel("ethene", (float) (240 * general.TO_BC), 40 * FluidContainerRegistry.BUCKET_VOLUME);
BuildcraftFuelRegistry.fuel.addFuel(FluidRegistry.getFluid("ethene"), (int)(240 * Mekanism.TO_TE), 40 * FluidContainerRegistry.BUCKET_VOLUME);
}
}
public void addRecipes()
{
CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(GeneratorsBlocks.Generator, 1, 0), new Object[] {

View file

@ -25,6 +25,7 @@ import cpw.mods.fml.common.Optional.Method;
import io.netty.buffer.ByteBuf;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.lua.LuaException;
import dan200.computercraft.api.peripheral.IComputerAccess;
public class TileEntityBioGenerator extends TileEntityGenerator implements IFluidHandler, ISustainedData
@ -232,7 +233,7 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements IFlui
@Override
@Method(modid = "ComputerCraft")
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws Exception
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws LuaException, InterruptedException
{
switch(method)
{

View file

@ -26,6 +26,7 @@ import cpw.mods.fml.common.Optional.Method;
import io.netty.buffer.ByteBuf;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.lua.LuaException;
import dan200.computercraft.api.peripheral.IComputerAccess;
public class TileEntityGasGenerator extends TileEntityGenerator implements IGasHandler, ITubeConnection, ISustainedData
@ -172,7 +173,7 @@ public class TileEntityGasGenerator extends TileEntityGenerator implements IGasH
@Override
@Method(modid = "ComputerCraft")
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws Exception
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws LuaException, InterruptedException
{
switch(method)
{

View file

@ -57,11 +57,6 @@ public abstract class TileEntityGenerator extends TileEntityNoisyElectricBlock i
{
super("gen." + soundPath, name, maxEnergy);
if(MekanismUtils.useBuildCraft())
{
powerHandler.configure(0, 0, 0, 0);
}
output = out;
isActive = false;
controlType = RedstoneControl.DISABLED;
@ -259,17 +254,4 @@ public abstract class TileEntityGenerator extends TileEntityNoisyElectricBlock i
controlType = type;
MekanismUtils.saveChunk(this);
}
@Override
public boolean canPulse()
{
return false;
}
@Override
@Method(modid = "BuildCraftAPI|power")
protected void reconfigure()
{
powerHandler.configure(0, 0, 0, 0);
}
}

View file

@ -29,6 +29,7 @@ import cpw.mods.fml.common.Optional.Method;
import io.netty.buffer.ByteBuf;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.lua.LuaException;
import dan200.computercraft.api.peripheral.IComputerAccess;
public class TileEntityHeatGenerator extends TileEntityGenerator implements IFluidHandler, ISustainedData
@ -279,7 +280,7 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements IFlu
@Override
@Method(modid = "ComputerCraft")
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws Exception
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws LuaException, InterruptedException
{
switch(method)
{

View file

@ -17,6 +17,7 @@ import cpw.mods.fml.common.Optional.Method;
import io.netty.buffer.ByteBuf;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.lua.LuaException;
import dan200.computercraft.api.peripheral.IComputerAccess;
import micdoodle8.mods.galacticraft.api.world.ISolarLevel;
@ -152,7 +153,7 @@ public class TileEntitySolarGenerator extends TileEntityGenerator
@Override
@Method(modid = "ComputerCraft")
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws Exception
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws LuaException, InterruptedException
{
switch(method)
{

View file

@ -11,6 +11,7 @@ import net.minecraft.item.ItemStack;
import cpw.mods.fml.common.Optional.Method;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.lua.LuaException;
import dan200.computercraft.api.peripheral.IComputerAccess;
public class TileEntityWindTurbine extends TileEntityGenerator implements IBoundingBlock
@ -82,7 +83,7 @@ public class TileEntityWindTurbine extends TileEntityGenerator implements IBound
@Override
@Method(modid = "ComputerCraft")
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws Exception
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws LuaException, InterruptedException
{
switch(method)
{