Merging with other computer

This commit is contained in:
Aidan Brady 2013-08-08 13:10:11 -04:00
parent db5588ddb9
commit 8996b499e3
59 changed files with 998 additions and 637 deletions

View file

@ -1,9 +1,9 @@
package buildcraft.api.blueprints;
import buildcraft.api.core.BuildCraftAPI;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import buildcraft.api.core.BuildCraftAPI;
@Deprecated
public class BlueprintManager {

View file

@ -9,15 +9,14 @@
package buildcraft.api.blueprints;
import buildcraft.api.core.BuildCraftAPI;
import java.util.ArrayList;
import java.util.LinkedList;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import buildcraft.api.core.BuildCraftAPI;
/**
* This class allow to specify specific behavior for blocks stored in blueprints:

View file

@ -10,7 +10,6 @@
package buildcraft.api.blueprints;
import java.util.LinkedList;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;

View file

@ -10,7 +10,6 @@
package buildcraft.api.blueprints;
import java.util.LinkedList;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;

View file

@ -9,10 +9,10 @@
package buildcraft.api.blueprints;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import buildcraft.api.core.IBox;
import buildcraft.api.core.Position;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
/**
* This interface provide contextual information when building or initializing blueprint slots.

View file

@ -9,13 +9,12 @@
package buildcraft.api.bptblocks;
import java.util.LinkedList;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import buildcraft.api.blueprints.BptBlock;
import buildcraft.api.blueprints.BptSlotInfo;
import buildcraft.api.blueprints.IBptContext;
import java.util.LinkedList;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@Deprecated
public class BptBlockBed extends BptBlock {

View file

@ -9,12 +9,11 @@
package buildcraft.api.bptblocks;
import java.util.LinkedList;
import net.minecraft.item.ItemStack;
import buildcraft.api.blueprints.BptBlock;
import buildcraft.api.blueprints.BptSlotInfo;
import buildcraft.api.blueprints.IBptContext;
import java.util.LinkedList;
import net.minecraft.item.ItemStack;
@Deprecated
public class BptBlockCustomStack extends BptBlock {

View file

@ -9,13 +9,12 @@
package buildcraft.api.bptblocks;
import java.util.LinkedList;
import net.minecraft.item.ItemStack;
import buildcraft.api.blueprints.BlueprintManager;
import buildcraft.api.blueprints.BptBlock;
import buildcraft.api.blueprints.BptSlotInfo;
import buildcraft.api.blueprints.IBptContext;
import java.util.LinkedList;
import net.minecraft.item.ItemStack;
@Deprecated
public class BptBlockDelegate extends BptBlock {

View file

@ -9,13 +9,12 @@
package buildcraft.api.bptblocks;
import java.util.LinkedList;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import buildcraft.api.blueprints.BptBlock;
import buildcraft.api.blueprints.BptSlotInfo;
import buildcraft.api.blueprints.IBptContext;
import java.util.LinkedList;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
@Deprecated
public class BptBlockDirt extends BptBlock {

View file

@ -9,12 +9,11 @@
package buildcraft.api.bptblocks;
import java.util.LinkedList;
import net.minecraft.item.ItemStack;
import buildcraft.api.blueprints.BptBlock;
import buildcraft.api.blueprints.BptSlotInfo;
import buildcraft.api.blueprints.IBptContext;
import java.util.LinkedList;
import net.minecraft.item.ItemStack;
@Deprecated
public class BptBlockDoor extends BptBlock {

View file

@ -9,19 +9,18 @@
package buildcraft.api.bptblocks;
import java.util.LinkedList;
import net.minecraft.item.ItemStack;
import buildcraft.api.blueprints.BptBlock;
import buildcraft.api.blueprints.BptSlotInfo;
import buildcraft.api.blueprints.IBptContext;
import java.util.LinkedList;
import net.minecraft.item.ItemStack;
@Deprecated
public class BptBlockLiquid extends BptBlock {
public class BptBlockFluid extends BptBlock {
private final ItemStack bucketStack;
public BptBlockLiquid(int blockId, ItemStack bucketStack) {
public BptBlockFluid(int blockId, ItemStack bucketStack) {
super(blockId);
this.bucketStack = bucketStack;

View file

@ -9,12 +9,11 @@
package buildcraft.api.bptblocks;
import java.util.LinkedList;
import net.minecraft.item.ItemStack;
import buildcraft.api.blueprints.BptBlock;
import buildcraft.api.blueprints.BptSlotInfo;
import buildcraft.api.blueprints.IBptContext;
import java.util.LinkedList;
import net.minecraft.item.ItemStack;
@Deprecated
public class BptBlockIgnore extends BptBlock {

View file

@ -9,12 +9,11 @@
package buildcraft.api.bptblocks;
import java.util.LinkedList;
import net.minecraft.item.ItemStack;
import buildcraft.api.blueprints.BptBlock;
import buildcraft.api.blueprints.BptSlotInfo;
import buildcraft.api.blueprints.IBptContext;
import java.util.LinkedList;
import net.minecraft.item.ItemStack;
@Deprecated
public class BptBlockIgnoreMeta extends BptBlock {

View file

@ -1,9 +1,9 @@
package buildcraft.api.bptblocks;
import net.minecraft.inventory.IInventory;
import buildcraft.api.blueprints.BptBlock;
import buildcraft.api.blueprints.BptSlotInfo;
import buildcraft.api.blueprints.IBptContext;
import net.minecraft.inventory.IInventory;
@Deprecated
public class BptBlockInventory extends BptBlock {

View file

@ -9,11 +9,10 @@
package buildcraft.api.bptblocks;
import java.util.LinkedList;
import net.minecraft.item.ItemStack;
import buildcraft.api.blueprints.BptSlotInfo;
import buildcraft.api.blueprints.IBptContext;
import java.util.LinkedList;
import net.minecraft.item.ItemStack;
@Deprecated
public class BptBlockLever extends BptBlockWallSide {

View file

@ -9,12 +9,11 @@
package buildcraft.api.bptblocks;
import java.util.LinkedList;
import net.minecraft.item.ItemStack;
import buildcraft.api.blueprints.BptBlock;
import buildcraft.api.blueprints.BptSlotInfo;
import buildcraft.api.blueprints.IBptContext;
import java.util.LinkedList;
import net.minecraft.item.ItemStack;
@Deprecated
public class BptBlockPumpkin extends BptBlock {

View file

@ -9,13 +9,12 @@
package buildcraft.api.bptblocks;
import java.util.LinkedList;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import buildcraft.api.blueprints.BptBlock;
import buildcraft.api.blueprints.BptSlotInfo;
import buildcraft.api.blueprints.IBptContext;
import java.util.LinkedList;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@Deprecated
public class BptBlockRedstoneRepeater extends BptBlock {

View file

@ -1,8 +1,8 @@
package buildcraft.api.bptblocks;
import net.minecraft.inventory.IInventory;
import buildcraft.api.blueprints.BptSlotInfo;
import buildcraft.api.blueprints.IBptContext;
import net.minecraft.inventory.IInventory;
@Deprecated
public class BptBlockRotateInventory extends BptBlockRotateMeta {

View file

@ -9,12 +9,11 @@
package buildcraft.api.bptblocks;
import java.util.LinkedList;
import net.minecraft.item.ItemStack;
import buildcraft.api.blueprints.BptBlock;
import buildcraft.api.blueprints.BptSlotInfo;
import buildcraft.api.blueprints.IBptContext;
import java.util.LinkedList;
import net.minecraft.item.ItemStack;
@Deprecated
public class BptBlockRotateMeta extends BptBlock {

View file

@ -9,15 +9,14 @@
package buildcraft.api.bptblocks;
import java.util.LinkedList;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import buildcraft.api.blueprints.BlockSignature;
import buildcraft.api.blueprints.BptBlock;
import buildcraft.api.blueprints.BptSlotInfo;
import buildcraft.api.blueprints.IBptContext;
import java.util.LinkedList;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@Deprecated
public class BptBlockSign extends BptBlock {

View file

@ -9,12 +9,11 @@
package buildcraft.api.bptblocks;
import java.util.LinkedList;
import net.minecraft.item.ItemStack;
import buildcraft.api.blueprints.BptBlock;
import buildcraft.api.blueprints.BptSlotInfo;
import buildcraft.api.blueprints.IBptContext;
import java.util.LinkedList;
import net.minecraft.item.ItemStack;
@Deprecated
public class BptBlockStairs extends BptBlock {

View file

@ -9,12 +9,11 @@
package buildcraft.api.bptblocks;
import java.util.LinkedList;
import net.minecraft.item.ItemStack;
import buildcraft.api.blueprints.BptBlock;
import buildcraft.api.blueprints.BptSlotInfo;
import buildcraft.api.blueprints.IBptContext;
import java.util.LinkedList;
import net.minecraft.item.ItemStack;
@Deprecated
public class BptBlockWallSide extends BptBlock {

View file

@ -1,9 +1,9 @@
package buildcraft.api.core;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.util.Icon;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.util.Icon;
public interface IIconProvider {

View file

@ -13,7 +13,9 @@ import net.minecraft.world.World;
public class SafeTimeTracker {
private long lastMark = 0;
private long lastMark = Long.MIN_VALUE;
private long duration = 0;
private boolean marked;
/**
* Return true if a given delay has passed since last time marked was called successfully.
@ -28,12 +30,18 @@ public class SafeTimeTracker {
lastMark = currentTime;
return false;
} else if (lastMark + delay <= currentTime) {
duration = currentTime - lastMark;
lastMark = world.getWorldTime();
marked = true;
return true;
} else
return false;
}
public long durationOfLastDelay(){
return marked ? duration : 0;
}
public void markTime(World world) {
lastMark = world.getWorldTime();

View file

@ -0,0 +1,50 @@
/*
* Copyright (c) SpaceToad, 2011-2012
* 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.item.ItemStack;
/**
*
* @author CovertJaguar <http://www.railcraft.info/>
*/
public class StackWrapper {
public final ItemStack stack;
public StackWrapper(ItemStack stack) {
this.stack = stack;
}
@Override
public int hashCode() {
int hash = 5;
hash = 67 * hash + stack.itemID;
hash = 67 * hash + stack.getItemDamage();
if (stack.stackTagCompound != null)
hash = 67 * hash + stack.stackTagCompound.hashCode();
return hash;
}
@Override
public boolean equals(Object obj) {
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
final StackWrapper other = (StackWrapper) obj;
if (stack.itemID != other.stack.itemID)
return false;
if (stack.getHasSubtypes() && stack.getItemDamage() != other.stack.getItemDamage())
return false;
if (stack.stackTagCompound != null && !stack.stackTagCompound.equals(other.stack.stackTagCompound))
return false;
return true;
}
}

View file

@ -1,11 +1,11 @@
package buildcraft.api.filler;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon;
import buildcraft.api.core.IBox;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon;
public interface IFillerPattern {

View file

@ -0,0 +1,83 @@
/**
* Copyright (c) SpaceToad, 2011 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 buildcraft.api.core.StackWrapper;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
public final class IronEngineCoolant {
public static Map<String, Coolant> liquidCoolants = new HashMap<String, Coolant>();
public static Map<StackWrapper, FluidStack> solidCoolants = new HashMap<StackWrapper, FluidStack>();
public static FluidStack getFluidCoolant(ItemStack stack) {
return solidCoolants.get(new StackWrapper(stack));
}
public static Coolant getCoolant(ItemStack stack) {
return getCoolant(getFluidCoolant(stack));
}
public static Coolant getCoolant(FluidStack fluidStack) {
return fluidStack != null ? liquidCoolants.get(fluidStack.getFluid().getName()) : null;
}
private IronEngineCoolant() {
}
public static 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 && Item.itemsList[stack.itemID] != null && coolant != null) {
solidCoolants.put(new StackWrapper(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 stack
* @param coolant
*/
public static void addCoolant(final int itemId, final int metadata, final FluidStack coolant) {
addCoolant(new ItemStack(itemId, 1, metadata), coolant);
}
public static boolean isCoolant(Fluid fluid) {
return liquidCoolants.containsKey(fluid.getName());
}
}

View file

@ -0,0 +1,50 @@
/**
* Copyright (c) SpaceToad, 2011 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 class IronEngineFuel {
public static Map<String, Fuel> fuels = new HashMap<String, Fuel>();
public static Fuel getFuelForFluid(Fluid liquid) {
return liquid == null ? null : fuels.get(liquid.getName());
}
private IronEngineFuel() {
}
public static 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

@ -1,16 +1,16 @@
package buildcraft.api.gates;
import buildcraft.api.transport.IPipe;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
import net.minecraft.block.Block;
import net.minecraft.tileentity.TileEntity;
import buildcraft.api.transport.IPipe;
public class ActionManager {
public static ITrigger[] triggers = new ITrigger[1024];
public static IAction[] actions = new IAction[1024];
public static Map<String, ITrigger> triggers = new HashMap<String, ITrigger>();
public static Map<String, IAction> actions = new HashMap<String, IAction>();
private static LinkedList<ITriggerProvider> triggerProviders = new LinkedList<ITriggerProvider>();
private static LinkedList<IActionProvider> actionProviders = new LinkedList<IActionProvider>();
@ -19,6 +19,14 @@ public class ActionManager {
triggerProviders.add(provider);
}
}
public static void registerTrigger(ITrigger trigger){
triggers.put(trigger.getUniqueTag(), trigger);
}
public static void registerAction(IAction action){
actions.put(action.getUniqueTag(), action);
}
public static LinkedList<ITrigger> getNeighborTriggers(Block block, TileEntity entity) {
LinkedList<ITrigger> triggers = new LinkedList<ITrigger>();
@ -79,5 +87,20 @@ public class ActionManager {
return triggers;
}
public static ITrigger getTriggerFromLegacyId(int legacyId){
for(ITrigger trigger : triggers.values()){
if(trigger.getLegacyId() == legacyId)
return trigger;
}
return null;
}
public static IAction getActionFromLegacyId(int legacyId){
for(IAction action : actions.values()){
if(action.getLegacyId() == legacyId)
return action;
}
return null;
}
}

View file

@ -1,20 +1,27 @@
package buildcraft.api.gates;
import buildcraft.api.core.IIconProvider;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.util.Icon;
public interface IAction {
int getId();
/**
* Return your ID from the old API here, this is only used to convert old
* saves to the new format.
*/
int getLegacyId();
String getUniqueTag();
@SideOnly(Side.CLIENT)
Icon getIcon();
@SideOnly(Side.CLIENT)
void registerIcons(IconRegister iconRegister);
int getIconIndex();
@SideOnly(Side.CLIENT)
IIconProvider getIconProvider();
boolean hasParameter();
String getDescription();
}

View file

@ -10,7 +10,6 @@
package buildcraft.api.gates;
import java.util.LinkedList;
import net.minecraft.block.Block;
import net.minecraft.tileentity.TileEntity;

View file

@ -1,38 +1,47 @@
package buildcraft.api.gates;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import buildcraft.api.core.IIconProvider;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon;
import net.minecraftforge.common.ForgeDirection;
public interface ITrigger {
public abstract int getId();
/**
* Return your ID from the old API here, this is only used to convert old
* saves to the new format.
*/
int getLegacyId();
public int getIconIndex();
@SideOnly(Side.CLIENT)
public IIconProvider getIconProvider();
String getUniqueTag();
@SideOnly(Side.CLIENT)
Icon getIcon();
@SideOnly(Side.CLIENT)
void registerIcons(IconRegister iconRegister);
/**
* Return true if this trigger can accept parameters
*/
public boolean hasParameter();
boolean hasParameter();
/**
* Return the trigger description in the UI
*/
public String getDescription();
String getDescription();
/**
* Return true if the tile given in parameter activates the trigger, given the parameters.
* Return true if the tile given in parameter activates the trigger, given
* the parameters.
*/
public abstract boolean isTriggerActive(ForgeDirection side, TileEntity tile, ITriggerParameter parameter);
boolean isTriggerActive(ForgeDirection side, TileEntity tile, ITriggerParameter parameter);
/**
* Create parameters for the trigger. As for now, there is only one kind of trigger parameter available so this subprogram is final.
* Create parameters for the trigger. As for now, there is only one kind of
* trigger parameter available so this subprogram is final.
*/
public ITriggerParameter createParameter();
ITriggerParameter createParameter();
}

View file

@ -9,11 +9,10 @@
package buildcraft.api.gates;
import buildcraft.api.transport.IPipe;
import java.util.LinkedList;
import net.minecraft.block.Block;
import net.minecraft.tileentity.TileEntity;
import buildcraft.api.transport.IPipe;
public interface ITriggerProvider {

View file

@ -0,0 +1,24 @@
/*
* Copyright (c) SpaceToad, 2011-2012
* 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.minecraftforge.common.ForgeDirection;
/**
* 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.
*
* @author CovertJaguar <http://www.railcraft.info/>
*/
public interface IPowerEmitter {
public boolean canEmitPowerFrom(ForgeDirection side);
}

View file

@ -1,41 +0,0 @@
package buildcraft.api.power;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.ForgeDirection;
import buildcraft.api.core.SafeTimeTracker;
public interface IPowerProvider {
int getLatency();
int getMinEnergyReceived();
int getMaxEnergyReceived();
int getMaxEnergyStored();
int getActivationEnergy();
float getEnergyStored();
void configure(int latency, int minEnergyReceived, int maxEnergyReceived, int minActivationEnergy, int maxStoredEnergy);
void configurePowerPerdition(int powerLoss, int powerLossRegularity);
boolean update(IPowerReceptor receptor);
boolean preConditions(IPowerReceptor receptor);
float useEnergy(float min, float max, boolean doUse);
void readFromNBT(NBTTagCompound nbttagcompound);
void writeToNBT(NBTTagCompound nbttagcompound);
void receiveEnergy(float quantity, ForgeDirection from);
boolean isPowerSource(ForgeDirection from);
SafeTimeTracker getTimeTracker();
}

View file

@ -1,24 +1,47 @@
/**
* Copyright (c) SpaceToad, 2011
* 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
/**
* Copyright (c) SpaceToad, 2011 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 buildcraft.api.power.PowerHandler.PowerReceiver;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
/**
* This interface should be implemented by any Tile Entity that wishes to be
* able to receive power.
*
* @author CovertJaguar <http://www.railcraft.info/>
*/
public interface IPowerReceptor {
public void setPowerProvider(IPowerProvider provider);
/**
* 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
* @return
*/
public PowerReceiver getPowerReceiver(ForgeDirection side);
public IPowerProvider getPowerProvider();
public void doWork();
public int powerRequest(ForgeDirection from);
/**
* 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
*/
public void doWork(PowerHandler workProvider);
public World getWorld();
}

View file

@ -1,55 +0,0 @@
/**
* Copyright (c) SpaceToad, 2011
* 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;
public abstract class PowerFramework {
static private String baseNBTName = "net.minecraft.src.buildcarft.Power";
public static PowerFramework currentFramework;
public abstract IPowerProvider createPowerProvider();
public void loadPowerProvider(IPowerReceptor receptor, NBTTagCompound compound) {
IPowerProvider provider = createPowerProvider();
if (compound.hasKey(baseNBTName)) {
NBTTagCompound cpt = compound.getCompoundTag(baseNBTName);
if (cpt.getString("class").equals(this.getClass().getName())) {
provider.readFromNBT(cpt.getCompoundTag("contents"));
}
}
receptor.setPowerProvider(provider);
}
public void savePowerProvider(IPowerReceptor receptor, NBTTagCompound compound) {
IPowerProvider provider = receptor.getPowerProvider();
if (provider == null)
return;
NBTTagCompound cpt = new NBTTagCompound();
cpt.setString("class", this.getClass().getName());
NBTTagCompound contents = new NBTTagCompound();
provider.writeToNBT(contents);
cpt.setTag("contents", contents);
compound.setTag(baseNBTName, cpt);
}
}

View file

@ -0,0 +1,387 @@
/**
* Copyright (c) SpaceToad, 2011 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 buildcraft.api.core.SafeTimeTracker;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.ForgeDirection;
public final class PowerHandler {
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;
}
}
}
public static class PerditionCalculator {
public static final float DEFAULT_POWERLOSS = 1F;
public static final float MIN_POWERLOSS = 0.01F;
private final float powerLoss;
public PerditionCalculator() {
powerLoss = DEFAULT_POWERLOSS;
}
public PerditionCalculator(float powerLoss) {
if (powerLoss < MIN_POWERLOSS) {
powerLoss = MIN_POWERLOSS;
}
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
* @return
*/
public float applyPerdition(PowerHandler powerHandler, float current, long ticksPassed) {
current -= powerLoss * ticksPassed;
if (current < 0) {
current = 0;
}
return current;
}
}
public static final PerditionCalculator DEFUALT_PERDITION = new PerditionCalculator();
private float minEnergyReceived;
private float maxEnergyReceived;
private float maxEnergyStored;
private float activationEnergy;
private float energyStored = 0;
private final SafeTimeTracker doWorkTracker = new SafeTimeTracker();
private final SafeTimeTracker sourcesTracker = new SafeTimeTracker();
private final SafeTimeTracker perditionTracker = new SafeTimeTracker();
public final int[] powerSources = new int[6];
public final IPowerReceptor receptor;
private PerditionCalculator perdition;
private final PowerReceiver receiver;
private final Type type;
public PowerHandler(IPowerReceptor receptor, Type type) {
this.receptor = receptor;
this.type = type;
this.receiver = new PowerReceiver();
}
public PowerReceiver getPowerReceiver() {
return receiver;
}
public float getMinEnergyReceived() {
return minEnergyReceived;
}
public float getMaxEnergyReceived() {
return maxEnergyReceived;
}
public float getMaxEnergyStored() {
return maxEnergyStored;
}
public float getActivationEnergy() {
return activationEnergy;
}
public float getEnergyStored() {
return energyStored;
}
/**
* 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(float minEnergyReceived, float maxEnergyReceived, float activationEnergy, float maxStoredEnergy) {
if (minEnergyReceived > maxEnergyReceived) {
maxEnergyReceived = minEnergyReceived;
}
this.minEnergyReceived = minEnergyReceived;
this.maxEnergyReceived = maxEnergyReceived;
this.maxEnergyStored = maxStoredEnergy;
this.activationEnergy = activationEnergy;
}
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.
*
* For example if you want exponentially increasing loss based on amount
* stored.
*
* @param perdition
*/
public void setPerdition(PerditionCalculator perdition) {
this.perdition = perdition;
}
public PerditionCalculator getPerdition() {
if (perdition == null)
return DEFUALT_PERDITION;
return perdition;
}
/**
* Ticks the power handler. You should call this if you can, but its not
* required.
*
* 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() {
if (perditionTracker.markTimeIfDelay(receptor.getWorld(), 1) && energyStored > 0) {
float newEnergy = getPerdition().applyPerdition(this, energyStored, perditionTracker.durationOfLastDelay());
if (newEnergy == 0 || newEnergy < energyStored) {
energyStored = newEnergy;
} else {
energyStored = DEFUALT_PERDITION.applyPerdition(this, energyStored, perditionTracker.durationOfLastDelay());
}
validateEnergy();
}
}
private void applyWork() {
if (energyStored >= activationEnergy) {
if (doWorkTracker.markTimeIfDelay(receptor.getWorld(), 1)) {
receptor.doWork(this);
}
}
}
private void updateSources(ForgeDirection source) {
if (sourcesTracker.markTimeIfDelay(receptor.getWorld(), 1)) {
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 float useEnergy(float min, float max, boolean doUse) {
applyPerdition();
float result = 0;
if (energyStored >= min) {
if (energyStored <= max) {
result = energyStored;
if (doUse) {
energyStored = 0;
}
} else {
result = max;
if (doUse) {
energyStored -= max;
}
}
}
validateEnergy();
return result;
}
public void readFromNBT(NBTTagCompound data) {
readFromNBT(data, "powerProvider");
}
public void readFromNBT(NBTTagCompound data, String tag) {
NBTTagCompound nbt = data.getCompoundTag(tag);
energyStored = nbt.getFloat("storedEnergy");
}
public void writeToNBT(NBTTagCompound data) {
writeToNBT(data, "powerProvider");
}
public void writeToNBT(NBTTagCompound data, String tag) {
NBTTagCompound nbt = new NBTTagCompound();
nbt.setFloat("storedEnergy", energyStored);
data.setCompoundTag(tag, nbt);
}
public final class PowerReceiver {
private PowerReceiver() {
}
public float getMinEnergyReceived() {
return minEnergyReceived;
}
public float getMaxEnergyReceived() {
return maxEnergyReceived;
}
public float getMaxEnergyStored() {
return maxEnergyStored;
}
public float getActivationEnergy() {
return activationEnergy;
}
public float getEnergyStored() {
return energyStored;
}
public Type getType() {
return type;
}
public void update() {
PowerHandler.this.update();
}
/**
* The amount of power that this PowerHandler currently needs.
*
* @return
*/
public float powerRequest() {
return Math.min(maxEnergyReceived, maxEnergyStored - energyStored);
}
/**
* Add power to the PowerReceiver from an external source.
*
* @param quantity
* @param from
* @return the amount of power used
*/
public float receiveEnergy(Type source, final float quantity, ForgeDirection from) {
float used = quantity;
if (source == Type.ENGINE) {
if (used < minEnergyReceived) {
return 0;
} else if (used > maxEnergyReceived) {
used = maxEnergyReceived;
}
}
updateSources(from);
used = addEnergy(used);
applyWork();
if (source == Type.ENGINE && type.eatsEngineExcess()) {
return Math.min(quantity, maxEnergyReceived);
}
return used;
}
}
/**
*
* @return the amount the power changed by
*/
public float addEnergy(float quantity) {
energyStored += quantity;
if (energyStored > maxEnergyStored) {
quantity -= energyStored - maxEnergyStored;
energyStored = maxEnergyStored;
} else if (energyStored < 0) {
quantity -= energyStored;
energyStored = 0;
}
applyPerdition();
return quantity;
}
public void setEnergy(float quantity) {
this.energyStored = quantity;
validateEnergy();
}
public boolean isPowerSource(ForgeDirection from) {
return powerSources[from.ordinal()] != 0;
}
private void validateEnergy() {
if (energyStored < 0) {
energyStored = 0;
}
if (energyStored > maxEnergyStored) {
energyStored = maxEnergyStored;
}
}
}

View file

@ -1,187 +0,0 @@
/**
* Copyright (c) SpaceToad, 2011
* 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.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import buildcraft.api.core.SafeTimeTracker;
public abstract class PowerProvider implements IPowerProvider {
protected int latency;
protected int minEnergyReceived;
protected int maxEnergyReceived;
protected int maxEnergyStored;
protected int minActivationEnergy;
protected float energyStored = 0;
protected int powerLoss = 1;
protected int powerLossRegularity = 100;
public SafeTimeTracker timeTracker = new SafeTimeTracker();
public SafeTimeTracker energyLossTracker = new SafeTimeTracker();
public int[] powerSources = { 0, 0, 0, 0, 0, 0 };
@Override
public SafeTimeTracker getTimeTracker() {
return this.timeTracker;
}
@Override
public int getLatency() {
return this.latency;
}
@Override
public int getMinEnergyReceived() {
return this.minEnergyReceived;
}
@Override
public int getMaxEnergyReceived() {
return this.maxEnergyReceived;
}
@Override
public int getMaxEnergyStored() {
return this.maxEnergyStored;
}
@Override
public int getActivationEnergy() {
return this.minActivationEnergy;
}
@Override
public float getEnergyStored() {
return this.energyStored;
}
@Override
public void configure(int latency, int minEnergyReceived, int maxEnergyReceived, int minActivationEnergy, int maxStoredEnergy) {
this.latency = latency;
this.minEnergyReceived = minEnergyReceived;
this.maxEnergyReceived = maxEnergyReceived;
this.maxEnergyStored = maxStoredEnergy;
this.minActivationEnergy = minActivationEnergy;
}
@Override
public void configurePowerPerdition(int powerLoss, int powerLossRegularity) {
this.powerLoss = powerLoss;
this.powerLossRegularity = powerLossRegularity;
}
@Override
public boolean update(IPowerReceptor receptor) {
if (!preConditions(receptor))
return false;
TileEntity tile = (TileEntity) receptor;
boolean result = false;
if (energyStored >= minActivationEnergy) {
if (latency == 0) {
receptor.doWork();
result = true;
} else {
if (timeTracker.markTimeIfDelay(tile.worldObj, latency)) {
receptor.doWork();
result = true;
}
}
}
if (powerLoss > 0 && energyLossTracker.markTimeIfDelay(tile.worldObj, powerLossRegularity)) {
energyStored -= powerLoss;
if (energyStored < 0) {
energyStored = 0;
}
}
for (int i = 0; i < 6; ++i) {
if (powerSources[i] > 0) {
powerSources[i]--;
}
}
return result;
}
@Override
public boolean preConditions(IPowerReceptor receptor) {
return true;
}
@Override
public float useEnergy(float min, float max, boolean doUse) {
float result = 0;
if (energyStored >= min) {
if (energyStored <= max) {
result = energyStored;
if (doUse) {
energyStored = 0;
}
} else {
result = max;
if (doUse) {
energyStored -= max;
}
}
}
return result;
}
@Override
public void readFromNBT(NBTTagCompound nbttagcompound) {
latency = nbttagcompound.getInteger("latency");
minEnergyReceived = nbttagcompound.getInteger("minEnergyReceived");
maxEnergyReceived = nbttagcompound.getInteger("maxEnergyReceived");
maxEnergyStored = nbttagcompound.getInteger("maxStoreEnergy");
minActivationEnergy = nbttagcompound.getInteger("minActivationEnergy");
try {
energyStored = nbttagcompound.getFloat("storedEnergy");
} catch (Throwable c) {
energyStored = 0;
}
}
@Override
public void writeToNBT(NBTTagCompound nbttagcompound) {
nbttagcompound.setInteger("latency", latency);
nbttagcompound.setInteger("minEnergyReceived", minEnergyReceived);
nbttagcompound.setInteger("maxEnergyReceived", maxEnergyReceived);
nbttagcompound.setInteger("maxStoreEnergy", maxEnergyStored);
nbttagcompound.setInteger("minActivationEnergy", minActivationEnergy);
nbttagcompound.setFloat("storedEnergy", energyStored);
}
@Override
public void receiveEnergy(float quantity, ForgeDirection from) {
powerSources[from.ordinal()] = 2;
energyStored += quantity;
if (energyStored > maxEnergyStored) {
energyStored = maxEnergyStored;
}
}
@Override
public boolean isPowerSource(ForgeDirection from) {
return powerSources[from.ordinal()] != 0;
}
}

View file

@ -1,7 +1,6 @@
package buildcraft.api.recipes;
import java.util.LinkedList;
import net.minecraft.item.ItemStack;
public class AssemblyRecipe {

View file

@ -0,0 +1,126 @@
/**
* Copyright (c) SpaceToad, 2011 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 com.google.common.base.Objects;
import java.util.Collections;
import java.util.SortedSet;
import java.util.TreeSet;
import net.minecraftforge.fluids.FluidStack;
public final class RefineryRecipes {
private static SortedSet<Recipe> recipes = new TreeSet<Recipe>();
public static void addRecipe(FluidStack ingredient, FluidStack result, int energy, int delay) {
addRecipe(ingredient, null, result, energy, delay);
}
public static void addRecipe(FluidStack ingredient1, FluidStack ingredient2, FluidStack result, int energy, int delay) {
Recipe recipe = new Recipe(ingredient1, ingredient2, result, energy, delay);
recipes.add(recipe);
}
public static SortedSet<Recipe> getRecipes() {
return Collections.unmodifiableSortedSet(recipes);
}
public static Recipe findRefineryRecipe(FluidStack liquid1, FluidStack liquid2) {
for (Recipe recipe : recipes) {
if (recipe.matches(liquid1, liquid2))
return recipe;
}
return null;
}
private RefineryRecipes() {
}
public static final class Recipe implements Comparable<Recipe> {
public final FluidStack ingredient1;
public final FluidStack ingredient2;
public final FluidStack result;
public final int energy;
public final int delay;
private Recipe(FluidStack ingredient1, FluidStack ingredient2, FluidStack result, int energy, int delay) {
if (ingredient1 == null)
throw new IllegalArgumentException("First Ingredient cannot be null!");
this.ingredient1 = ingredient1;
this.ingredient2 = ingredient2;
this.result = result;
this.energy = energy;
this.delay = delay;
}
public boolean matches(FluidStack liquid1, FluidStack liquid2) {
// No inputs, return.
if (liquid1 == null && liquid2 == null)
return false;
// Return if two ingredients are required but only one was supplied.
if ((ingredient1 != null && ingredient2 != null) && (liquid1 == null || liquid2 == null))
return false;
if (liquid1 != null && liquid2 != null) {
if (liquid1.containsFluid(ingredient1) && liquid1.containsFluid(ingredient2))
return true;
if (liquid1.containsFluid(ingredient2) && liquid1.containsFluid(ingredient1))
return true;
}
if (liquid1 != null)
return liquid1.containsFluid(ingredient1) || liquid1.containsFluid(ingredient2);
if (liquid2 != null)
return liquid2.containsFluid(ingredient1) || liquid2.containsFluid(ingredient2);
return false;
}
// Compares to only the types of source materials.
// We consider non-null < null in order that one-ingredient recipe is checked after
// the failure of matching two-ingredient recipes which include that liquid.
@Override
public int compareTo(Recipe other) {
if (other == null)
return -1;
else if (ingredient1.getFluid() != other.ingredient1.getFluid())
return ingredient1.getFluid().getName().compareTo(other.ingredient1.getFluid().getName());
else if (ingredient1.amount != other.ingredient1.amount)
return other.ingredient1.amount - ingredient1.amount;
else if (ingredient2 == null)
return other.ingredient2 == null ? 0 : 1;
else if (other.ingredient2 == null)
return -1;
else if (ingredient2.getFluid() != other.ingredient2.getFluid())
return ingredient2.getFluid().getName().compareTo(other.ingredient2.getFluid().getName());
else if (ingredient2.amount != other.ingredient2.amount)
return other.ingredient2.amount - ingredient2.amount;
return 0;
}
// equals() should be consistent with compareTo().
@Override
public boolean equals(Object obj) {
return obj instanceof Recipe
&& Objects.equal(ingredient1, ((Recipe) obj).ingredient1)
&& Objects.equal(ingredient2, ((Recipe) obj).ingredient2);
}
// hashCode() should be overridden because equals() was overridden.
@Override
public int hashCode() {
return Objects.hashCode(ingredient1, ingredient2);
}
}
}

View file

@ -0,0 +1,40 @@
package buildcraft.api.tools;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
public interface IToolPipette {
/**
* @param pipette
* ItemStack of the pipette.
* @return Capacity of the pipette.
*/
int getCapacity(ItemStack pipette);
/**
* @param pipette
* @return true if the pipette can pipette.
*/
boolean canPipette(ItemStack pipette);
/**
* Fills the pipette with the given liquid stack.
*
* @param pipette
* @param liquid
* @param doFill
* @return Amount of liquid used in filling the pipette.
*/
int fill(ItemStack pipette, FluidStack liquid, boolean doFill);
/**
* Drains liquid from the pipette
*
* @param pipette
* @param maxDrain
* @param doDrain
* @return Fluid stack representing the liquid and amount drained from the pipette.
*/
FluidStack drain(ItemStack pipette, int maxDrain, boolean doDrain);
}

View file

@ -1,7 +1,6 @@
package buildcraft.api.transport;
import java.lang.reflect.Method;
import net.minecraft.item.ItemStack;
/**

View file

@ -17,5 +17,5 @@ public interface IExtractionHandler {
* Can this pipe extract liquids from the block located at these coordinates?
* param extractor can be null
*/
boolean canExtractLiquids(Object extractor, World world, int i, int j, int k);
boolean canExtractFluids(Object extractor, World world, int i, int j, int k);
}

View file

@ -1,20 +0,0 @@
/**
* Copyright (c) SpaceToad, 2012
* 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.transport;
import net.minecraft.nbt.NBTTagCompound;
public interface IPassiveItemContribution {
public void readFromNBT(NBTTagCompound nbttagcompound);
public void writeToNBT(NBTTagCompound nbttagcompound);
}

View file

@ -36,7 +36,7 @@ public interface IPipe {
public boolean isWired(WireColor color);
public boolean hasInterface();
public boolean hasGate();
public TileEntity getContainer();

View file

@ -1,26 +0,0 @@
/**
* Copyright (c) SpaceToad, 2011
* 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.transport;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.ForgeDirection;
/**
* Interface used to put objects into pipes, implemented by pipe tile entities.
*/
public interface IPipeEntry {
void entityEntering(ItemStack payload, ForgeDirection orientation);
void entityEntering(IPipedItem item, ForgeDirection orientation);
boolean acceptItems();
}

View file

@ -1,17 +1,37 @@
/**
* Copyright (c) SpaceToad, 2011
* 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
/**
* Copyright (c) SpaceToad, 2011 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.transport;
public interface IPipeTile {
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.fluids.IFluidHandler;
public interface IPipeTile extends ISolidSideTile, IPipeConnection, IFluidHandler {
public enum PipeType {
ITEM, FLUID, POWER, STRUCTURE;
}
@Deprecated
IPipe getPipe();
boolean isInitialized();
PipeType getPipeType();
/**
* Offers an ItemStack for addition to the pipe. Will be rejected if the
* pipe doesn't accept items from that side.
*
* @param stack ItemStack offered for addition. Do not manipulate this!
* @param doAdd If false no actual addition should take place. Implementors
* should simulate.
* @param from Orientation the ItemStack is offered from.
* @return Amount of items used from the passed stack.
*/
int injectItem(ItemStack stack, boolean doAdd, ForgeDirection from);
}

View file

@ -1,83 +0,0 @@
package buildcraft.api.transport;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import buildcraft.api.core.Position;
public interface IPipedItem {
public abstract void remove();
/* GETTING & SETTING */
public abstract void setWorld(World world);
public abstract Position getPosition();
public abstract void setPosition(double x, double y, double z);
/**
* @return the speed
*/
public abstract float getSpeed();
/**
* @param speed
* the speed to set
*/
public abstract void setSpeed(float speed);
/**
* @return the item
*/
public abstract ItemStack getItemStack();
/**
* @param item
* the item to set
*/
public abstract void setItemStack(ItemStack item);
/**
* @return the container
*/
public abstract TileEntity getContainer();
/**
* @param container
* the container to set
*/
public abstract void setContainer(TileEntity container);
/**
* @return the entityId
*/
public abstract int getEntityId();
/**
* @param entityId
* the entityId to set
*/
public abstract void setEntityId(int entityId);
/* SAVING & LOADING */
public abstract void readFromNBT(NBTTagCompound nbttagcompound);
public abstract void writeToNBT(NBTTagCompound nbttagcompound);
public abstract EntityItem toEntityItem(ForgeDirection dir);
public abstract float getEntityBrightness(float f);
public abstract boolean isCorrupted();
public abstract void addContribution(String key, IPassiveItemContribution contribution);
public abstract IPassiveItemContribution getContribution(String key);
public abstract boolean hasContributions();
}

View file

@ -2,7 +2,6 @@ package buildcraft.api.transport;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.world.World;
public abstract class PipeManager {
@ -27,9 +26,9 @@ public abstract class PipeManager {
/**
* param extractor can be null
*/
public static boolean canExtractLiquids(Object extractor, World world, int i, int j, int k) {
public static boolean canExtractFluids(Object extractor, World world, int i, int j, int k) {
for (IExtractionHandler handler : extractionHandlers)
if (!handler.canExtractLiquids(extractor, world, i, j, k))
if (!handler.canExtractFluids(extractor, world, i, j, k))
return false;
return true;

View file

@ -20,6 +20,8 @@ import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.event.ForgeSubscribe;
import net.minecraftforge.event.world.ChunkEvent;
import buildcraft.api.power.IPowerReceptor;
import buildcraft.api.power.PowerHandler.PowerReceiver;
import buildcraft.api.power.PowerHandler.Type;
public class EnergyNetwork
{
@ -55,7 +57,7 @@ public class EnergyNetwork
}
else if(acceptor instanceof IPowerReceptor && Mekanism.hooks.BuildCraftLoaded)
{
totalNeeded += (((IPowerReceptor)acceptor).powerRequest(acceptorDirections.get(acceptor).getOpposite())*Mekanism.FROM_BC);
totalNeeded += (((IPowerReceptor)acceptor).getPowerReceiver(acceptorDirections.get(acceptor).getOpposite()).powerRequest()*Mekanism.FROM_BC);
}
}
}
@ -97,11 +99,11 @@ public class EnergyNetwork
}
else if(acceptor instanceof IPowerReceptor && Mekanism.hooks.BuildCraftLoaded)
{
IPowerReceptor receptor = (IPowerReceptor)acceptor;
double electricityNeeded = Math.min(receptor.powerRequest(acceptorDirections.get(acceptor).getOpposite()), receptor.getPowerProvider().getMaxEnergyStored() - receptor.getPowerProvider().getEnergyStored())*Mekanism.FROM_BC;
float transferEnergy = (float)Math.min(electricityNeeded, currentSending);
receptor.getPowerProvider().receiveEnergy((float)(transferEnergy*Mekanism.TO_BC), acceptorDirections.get(acceptor).getOpposite());
energyToSend -= transferEnergy;
PowerReceiver receiver = ((IPowerReceptor)acceptor).getPowerReceiver(acceptorDirections.get(acceptor).getOpposite());
double electricityNeeded = Math.min(receiver.powerRequest(), receiver.getMaxEnergyStored() - receiver.getEnergyStored())*Mekanism.FROM_BC;
double transferEnergy = Math.min(electricityNeeded, currentSending);
receiver.receiveEnergy(Type.STORAGE, (float)(transferEnergy*Mekanism.TO_BC), acceptorDirections.get(acceptor).getOpposite());
energyToSend -= transferEnergy;
}
}
}
@ -140,9 +142,9 @@ public class EnergyNetwork
}
else if(acceptor instanceof IPowerReceptor && Mekanism.hooks.BuildCraftLoaded)
{
if(((IPowerReceptor)acceptor).getPowerProvider() != null)
if(((IPowerReceptor)acceptor).getPowerReceiver(acceptorDirections.get(acceptor).getOpposite()) != null)
{
if((((IPowerReceptor)acceptor).powerRequest(acceptorDirections.get(acceptor).getOpposite())*Mekanism.FROM_BC) > 0)
if((((IPowerReceptor)acceptor).getPowerReceiver(acceptorDirections.get(acceptor).getOpposite()).powerRequest()*Mekanism.FROM_BC) > 0)
{
toReturn.add(acceptor);
}

View file

@ -91,10 +91,7 @@ public class ItemBlockEnergyCube extends ItemBlock implements IEnergizedItem, II
((ISustainedInventory)tileEntity).setInventory(getInventory(stack));
if(tileEntity.powerProvider != null)
{
tileEntity.powerProvider.configure(0, 0, 100, 0, (int)(tileEntity.tier.MAX_ELECTRICITY*Mekanism.TO_BC));
}
tileEntity.powerProvider.configure(0, 0, 100, 0, (int)(tileEntity.tier.MAX_ELECTRICITY*Mekanism.TO_BC));
if(!world.isRemote)
{

View file

@ -1,7 +1,7 @@
package mekanism.common;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
@ -37,7 +37,7 @@ public class ItemStopwatch extends ItemMekanism
{
if(itemstack.getItemDamage() > 0)
{
itemstack.damageItem(-1, (EntityLiving)entity);
itemstack.damageItem(-1, (EntityLivingBase)entity);
}
}
}

View file

@ -1,7 +1,7 @@
package mekanism.common;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
@ -37,7 +37,7 @@ public class ItemWeatherOrb extends ItemMekanism
{
if(itemstack.getItemDamage() > 0)
{
itemstack.damageItem(-1, (EntityLiving)entity);
itemstack.damageItem(-1, (EntityLivingBase)entity);
}
}
}

View file

@ -2,7 +2,6 @@ package mekanism.common;
import net.minecraftforge.common.ForgeDirection;
import buildcraft.api.power.IPowerReceptor;
import buildcraft.api.power.PowerProvider;
public class LinkedPowerProvider extends PowerProvider
{

View file

@ -10,14 +10,16 @@ import java.util.EnumSet;
import mekanism.api.IStrictEnergyStorage;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.common.MinecraftForge;
import universalelectricity.core.block.IConnector;
import universalelectricity.core.block.IElectrical;
import universalelectricity.core.block.IElectricalStorage;
import universalelectricity.core.electricity.ElectricityPack;
import buildcraft.api.power.IPowerProvider;
import buildcraft.api.power.IPowerReceptor;
import buildcraft.api.power.PowerHandler;
import buildcraft.api.power.PowerHandler.PowerReceiver;
import com.google.common.io.ByteArrayDataInput;
@ -153,22 +155,19 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
}
@Override
public void setPowerProvider(IPowerProvider provider) {}
@Override
public IPowerProvider getPowerProvider()
public PowerReceiver getPowerReceiver(ForgeDirection side)
{
return powerProvider;
}
@Override
public int powerRequest(ForgeDirection side)
{
return (int)Math.min(((getMaxEnergy()-getEnergy())*Mekanism.TO_BC), 100);
}
public void doWork(PowerHandler workProvider) {}
@Override
public void doWork() {}
public World getWorld()
{
return worldObj;
}
@Override
public float receiveElectricity(ForgeDirection from, ElectricityPack receive, boolean doReceive)

View file

@ -23,13 +23,12 @@ import net.minecraft.util.MathHelper;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.common.MinecraftForge;
import universalelectricity.core.block.IConductor;
import universalelectricity.core.block.IElectricalStorage;
import universalelectricity.core.electricity.ElectricityHelper;
import universalelectricity.core.electricity.ElectricityPack;
import universalelectricity.core.grid.IElectricityNetwork;
import buildcraft.api.power.IPowerProvider;
import buildcraft.api.power.IPowerReceptor;
import buildcraft.api.power.PowerProvider;
import buildcraft.api.power.PowerHandler.PowerReceiver;
import buildcraft.api.power.PowerHandler.Type;
import com.google.common.io.ByteArrayDataInput;
@ -84,12 +83,12 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements IEn
setEnergy(electricityStored - (tier.OUTPUT - (event.amount*Mekanism.FROM_IC2)));
}
}
else if(isPowerReceptor(tileEntity) && Mekanism.hooks.BuildCraftLoaded)
else if(tileEntity instanceof IPowerReceptor && Mekanism.hooks.BuildCraftLoaded)
{
IPowerReceptor receptor = (IPowerReceptor)tileEntity;
double electricityNeeded = Math.min(receptor.powerRequest(ForgeDirection.getOrientation(facing).getOpposite()), receptor.getPowerProvider().getMaxEnergyStored() - receptor.getPowerProvider().getEnergyStored())*Mekanism.FROM_BC;
float transferEnergy = (float)Math.min(electricityStored, Math.min(electricityNeeded, tier.OUTPUT));
receptor.getPowerProvider().receiveEnergy((float)(transferEnergy*Mekanism.TO_BC), ForgeDirection.getOrientation(facing).getOpposite());
PowerReceiver receiver = ((IPowerReceptor)tileEntity).getPowerReceiver(ForgeDirection.getOrientation(facing).getOpposite());
double electricityNeeded = Math.min(receiver.powerRequest(), receiver.getMaxEnergyStored() - receiver.getEnergyStored())*Mekanism.FROM_BC;
double transferEnergy = Math.min(electricityStored, Math.min(electricityNeeded, tier.OUTPUT));
receiver.receiveEnergy(Type.STORAGE, (float)(transferEnergy*Mekanism.TO_BC), ForgeDirection.getOrientation(facing).getOpposite());
setEnergy(electricityStored - transferEnergy);
}
}
@ -280,22 +279,6 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements IEn
{
return tier.VOLTAGE;
}
/**
* Whether or not the declared Tile Entity is an instance of a BuildCraft power receptor.
* @param tileEntity - tile entity to check
* @return if the tile entity is a power receptor
*/
public boolean isPowerReceptor(TileEntity tileEntity)
{
if(tileEntity instanceof IPowerReceptor)
{
IPowerReceptor receptor = (IPowerReceptor)tileEntity;
IPowerProvider provider = receptor.getPowerProvider();
return provider != null && provider.getClass().getSuperclass().equals(PowerProvider.class);
}
return false;
}
@Override
public String getType()
@ -397,12 +380,6 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements IEn
return true;
}
@Override
public int powerRequest(ForgeDirection side)
{
return side != ForgeDirection.getOrientation(facing) ? Math.min(100, (int)(tier.MAX_ELECTRICITY-electricityStored)) : 0;
}
@Override
public boolean canOutputTo(ForgeDirection side)
{

View file

@ -6,9 +6,9 @@ import mekanism.api.Object3D;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraftforge.common.ForgeDirection;
import buildcraft.api.power.IPowerProvider;
import buildcraft.api.power.IPowerReceptor;
import buildcraft.api.power.PowerProvider;
import buildcraft.api.power.PowerHandler;
import buildcraft.api.power.PowerHandler.PowerReceiver;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@ -80,16 +80,13 @@ public class TileEntityUniversalCable extends TileEntity implements IUniversalCa
}
@Override
public void setPowerProvider(IPowerProvider provider) {}
@Override
public IPowerProvider getPowerProvider()
public PowerReceiver getPowerReceiver()
{
return powerProvider;
}
@Override
public void doWork() {}
public void doWork(PowerHandler workProvider) {}
@Override
public int powerRequest(ForgeDirection from)

View file

@ -31,9 +31,9 @@ import universalelectricity.core.block.IConductor;
import universalelectricity.core.electricity.ElectricityHelper;
import universalelectricity.core.electricity.ElectricityPack;
import universalelectricity.core.grid.IElectricityNetwork;
import buildcraft.api.power.IPowerProvider;
import buildcraft.api.power.IPowerReceptor;
import buildcraft.api.power.PowerProvider;
import buildcraft.api.power.PowerHandler.PowerReceiver;
import buildcraft.api.power.PowerHandler.Type;
import com.google.common.io.ByteArrayDataInput;
@ -63,10 +63,7 @@ public abstract class TileEntityGenerator extends TileEntityElectricBlock implem
{
super(name, maxEnergy);
if(powerProvider != null)
{
powerProvider.configure(0, 0, 0, 0, (int)(maxEnergy*Mekanism.TO_BC));
}
powerProvider.configure(0, 0, 0, 0, (int)(maxEnergy*Mekanism.TO_BC));
output = out;
isActive = false;
@ -104,12 +101,12 @@ public abstract class TileEntityGenerator extends TileEntityElectricBlock implem
setEnergy(electricityStored - (output - (event.amount*Mekanism.FROM_IC2)));
}
}
else if(isPowerReceptor(tileEntity) && Mekanism.hooks.BuildCraftLoaded)
else if(tileEntity instanceof IPowerReceptor && Mekanism.hooks.BuildCraftLoaded)
{
IPowerReceptor receptor = (IPowerReceptor)tileEntity;
double electricityNeeded = Math.min(receptor.powerRequest(ForgeDirection.getOrientation(facing).getOpposite()), receptor.getPowerProvider().getMaxEnergyStored() - receptor.getPowerProvider().getEnergyStored())*Mekanism.FROM_BC;
float transferEnergy = (float)Math.min(electricityStored, Math.min(electricityNeeded, output));
receptor.getPowerProvider().receiveEnergy((float)(transferEnergy*Mekanism.TO_BC), ForgeDirection.getOrientation(facing).getOpposite());
PowerReceiver receiver = ((IPowerReceptor)tileEntity).getPowerReceiver(ForgeDirection.getOrientation(facing).getOpposite());
double electricityNeeded = Math.min(receiver.powerRequest(), receiver.getMaxEnergyStored() - receiver.getEnergyStored())*Mekanism.FROM_BC;
double transferEnergy = Math.min(electricityStored, Math.min(electricityNeeded, output));
receiver.receiveEnergy(Type.STORAGE, (float)(transferEnergy*Mekanism.TO_BC), ForgeDirection.getOrientation(facing).getOpposite());
setEnergy(electricityStored - transferEnergy);
}
}
@ -187,22 +184,6 @@ public abstract class TileEntityGenerator extends TileEntityElectricBlock implem
*/
public abstract boolean canOperate();
/**
* Whether or not the declared Tile Entity is an instance of a BuildCraft power receptor.
* @param tileEntity - tile entity to check
* @return if the tile entity is a power receptor
*/
public boolean isPowerReceptor(TileEntity tileEntity)
{
if(tileEntity instanceof IPowerReceptor)
{
IPowerReceptor receptor = (IPowerReceptor)tileEntity;
IPowerProvider provider = receptor.getPowerProvider();
return provider != null && provider.getClass().getSuperclass().equals(PowerProvider.class);
}
return false;
}
/**
* Gets the scaled energy level for the GUI.
* @param i - multiplier
@ -345,12 +326,6 @@ public abstract class TileEntityGenerator extends TileEntityElectricBlock implem
nbtTags.setBoolean("isActive", isActive);
}
@Override
public int powerRequest(ForgeDirection side)
{
return 0;
}
@Override
@SideOnly(Side.CLIENT)
public AxisAlignedBB getRenderBoundingBox()