Re-add BC stuff

This commit is contained in:
Aidan C. Brady 2013-12-03 11:10:14 -05:00
parent 5e9a282eff
commit a4d1b191e9
15 changed files with 385 additions and 23 deletions

View file

@ -11,10 +11,12 @@ import java.util.Iterator;
import java.util.List;
import java.util.Set;
import mekanism.api.Object3D;
import mekanism.api.energy.IStrictEnergyAcceptor;
import mekanism.api.transmitters.DynamicNetwork;
import mekanism.api.transmitters.ITransmitter;
import mekanism.api.transmitters.TransmissionType;
import mekanism.common.tileentity.TileEntityUniversalCable;
import mekanism.common.util.CableUtils;
import mekanism.common.util.MekanismUtils;
import net.minecraft.tileentity.TileEntity;
@ -23,6 +25,9 @@ import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.Event;
import universalelectricity.core.block.IElectrical;
import universalelectricity.core.electricity.ElectricityPack;
import buildcraft.api.power.IPowerReceptor;
import buildcraft.api.power.PowerHandler.PowerReceiver;
import buildcraft.api.power.PowerHandler.Type;
import cofh.api.energy.IEnergyHandler;
import cpw.mods.fml.common.FMLCommonHandler;
@ -97,6 +102,10 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork, Dou
{
totalNeeded += Math.min((((IEnergySink)acceptor).demandedEnergyUnits()*Mekanism.FROM_IC2), (((IEnergySink)acceptor).getMaxSafeInput()*Mekanism.FROM_IC2));
}
else if(acceptor instanceof IPowerReceptor && MekanismUtils.useBuildcraft())
{
totalNeeded += (((IPowerReceptor)acceptor).getPowerReceiver(side).powerRequest()*Mekanism.FROM_BC);
}
else if(acceptor instanceof IElectrical)
{
totalNeeded += ((IElectrical)acceptor).getRequest(side)*Mekanism.FROM_UE;
@ -185,6 +194,16 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork, Dou
toSend = Math.min(toSend, ((IEnergySink)acceptor).demandedEnergyUnits()*Mekanism.FROM_IC2);
energyToSend -= (toSend - (((IEnergySink)acceptor).injectEnergyUnits(side.getOpposite(), toSend*Mekanism.TO_IC2)*Mekanism.FROM_IC2));
}
else if(acceptor instanceof IPowerReceptor && MekanismUtils.useBuildcraft())
{
PowerReceiver receiver = ((IPowerReceptor)acceptor).getPowerReceiver(side.getOpposite());
if(receiver != null)
{
float toSend = receiver.receiveEnergy(Type.PIPE, (float)(Math.min(receiver.powerRequest(), currentSending*Mekanism.TO_BC)), side.getOpposite());
energyToSend -= toSend*Mekanism.FROM_BC;
}
}
else if(acceptor instanceof IElectrical)
{
double toSend = Math.min(currentSending, ((IElectrical)acceptor).getRequest(side.getOpposite())*Mekanism.FROM_UE);
@ -269,6 +288,23 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork, Dou
}
}
}
else if(acceptor instanceof IPowerReceptor && MekanismUtils.useBuildcraft())
{
IPowerReceptor handler = (IPowerReceptor)acceptor;
if(handler.getPowerReceiver(side.getOpposite()) != null)
{
if((handler.getPowerReceiver(side.getOpposite()).powerRequest()*Mekanism.FROM_BC) > 0)
{
TileEntityUniversalCable cable = (TileEntityUniversalCable)Object3D.get(acceptor).getFromSide(side.getOpposite()).getTileEntity(acceptor.worldObj);
if(cable != null && !cable.getBuildCraftIgnored().contains(acceptor))
{
toReturn.add(acceptor);
}
}
}
}
}
return toReturn;

View file

@ -2,17 +2,18 @@ package mekanism.common;
import ic2.api.energy.tile.IEnergySink;
import ic2.api.energy.tile.IEnergyTile;
import universalelectricity.core.block.IConnector;
import universalelectricity.core.block.IElectrical;
import universalelectricity.core.block.IElectricalStorage;
import buildcraft.api.power.IPowerReceptor;
import cofh.api.energy.IEnergyHandler;
import mekanism.api.Object3D;
import mekanism.api.energy.IStrictEnergyAcceptor;
import mekanism.api.energy.IStrictEnergyStorage;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import universalelectricity.core.block.IConnector;
import universalelectricity.core.block.IElectrical;
import universalelectricity.core.block.IElectricalStorage;
import cofh.api.energy.IEnergyHandler;
public interface IAdvancedBoundingBlock extends IBoundingBlock, ISidedInventory, IEnergySink, IStrictEnergyAcceptor, IEnergyTile, IElectrical, IElectricalStorage, IConnector, IStrictEnergyStorage, IEnergyHandler
public interface IAdvancedBoundingBlock extends IBoundingBlock, ISidedInventory, IEnergySink, IStrictEnergyAcceptor, IPowerReceptor, IEnergyTile, IElectrical, IElectricalStorage, IConnector, IStrictEnergyStorage, IEnergyHandler
{
public int[] getBoundSlots(Object3D location, int side);

View file

@ -1192,7 +1192,6 @@ public class Mekanism
donators.add("ejmiv89");
donators.add("Greylocke");
donators.add("darkphan");
donators.add("mallrat208");
//Load proxy
proxy.registerRenderInformation();

View file

@ -1,5 +1,13 @@
package mekanism.common.tileentity;
import universalelectricity.core.block.IConnector;
import universalelectricity.core.block.IElectrical;
import universalelectricity.core.block.IElectricalStorage;
import universalelectricity.core.electricity.ElectricityPack;
import buildcraft.api.power.IPowerReceptor;
import buildcraft.api.power.PowerHandler;
import buildcraft.api.power.PowerHandler.PowerReceiver;
import cofh.api.energy.IEnergyHandler;
import ic2.api.energy.tile.IEnergySink;
import ic2.api.energy.tile.IEnergyTile;
import mekanism.api.Object3D;
@ -10,14 +18,10 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import universalelectricity.core.block.IConnector;
import universalelectricity.core.block.IElectrical;
import universalelectricity.core.block.IElectricalStorage;
import universalelectricity.core.electricity.ElectricityPack;
import cofh.api.energy.IEnergyHandler;
public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock implements ISidedInventory, IEnergySink, IStrictEnergyAcceptor, IEnergyTile, IElectrical, IElectricalStorage, IConnector, IStrictEnergyStorage, IEnergyHandler
public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock implements ISidedInventory, IEnergySink, IStrictEnergyAcceptor, IPowerReceptor, IEnergyTile, IElectrical, IElectricalStorage, IConnector, IStrictEnergyStorage, IEnergyHandler
{
@Override
public int getSizeInventory()
@ -377,6 +381,39 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp
return getInv().getVoltage();
}
@Override
public PowerReceiver getPowerReceiver(ForgeDirection side)
{
if(getInv() == null)
{
return null;
}
return getInv().getPowerReceiver(side);
}
@Override
public void doWork(PowerHandler workProvider)
{
if(getInv() == null)
{
return;
}
getInv().doWork(workProvider);
}
@Override
public World getWorld()
{
if(getInv() == null)
{
return null;
}
return getInv().getWorld();
}
@Override
public double transferEnergyToAcceptor(ForgeDirection side, double amount)
{

View file

@ -18,17 +18,21 @@ import mekanism.common.Mekanism;
import mekanism.common.util.MekanismUtils;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
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.IPowerReceptor;
import buildcraft.api.power.PowerHandler;
import buildcraft.api.power.PowerHandler.PowerReceiver;
import cofh.api.energy.IEnergyHandler;
import com.google.common.io.ByteArrayDataInput;
public abstract class TileEntityElectricBlock extends TileEntityContainerBlock implements ITileNetwork, IEnergyTile, IElectrical, IElectricalStorage, IConnector, IStrictEnergyStorage, IEnergyHandler, IEnergySink, IEnergyStorage, IStrictEnergyAcceptor, ICableOutputter
public abstract class TileEntityElectricBlock extends TileEntityContainerBlock implements ITileNetwork, IPowerReceptor, IEnergyTile, IElectrical, IElectricalStorage, IConnector, IStrictEnergyStorage, IEnergyHandler, IEnergySink, IEnergyStorage, IStrictEnergyAcceptor, ICableOutputter
{
/** How much energy is stored in this block. */
public double electricityStored;
@ -36,6 +40,9 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
/** Maximum amount of energy this machine can hold. */
public double MAX_ELECTRICITY;
/** BuildCraft power handler. */
public PowerHandler powerHandler;
/**
* The base of all blocks that deal with electricity. It has a facing state, initialized state,
* and a current amount of stored energy.
@ -46,6 +53,10 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
{
super(name);
MAX_ELECTRICITY = maxEnergy;
powerHandler = new PowerHandler(this, PowerHandler.Type.STORAGE);
powerHandler.configurePowerPerdition(0, 0);
powerHandler.configure(0, 0, 0, 0);
}
public void register()
@ -61,7 +72,10 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
}
@Override
public void onUpdate() {}
public void onUpdate()
{
reconfigure();
}
public EnumSet<ForgeDirection> getOutputtingSides()
{
@ -144,6 +158,7 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
super.readFromNBT(nbtTags);
electricityStored = nbtTags.getDouble("electricityStored");
reconfigure();
}
@Override
@ -154,6 +169,42 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
nbtTags.setDouble("electricityStored", getEnergy());
}
@Override
public PowerReceiver getPowerReceiver(ForgeDirection side)
{
return powerHandler.getPowerReceiver();
}
protected void reconfigure()
{
if(MekanismUtils.useBuildcraft())
{
powerHandler.configure(1, (float)((getMaxEnergy()-getEnergy())*Mekanism.TO_BC), 0, (float)(getMaxEnergy()*Mekanism.TO_BC));
}
}
@Override
public void doWork(PowerHandler workProvider)
{
if(powerHandler.getEnergyStored() > 0)
{
if(getEnergy() < getMaxEnergy())
{
setEnergy(getEnergy() + powerHandler.useEnergy(0, (float)((getMaxEnergy()-getEnergy())*Mekanism.TO_BC), true)*Mekanism.FROM_BC);
}
powerHandler.setEnergy(0);
}
reconfigure();
}
@Override
public World getWorld()
{
return worldObj;
}
@Override
public float receiveElectricity(ForgeDirection from, ElectricityPack receive, boolean doReceive)
{

View file

@ -2,6 +2,7 @@ package mekanism.common.tileentity;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.HashSet;
import mekanism.api.Object3D;
import mekanism.common.IRedstoneControl;
@ -17,6 +18,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.MathHelper;
import net.minecraftforge.common.ForgeDirection;
import buildcraft.api.power.IPowerReceptor;
import com.google.common.io.ByteArrayDataInput;
@ -24,7 +26,7 @@ import dan200.computer.api.IComputerAccess;
import dan200.computer.api.ILuaContext;
import dan200.computer.api.IPeripheral;
public class TileEntityEnergyCube extends TileEntityElectricBlock implements IPeripheral, IRedstoneControl
public class TileEntityEnergyCube extends TileEntityElectricBlock implements IPowerReceptor, IPeripheral, IRedstoneControl
{
/** This Energy Cube's tier. */
public EnergyCubeTier tier = EnergyCubeTier.BASIC;

View file

@ -14,21 +14,37 @@ import mekanism.api.transmitters.TransmitterNetworkRegistry;
import mekanism.common.EnergyNetwork;
import mekanism.common.Mekanism;
import mekanism.common.util.CableUtils;
import mekanism.common.util.MekanismUtils;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.common.MinecraftForge;
import universalelectricity.core.block.IElectrical;
import universalelectricity.core.electricity.ElectricityPack;
import universalelectricity.core.grid.IElectricityNetwork;
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;
public class TileEntityUniversalCable extends TileEntityTransmitter<EnergyNetwork, Double> implements IEnergySink, IEnergyHandler, IElectrical
public class TileEntityUniversalCable extends TileEntityTransmitter<EnergyNetwork, Double> implements IPowerReceptor, IEnergySink, IEnergyHandler, IElectrical
{
/** A fake power handler used to initiate energy transfer calculations. */
public PowerHandler powerHandler;
/** A fake UE ElectricityNetwork used to accept power from EU machines */
public IElectricityNetwork ueNetwork;
public double energyScale;
public TileEntityUniversalCable()
{
powerHandler = new PowerHandler(this, PowerHandler.Type.STORAGE);
powerHandler.configurePowerPerdition(0, 0);
powerHandler.configure(0, 0, 0, 0);
}
@Override
public TransmissionType getTransmissionType()
{
@ -128,6 +144,7 @@ public class TileEntityUniversalCable extends TileEntityTransmitter<EnergyNetwor
}
getTransmitterNetwork().refresh();
reconfigure();
}
@Override
@ -148,6 +165,86 @@ public class TileEntityUniversalCable extends TileEntityTransmitter<EnergyNetwor
}
}
@Override
public PowerReceiver getPowerReceiver(ForgeDirection side)
{
if(getTransmitterNetwork().getEnergyNeeded(new ArrayList()) == 0)
{
return null;
}
return powerHandler.getPowerReceiver();
}
@Override
public World getWorld()
{
return worldObj;
}
private void reconfigure()
{
if(MekanismUtils.useBuildcraft())
{
float needed = (float)(getTransmitterNetwork().getEnergyNeeded(getBuildCraftIgnored())*Mekanism.TO_BC);
powerHandler.configure(1, needed, 0, needed);
}
}
public ArrayList<TileEntity> getBuildCraftIgnored()
{
ArrayList<TileEntity> ignored = new ArrayList<TileEntity>();
for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
{
TileEntity tile = Object3D.get(this).getFromSide(side).getTileEntity(worldObj);
if(tile != null)
{
if(powerHandler.powerSources[side.ordinal()] > 0)
{
ignored.add(tile);
}
else if(tile instanceof IPowerEmitter)
{
IPowerEmitter emitter = (IPowerEmitter)tile;
if(emitter.canEmitPowerFrom(side.getOpposite()))
{
ignored.add(tile);
}
}
}
}
return ignored;
}
@Override
public void doWork(PowerHandler workProvider)
{
if(MekanismUtils.useBuildcraft())
{
if(powerHandler.getEnergyStored() > 0)
{
getTransmitterNetwork().emit(powerHandler.getEnergyStored()*Mekanism.FROM_BC, getBuildCraftIgnored());
}
powerHandler.setEnergy(0);
reconfigure();
}
}
public void setCachedEnergy(double scale)
{
energyScale = scale;
}
public float getEnergyScale()
{
return (float)energyScale;
}
@Override
public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction)
{
@ -157,7 +254,7 @@ public class TileEntityUniversalCable extends TileEntityTransmitter<EnergyNetwor
@Override
public double demandedEnergyUnits()
{
return getTransmitterNetwork().getEnergyNeeded(new ArrayList())*Mekanism.TO_IC2;
return getTransmitterNetwork().getEnergyNeeded(getBuildCraftIgnored())*Mekanism.TO_IC2;
}
@Override

View file

@ -6,6 +6,7 @@ import ic2.api.energy.tile.IEnergySource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.List;
import mekanism.api.Object3D;
@ -23,6 +24,9 @@ import universalelectricity.core.block.IElectrical;
import universalelectricity.core.electricity.ElectricityHelper;
import universalelectricity.core.electricity.ElectricityPack;
import universalelectricity.core.grid.IElectricityNetwork;
import buildcraft.api.power.IPowerReceptor;
import buildcraft.api.power.PowerHandler.PowerReceiver;
import buildcraft.api.power.PowerHandler.Type;
import cofh.api.energy.IEnergyHandler;
public final class CableUtils
@ -40,7 +44,10 @@ public final class CableUtils
{
TileEntity acceptor = Object3D.get(tileEntity).getFromSide(orientation).getTileEntity(tileEntity.worldObj);
if(acceptor instanceof IStrictEnergyAcceptor || acceptor instanceof IEnergySink || acceptor instanceof IElectrical || acceptor instanceof IEnergyHandler)
if(acceptor instanceof IStrictEnergyAcceptor ||
acceptor instanceof IEnergySink ||
(acceptor instanceof IPowerReceptor && !(acceptor instanceof ITransmitter) && MekanismUtils.useBuildcraft()) ||
acceptor instanceof IElectrical || acceptor instanceof IEnergyHandler)
{
acceptors[orientation.ordinal()] = acceptor;
}
@ -187,6 +194,17 @@ public final class CableUtils
return true;
}
if(tileEntity instanceof IPowerReceptor && !(tileEntity instanceof ITransmitter) && MekanismUtils.useBuildcraft())
{
if(!(tileEntity instanceof IEnergyAcceptor) || ((IEnergyAcceptor)tileEntity).acceptsEnergyFrom(null, side.getOpposite()))
{
if(!(tileEntity instanceof IEnergySource) || ((IEnergySource)tileEntity).emitsEnergyTo(null, side.getOpposite()))
{
return true;
}
}
}
return false;
}
@ -338,6 +356,17 @@ public final class CableUtils
ElectricityPack pack = ElectricityPack.getFromWatts((float)(toSend*Mekanism.TO_UE), ((IElectrical)tileEntity).getVoltage());
sendingEnergy -= (((IElectrical)tileEntity).receiveElectricity(side.getOpposite(), pack, true)*Mekanism.FROM_UE);
}
else if(tileEntity instanceof IPowerReceptor && MekanismUtils.useBuildcraft())
{
PowerReceiver receiver = ((IPowerReceptor)tileEntity).getPowerReceiver(side.getOpposite());
if(receiver != null)
{
double transferEnergy = Math.min(sendingEnergy, receiver.powerRequest()*Mekanism.FROM_BC);
float sent = receiver.receiveEnergy(Type.STORAGE, (float)(transferEnergy*Mekanism.TO_BC), side.getOpposite());
sendingEnergy -= sent;
}
}
return sendingEnergy;
}

View file

@ -16,9 +16,9 @@ import mekanism.api.EnumColor;
import mekanism.api.Object3D;
import mekanism.common.DynamicTankCache;
import mekanism.common.IActiveState;
import mekanism.common.IInvConfiguration;
import mekanism.common.IFactory;
import mekanism.common.IFactory.RecipeType;
import mekanism.common.IInvConfiguration;
import mekanism.common.IModule;
import mekanism.common.IRedstoneControl;
import mekanism.common.IRedstoneControl.RedstoneControl;
@ -1116,6 +1116,11 @@ public final class MekanismUtils
return ElectricityDisplay.getDisplayShort((float)(energy*Mekanism.TO_UE), ElectricUnit.JOULES);
}
public static boolean useBuildcraft()
{
return Mekanism.hooks.BuildCraftLoaded || Mekanism.forceBuildcraft;
}
public static String getCoordDisplay(Object3D obj)
{
return "[" + obj.xCoord + ", " + obj.yCoord + ", " + obj.zCoord + "]";

View file

@ -86,7 +86,7 @@ public final class TransporterUtils
ForgeDirection forgeSide = ForgeDirection.getOrientation(side).getOpposite();
//Immature BuildCraft inv check
if(inventory instanceof IPowerReceptor)
if(MekanismUtils.useBuildcraft() && inventory instanceof IPowerReceptor)
{
if(((IPowerReceptor)inventory).getPowerReceiver(forgeSide) != null && ((IPowerReceptor)inventory).getPowerReceiver(forgeSide).getType() == Type.MACHINE)
{

View file

@ -1,9 +1,13 @@
package mekanism.generators.common.tileentity;
import ic2.api.energy.tile.IEnergySource;
import ic2.api.tile.IEnergyStorage;
import java.util.ArrayList;
import java.util.EnumSet;
import mekanism.api.Object3D;
import mekanism.api.energy.ICableOutputter;
import mekanism.client.sound.IHasSound;
import mekanism.common.IActiveState;
import mekanism.common.IRedstoneControl;
@ -12,11 +16,15 @@ import mekanism.common.PacketHandler;
import mekanism.common.PacketHandler.Transmission;
import mekanism.common.network.PacketTileEntity;
import mekanism.common.tileentity.TileEntityElectricBlock;
import mekanism.common.tileentity.TileEntityUniversalCable;
import mekanism.common.util.CableUtils;
import mekanism.common.util.MekanismUtils;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraftforge.common.ForgeDirection;
import buildcraft.api.power.IPowerEmitter;
import buildcraft.api.power.IPowerReceptor;
import com.google.common.io.ByteArrayDataInput;
@ -25,7 +33,7 @@ import cpw.mods.fml.relauncher.SideOnly;
import dan200.computer.api.IComputerAccess;
import dan200.computer.api.IPeripheral;
public abstract class TileEntityGenerator extends TileEntityElectricBlock implements IPeripheral, IActiveState, IHasSound, IRedstoneControl
public abstract class TileEntityGenerator extends TileEntityElectricBlock implements IPowerReceptor, IPeripheral, IActiveState, IHasSound, IRedstoneControl, IPowerEmitter
{
/** Output per tick this generator can transfer. */
public double output;
@ -52,6 +60,8 @@ public abstract class TileEntityGenerator extends TileEntityElectricBlock implem
{
super(name, maxEnergy);
powerHandler.configure(0, 0, 0, 0);
output = out;
isActive = false;
controlType = RedstoneControl.DISABLED;
@ -265,4 +275,16 @@ public abstract class TileEntityGenerator extends TileEntityElectricBlock implem
controlType = type;
MekanismUtils.saveChunk(this);
}
@Override
public boolean canEmitPowerFrom(ForgeDirection side)
{
return getOutputtingSides().contains(side);
}
@Override
protected void reconfigure()
{
powerHandler.configure(0, 0, 0, 0);
}
}

View file

@ -28,6 +28,7 @@ import universalelectricity.core.grid.IElectricityNetwork;
import universalelectricity.prefab.tile.IRotatable;
import universalelectricity.prefab.tile.TileEntityAdvanced;
import universalelectricity.prefab.tile.TileEntityElectrical;
import buildcraft.api.power.IPowerReceptor;
import cofh.api.energy.TileEnergyHandler;
import com.google.common.io.ByteArrayDataInput;
@ -194,6 +195,13 @@ public class TileEntityMultimeter extends TileEntityAdvanced implements ITileNet
{
return ((TileEnergyHandler) tileEntity).getEnergyStored(side.getOpposite());
}
else if (tileEntity instanceof IPowerReceptor)
{
if (((IPowerReceptor) tileEntity).getPowerReceiver(side) != null)
{
return ((IPowerReceptor) tileEntity).getPowerReceiver(side).getEnergyStored();
}
}
return 0;
}

View file

@ -10,10 +10,12 @@ import mekanism.induction.common.wire.IWireMaterial;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import universalelectricity.compatibility.Compatibility;
import universalelectricity.compatibility.TileEntityUniversalConductor;
import universalelectricity.core.block.INetworkProvider;
import universalelectricity.core.vector.Vector3;
import universalelectricity.core.vector.VectorHelper;
import buildcraft.api.power.PowerHandler;
import com.google.common.io.ByteArrayDataInput;
@ -167,7 +169,16 @@ public class TileEntityWire extends TileEntityUniversalConductor implements ITil
nbt.setInteger("dyeID", dyeID);
nbt.setBoolean("isInsulated", isInsulated);
}
@Override
public void doWork(PowerHandler workProvider)
{
buildcraftBuffer = Compatibility.BC3_RATIO * 25 * getMaterial().maxAmps;
powerHandler.configure(0, buildcraftBuffer, buildcraftBuffer, buildcraftBuffer * 2);
super.doWork(workProvider);
}
@Override
public boolean isInsulated()
{

View file

@ -4,18 +4,36 @@ import ic2.api.energy.event.EnergyTileLoadEvent;
import ic2.api.energy.event.EnergyTileUnloadEvent;
import ic2.api.energy.tile.IEnergySink;
import ic2.api.energy.tile.IEnergyTile;
import java.util.HashSet;
import java.util.Set;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.common.MinecraftForge;
import universalelectricity.compatibility.Compatibility;
import universalelectricity.core.electricity.ElectricityPack;
import universalelectricity.core.vector.Vector3;
import universalelectricity.core.vector.VectorHelper;
import buildcraft.api.power.IPowerReceptor;
import buildcraft.api.power.PowerHandler;
import buildcraft.api.power.PowerHandler.PowerReceiver;
import buildcraft.api.power.PowerHandler.Type;
import cofh.api.energy.IEnergyHandler;
public abstract class PartUniversalConductor extends PartConductor implements IEnergySink, IEnergyHandler
public abstract class PartUniversalConductor extends PartConductor implements IEnergySink, IPowerReceptor, IEnergyHandler
{
protected boolean isAddedToEnergyNet;
public PowerHandler powerHandler;
public float buildcraftBuffer = Compatibility.BC3_RATIO * 50;
public PartUniversalConductor()
{
powerHandler = new PowerHandler(this, Type.PIPE);
powerHandler.configure(0, buildcraftBuffer, buildcraftBuffer, buildcraftBuffer * 2);
powerHandler.configurePowerPerdition(0, 0);
}
@Override
public boolean isValidAcceptor(TileEntity tile)
@ -24,6 +42,10 @@ public abstract class PartUniversalConductor extends PartConductor implements IE
{
return true;
}
else if(tile instanceof IPowerReceptor)
{
return true;
}
else if(tile instanceof IEnergyHandler)
{
return true;
@ -163,6 +185,37 @@ public abstract class PartUniversalConductor extends PartConductor implements IE
return true;
}
/**
* BuildCraft functions
*/
@Override
public PowerReceiver getPowerReceiver(ForgeDirection side)
{
return powerHandler.getPowerReceiver();
}
@Override
public void doWork(PowerHandler workProvider)
{
Set<TileEntity> ignoreTiles = new HashSet<TileEntity>();
ignoreTiles.add(tile());
for(ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS)
{
TileEntity tile = new Vector3(tile()).modifyPositionFromSide(direction).getTileEntity(world());
ignoreTiles.add(tile);
}
ElectricityPack pack = ElectricityPack.getFromWatts(workProvider.useEnergy(0, getNetwork().getRequest(tile()).getWatts() * Compatibility.TO_BC_RATIO, true) * Compatibility.BC3_RATIO, 120);
getNetwork().produce(pack, ignoreTiles.toArray(new TileEntity[0]));
}
@Override
public World getWorld()
{
return world();
}
/**
* Thermal Expansion Functions
*/

View file

@ -22,6 +22,8 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon;
import net.minecraft.util.MovingObjectPosition;
import net.minecraftforge.common.ForgeDirection;
import universalelectricity.compatibility.Compatibility;
import buildcraft.api.power.PowerHandler;
import codechicken.lib.data.MCDataInput;
import codechicken.lib.data.MCDataOutput;
import codechicken.lib.lighting.LazyLightMatrix;
@ -184,6 +186,15 @@ public class PartWire extends PartUniversalConductor implements TSlottedPart, JN
material = EnumWireMaterial.values()[id];
}
@Override
public void doWork(PowerHandler workProvider)
{
buildcraftBuffer = Compatibility.BC3_RATIO * 25 * Math.min(getMaterial().maxAmps, 100);
powerHandler.configure(0, buildcraftBuffer, buildcraftBuffer, buildcraftBuffer * 2);
super.doWork(workProvider);
}
@Override
public String getType()
{