Killed off old UE references

This commit is contained in:
Aidan Brady 2013-12-21 12:51:55 -05:00
parent c3f023c9e2
commit 235c3f20a2
15 changed files with 77 additions and 635 deletions

View file

@ -2,7 +2,6 @@ package mekanism.common;
import ic2.api.energy.tile.IEnergySink;
import java.text.DecimalFormat;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
@ -22,8 +21,6 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
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;
@ -234,12 +231,6 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork>
energyToSend -= toSend*Mekanism.FROM_BC;
}
}
else if(acceptor instanceof IElectrical)
{
double toSend = Math.min(currentSending, ((IElectrical)acceptor).getRequest(side.getOpposite())*Mekanism.FROM_UE);
ElectricityPack pack = ElectricityPack.getFromWatts((float)(toSend*Mekanism.TO_UE), ((IElectrical)acceptor).getVoltage());
energyToSend -= ((IElectrical)acceptor).receiveElectricity(side.getOpposite(), pack, true)*Mekanism.FROM_UE;
}
}
}
@ -307,18 +298,6 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork>
}
}
}
else if(acceptor instanceof IElectrical)
{
IElectrical handler = (IElectrical)acceptor;
if(handler.canConnect(side.getOpposite()))
{
if(handler.getRequest(side.getOpposite()) > 0)
{
toReturn.add(acceptor);
}
}
}
else if(acceptor instanceof IPowerReceptor && MekanismUtils.useBuildcraft())
{
IPowerReceptor handler = (IPowerReceptor)acceptor;

View file

@ -2,18 +2,15 @@ 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.Coord4D;
import mekanism.api.energy.IStrictEnergyAcceptor;
import mekanism.api.energy.IStrictEnergyStorage;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import buildcraft.api.power.IPowerReceptor;
import cofh.api.energy.IEnergyHandler;
public interface IAdvancedBoundingBlock extends IBoundingBlock, ISidedInventory, IEnergySink, IStrictEnergyAcceptor, IPowerReceptor, IEnergyTile, IElectrical, IElectricalStorage, IConnector, IStrictEnergyStorage, IEnergyHandler
public interface IAdvancedBoundingBlock extends IBoundingBlock, ISidedInventory, IEnergySink, IStrictEnergyAcceptor, IPowerReceptor, IEnergyTile, IStrictEnergyStorage, IEnergyHandler
{
public int[] getBoundSlots(Coord4D location, int side);

View file

@ -17,13 +17,12 @@ public final class Tier
*/
public static enum EnergyCubeTier
{
BASIC("Basic", EnumColor.BRIGHT_GREEN, 2000000, 120, 800),
ADVANCED("Advanced", EnumColor.DARK_RED, 8000000, 240, 3200),
ELITE("Elite", EnumColor.DARK_BLUE, 32000000, 240, 12800),
ULTIMATE("Ultimate", EnumColor.PURPLE, 128000000, 480, 51200);
BASIC("Basic", EnumColor.BRIGHT_GREEN, 2000000, 800),
ADVANCED("Advanced", EnumColor.DARK_RED, 8000000, 3200),
ELITE("Elite", EnumColor.DARK_BLUE, 32000000, 12800),
ULTIMATE("Ultimate", EnumColor.PURPLE, 128000000, 51200);
public double MAX_ELECTRICITY;
public float VOLTAGE;
public double OUTPUT;
public String name;
public EnumColor color;
@ -42,12 +41,11 @@ public final class Tier
return BASIC;
}
private EnergyCubeTier(String s, EnumColor c, double maxEnergy, float voltage, int out)
private EnergyCubeTier(String s, EnumColor c, double maxEnergy, double out)
{
name = s;
color = c;
MAX_ELECTRICITY = maxEnergy;
VOLTAGE = voltage;
OUTPUT = out;
}
}

View file

@ -6,8 +6,8 @@ import ic2.api.item.ISpecialElectricItem;
import java.util.ArrayList;
import java.util.List;
import mekanism.api.EnumColor;
import mekanism.api.Coord4D;
import mekanism.api.EnumColor;
import mekanism.api.energy.IEnergizedItem;
import mekanism.common.IEnergyCube;
import mekanism.common.ISustainedInventory;
@ -29,12 +29,11 @@ import net.minecraft.world.World;
import org.lwjgl.input.Keyboard;
import universalelectricity.core.item.IItemElectric;
import cofh.api.energy.IEnergyContainerItem;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ItemBlockEnergyCube extends ItemBlock implements IEnergizedItem, IItemElectric, IEnergyCube, ISpecialElectricItem, ISustainedInventory, IEnergyContainerItem
public class ItemBlockEnergyCube extends ItemBlock implements IEnergizedItem, IEnergyCube, ISpecialElectricItem, ISustainedInventory, IEnergyContainerItem
{
public Block metaBlock;
@ -58,7 +57,6 @@ public class ItemBlockEnergyCube extends ItemBlock implements IEnergizedItem, II
}
else {
list.add(EnumColor.BRIGHT_GREEN + "Stored Energy: " + EnumColor.GREY + MekanismUtils.getEnergyDisplay(getEnergy(itemstack)));
list.add(EnumColor.BRIGHT_GREEN + "Voltage: " + EnumColor.GREY + getVoltage(itemstack) + "v");
list.add(EnumColor.AQUA + "Inventory: " + EnumColor.GREY + (getInventory(itemstack) != null && getInventory(itemstack).tagCount() != 0));
}
}
@ -70,12 +68,6 @@ public class ItemBlockEnergyCube extends ItemBlock implements IEnergizedItem, II
charged.setItemDamage(100);
return charged;
}
@Override
public float getVoltage(ItemStack itemStack)
{
return getEnergyCubeTier(itemStack).VOLTAGE;
}
@Override
public String getUnlocalizedName(ItemStack itemstack)
@ -309,68 +301,6 @@ public class ItemBlockEnergyCube extends ItemBlock implements IEnergizedItem, II
return false;
}
@Override
public float recharge(ItemStack itemStack, float energy, boolean doRecharge)
{
if(canReceive(itemStack))
{
double energyNeeded = getMaxEnergy(itemStack)-getEnergy(itemStack);
double toReceive = Math.min(energy*Mekanism.FROM_UE, energyNeeded);
if(doRecharge)
{
setEnergy(itemStack, getEnergy(itemStack) + toReceive);
}
return (float)(toReceive*Mekanism.TO_UE);
}
return 0;
}
@Override
public float discharge(ItemStack itemStack, float energy, boolean doDischarge)
{
if(canSend(itemStack))
{
double energyRemaining = getEnergy(itemStack);
double toSend = Math.min((energy*Mekanism.FROM_UE), energyRemaining);
if(doDischarge)
{
setEnergy(itemStack, getEnergy(itemStack) - toSend);
}
return (float)(toSend*Mekanism.TO_UE);
}
return 0;
}
@Override
public float getElectricityStored(ItemStack theItem)
{
return (float)(getEnergy(theItem)*Mekanism.TO_UE);
}
@Override
public float getMaxElectricityStored(ItemStack theItem)
{
return (float)(getMaxEnergy(theItem)*Mekanism.TO_UE);
}
@Override
public void setElectricity(ItemStack itemStack, float joules)
{
setEnergy(itemStack, joules*Mekanism.TO_UE);
}
@Override
public float getTransfer(ItemStack itemStack)
{
return (float)(getMaxTransfer(itemStack)*Mekanism.TO_UE);
}
@Override
public IElectricItemManager getManager(ItemStack itemStack)
{

View file

@ -82,7 +82,7 @@ import cpw.mods.fml.relauncher.SideOnly;
* @author AidanBrady
*
*/
public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, IItemElectric, ISpecialElectricItem, IUpgradeManagement, IFactory, ISustainedInventory, ISustainedTank, IElectricChest, IEnergyContainerItem
public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpecialElectricItem, IUpgradeManagement, IFactory, ISustainedInventory, ISustainedTank, IElectricChest, IEnergyContainerItem
{
public Block metaBlock;
@ -139,7 +139,6 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, IItem
if(type != MachineType.LOGISTICAL_SORTER)
{
list.add(EnumColor.BRIGHT_GREEN + "Stored Energy: " + EnumColor.GREY + MekanismUtils.getEnergyDisplay(getEnergyStored(itemstack)));
list.add(EnumColor.BRIGHT_GREEN + "Voltage: " + EnumColor.GREY + getVoltage(itemstack) + "v");
}
if(hasTank(itemstack))
@ -165,12 +164,6 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, IItem
list.addAll(MekanismUtils.splitLines(type.getDescription()));
}
}
@Override
public float getVoltage(ItemStack itemStack)
{
return 120;
}
@Override
public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata)
@ -893,68 +886,6 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, IItem
return true;
}
@Override
public float recharge(ItemStack itemStack, float energy, boolean doRecharge)
{
if(canReceive(itemStack))
{
double energyNeeded = getMaxEnergy(itemStack)-getEnergy(itemStack);
double toReceive = Math.min(energy*Mekanism.FROM_UE, energyNeeded);
if(doRecharge)
{
setEnergy(itemStack, getEnergy(itemStack) + toReceive);
}
return (float)(toReceive*Mekanism.TO_UE);
}
return 0;
}
@Override
public float discharge(ItemStack itemStack, float energy, boolean doDischarge)
{
if(canSend(itemStack))
{
double energyRemaining = getEnergy(itemStack);
double toSend = Math.min((energy*Mekanism.FROM_UE), energyRemaining);
if(doDischarge)
{
setEnergy(itemStack, getEnergy(itemStack) - toSend);
}
return (float)(toSend*Mekanism.TO_UE);
}
return 0;
}
@Override
public float getElectricityStored(ItemStack theItem)
{
return (float)(getEnergy(theItem)*Mekanism.TO_UE);
}
@Override
public float getMaxElectricityStored(ItemStack theItem)
{
return (float)(getMaxEnergy(theItem)*Mekanism.TO_UE);
}
@Override
public void setElectricity(ItemStack itemStack, float joules)
{
setEnergy(itemStack, joules*Mekanism.TO_UE);
}
@Override
public float getTransfer(ItemStack itemStack)
{
return (float)(getMaxTransfer(itemStack)*Mekanism.TO_UE);
}
@Override
public IElectricItemManager getManager(ItemStack itemStack)
{

View file

@ -15,22 +15,17 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import universalelectricity.core.item.IItemElectric;
import cofh.api.energy.IEnergyContainerItem;
public class ItemEnergized extends ItemMekanism implements IEnergizedItem, IItemElectric, ISpecialElectricItem, IEnergyContainerItem
public class ItemEnergized extends ItemMekanism implements IEnergizedItem, ISpecialElectricItem, IEnergyContainerItem
{
/** The maximum amount of energy this item can hold. */
public double MAX_ELECTRICITY;
/** How fast this item can transfer energy. */
public float VOLTAGE;
public ItemEnergized(int id, double maxElectricity, float voltage)
{
super(id);
MAX_ELECTRICITY = maxElectricity;
VOLTAGE = voltage;
setMaxStackSize(1);
setMaxDamage(100);
setNoRepair();
@ -41,7 +36,6 @@ public class ItemEnergized extends ItemMekanism implements IEnergizedItem, IItem
public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag)
{
list.add(EnumColor.AQUA + "Stored Energy: " + EnumColor.GREY + MekanismUtils.getEnergyDisplay(getEnergy(itemstack)));
list.add(EnumColor.AQUA + "Voltage: " + EnumColor.GREY + getVoltage(itemstack) + "v");
}
@Override
@ -67,12 +61,6 @@ public class ItemEnergized extends ItemMekanism implements IEnergizedItem, IItem
setEnergy(charged, ((IEnergizedItem)charged.getItem()).getMaxEnergy(charged));
list.add(charged);
}
@Override
public float getVoltage(ItemStack itemStack)
{
return VOLTAGE;
}
@Override
public boolean canProvideEnergy(ItemStack itemStack)
@ -217,68 +205,6 @@ public class ItemEnergized extends ItemMekanism implements IEnergizedItem, IItem
return false;
}
@Override
public float recharge(ItemStack itemStack, float energy, boolean doRecharge)
{
if(canReceive(itemStack))
{
double energyNeeded = getMaxEnergy(itemStack)-getEnergy(itemStack);
double toReceive = Math.min(energy*Mekanism.FROM_UE, energyNeeded);
if(doRecharge)
{
setEnergy(itemStack, getEnergy(itemStack) + toReceive);
}
return (float)(toReceive*Mekanism.TO_UE);
}
return 0;
}
@Override
public float discharge(ItemStack itemStack, float energy, boolean doDischarge)
{
if(canSend(itemStack))
{
double energyRemaining = getEnergy(itemStack);
double toSend = Math.min((energy*Mekanism.FROM_UE), energyRemaining);
if(doDischarge)
{
setEnergy(itemStack, getEnergy(itemStack) - toSend);
}
return (float)(toSend*Mekanism.TO_UE);
}
return 0;
}
@Override
public float getElectricityStored(ItemStack theItem)
{
return (float)(getEnergy(theItem)*Mekanism.TO_UE);
}
@Override
public float getMaxElectricityStored(ItemStack theItem)
{
return (float)(getMaxEnergy(theItem)*Mekanism.TO_UE);
}
@Override
public void setElectricity(ItemStack itemStack, float joules)
{
setEnergy(itemStack, joules*Mekanism.TO_UE);
}
@Override
public float getTransfer(ItemStack itemStack)
{
return (float)(getMaxTransfer(itemStack)*Mekanism.TO_UE);
}
@Override
public IElectricItemManager getManager(ItemStack itemStack)
{

View file

@ -24,6 +24,7 @@ public class MultipartMekanism implements IPartFactory, IPartConverter
"mekanism:restrictive_transporter", "mekanism:diversion_transporter"});
MultipartGenerator.registerPassThroughInterface("mekanism.api.transmitters.ITransmitter");
MultipartGenerator.registerPassThroughInterface("mekanism.api.IStrictEnergyAcceptor");
MultipartGenerator.registerPassThroughInterface("mekanism.api.transmitters.IGridTransmitter");
MultipartGenerator.registerPassThroughInterface("mekanism.common.ILogisticalTransporter");
MultipartGenerator.registerPassThroughInterface("ic2.api.energy.tile.IEnergySink");

View file

@ -5,10 +5,10 @@ import ic2.api.energy.event.EnergyTileUnloadEvent;
import ic2.api.energy.tile.IEnergySink;
import ic2.api.energy.tile.IEnergyTile;
import java.util.Arrays;
import java.util.Set;
import mekanism.api.Coord4D;
import mekanism.api.energy.IStrictEnergyAcceptor;
import mekanism.api.transmitters.IGridTransmitter;
import mekanism.api.transmitters.TransmissionType;
import mekanism.client.render.PartTransmitterIcons;
@ -22,14 +22,12 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.common.MinecraftForge;
import universalelectricity.core.block.IElectrical;
import universalelectricity.core.electricity.ElectricityPack;
import codechicken.lib.vec.Vector3;
import cofh.api.energy.IEnergyHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class PartUniversalCable extends PartTransmitter<EnergyNetwork> implements IEnergySink, IEnergyHandler, IElectrical
public class PartUniversalCable extends PartTransmitter<EnergyNetwork> implements IStrictEnergyAcceptor, IEnergySink, IEnergyHandler
{
public static PartTransmitterIcons cableIcons;
@ -252,41 +250,6 @@ public class PartUniversalCable extends PartTransmitter<EnergyNetwork> implement
return getTransmitterNetwork().emit(i*Mekanism.FROM_IC2)*Mekanism.TO_IC2;
}
@Override
public float receiveElectricity(ForgeDirection from, ElectricityPack receive, boolean doReceive)
{
if(doReceive && receive != null && receive.getWatts() > 0)
{
return receive.getWatts() - (float)(getTransmitterNetwork().emit(receive.getWatts()*Mekanism.FROM_UE));
}
return 0;
}
@Override
public ElectricityPack provideElectricity(ForgeDirection from, ElectricityPack request, boolean doProvide)
{
return null;
}
@Override
public float getRequest(ForgeDirection direction)
{
return (float)(getTransmitterNetwork().getEnergyNeeded()*Mekanism.TO_UE);
}
@Override
public float getProvide(ForgeDirection direction)
{
return 0;
}
@Override
public float getVoltage()
{
return 120;
}
@Override
public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate)
{
@ -327,4 +290,42 @@ public class PartUniversalCable extends PartTransmitter<EnergyNetwork> implement
{
return 10000;
}
@Override
public double transferEnergyToAcceptor(ForgeDirection side, double amount)
{
if(!canReceiveEnergy(side))
{
return amount;
}
double toUse = Math.min(getMaxEnergy()-getEnergy(), amount);
setEnergy(getEnergy() + toUse);
return amount-toUse;
}
@Override
public boolean canReceiveEnergy(ForgeDirection side)
{
return false;
}
@Override
public double getMaxEnergy()
{
return getTransmitterNetwork().getCapacity();
}
@Override
public double getEnergy()
{
return getTransmitterNetwork().electricityStored;
}
@Override
public void setEnergy(double energy)
{
getTransmitterNetwork().electricityStored = energy;
}
}

View file

@ -1,13 +1,5 @@
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.Coord4D;
@ -21,8 +13,12 @@ import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import buildcraft.api.power.IPowerReceptor;
import buildcraft.api.power.PowerHandler;
import buildcraft.api.power.PowerHandler.PowerReceiver;
import cofh.api.energy.IEnergyHandler;
public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock implements ISidedInventory, IEnergySink, IStrictEnergyAcceptor, IPowerReceptor, IEnergyTile, IElectrical, IElectricalStorage, IConnector, IStrictEnergyStorage, IEnergyHandler
public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock implements ISidedInventory, IEnergySink, IStrictEnergyAcceptor, IPowerReceptor, IEnergyTile, IStrictEnergyStorage, IEnergyHandler
{
@Override
public int getSizeInventory()
@ -283,105 +279,6 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp
return getInv().getMaxEnergy();
}
@Override
public boolean canConnect(ForgeDirection direction)
{
if(getInv() == null)
{
return false;
}
return getInv().canConnect(direction);
}
@Override
public void setEnergyStored(float energy)
{
if(getInv() == null)
{
return;
}
getInv().setEnergyStored(energy);
}
@Override
public float getEnergyStored()
{
if(getInv() == null)
{
return 0;
}
return getInv().getEnergyStored();
}
@Override
public float getMaxEnergyStored()
{
if(getInv() == null)
{
return 0;
}
return getInv().getMaxEnergyStored();
}
@Override
public float receiveElectricity(ForgeDirection from, ElectricityPack receive, boolean doReceive)
{
if(getInv() == null)
{
return 0;
}
return getInv().receiveElectricity(from, receive, doReceive);
}
@Override
public ElectricityPack provideElectricity(ForgeDirection from, ElectricityPack request, boolean doProvide)
{
if(getInv() == null)
{
return null;
}
return getInv().provideElectricity(from, request, doProvide);
}
@Override
public float getRequest(ForgeDirection direction)
{
if(getInv() == null)
{
return 0;
}
return getInv().getRequest(direction);
}
@Override
public float getProvide(ForgeDirection direction)
{
if(getInv() == null)
{
return 0;
}
return getInv().getProvide(direction);
}
@Override
public float getVoltage()
{
if(getInv() == null)
{
return 0;
}
return getInv().getVoltage();
}
@Override
public PowerReceiver getPowerReceiver(ForgeDirection side)
{

View file

@ -21,10 +21,6 @@ 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;
@ -32,7 +28,7 @@ import cofh.api.energy.IEnergyHandler;
import com.google.common.io.ByteArrayDataInput;
public abstract class TileEntityElectricBlock extends TileEntityContainerBlock implements ITileNetwork, IPowerReceptor, IEnergyTile, IElectrical, IElectricalStorage, IConnector, IStrictEnergyStorage, IEnergyHandler, IEnergySink, IEnergyStorage, IStrictEnergyAcceptor, ICableOutputter
public abstract class TileEntityElectricBlock extends TileEntityContainerBlock implements ITileNetwork, IPowerReceptor, IEnergyTile, IStrictEnergyStorage, IEnergyHandler, IEnergySink, IEnergyStorage, IStrictEnergyAcceptor, ICableOutputter
{
/** How much energy is stored in this block. */
public double electricityStored;
@ -94,12 +90,6 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
return 0;
}
@Override
public boolean canConnect(ForgeDirection direction)
{
return getConsumingSides().contains(direction) || getOutputtingSides().contains(direction);
}
@Override
public double getEnergy()
{
@ -119,12 +109,6 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
return MAX_ELECTRICITY;
}
@Override
public float getVoltage()
{
return (float)(120*Mekanism.TO_UE);
}
@Override
public void handlePacketData(ByteArrayDataInput dataStream)
{
@ -205,77 +189,6 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
return worldObj;
}
@Override
public float receiveElectricity(ForgeDirection from, ElectricityPack receive, boolean doReceive)
{
if(getConsumingSides().contains(from))
{
double toAdd = Math.min(getMaxEnergy()-getEnergy(), receive.getWatts()*Mekanism.FROM_UE);
if(doReceive)
{
setEnergy(getEnergy() + toAdd);
}
return (float)(toAdd*Mekanism.TO_UE);
}
return 0;
}
@Override
public ElectricityPack provideElectricity(ForgeDirection from, ElectricityPack request, boolean doProvide)
{
if(getOutputtingSides().contains(from))
{
double toSend = Math.min(getEnergy(), Math.min(getMaxOutput(), request.getWatts()*Mekanism.FROM_UE));
if(doProvide)
{
setEnergy(getEnergy() - toSend);
}
return ElectricityPack.getFromWatts((float)(toSend*Mekanism.TO_UE), getVoltage());
}
return new ElectricityPack();
}
@Override
public float getRequest(ForgeDirection direction)
{
if(getConsumingSides().contains(direction))
{
return getMaxEnergyStored()-getEnergyStored();
}
return 0;
}
@Override
public float getProvide(ForgeDirection direction)
{
return getOutputtingSides().contains(direction) ? Math.min(getEnergyStored(), (float)(getMaxOutput()*Mekanism.TO_UE)) : 0;
}
@Override
public void setEnergyStored(float energy)
{
setEnergy(energy*Mekanism.FROM_UE);
}
@Override
public float getEnergyStored()
{
return (float)(getEnergy()*Mekanism.TO_UE);
}
@Override
public float getMaxEnergyStored()
{
return (float)(getMaxEnergy()*Mekanism.TO_UE);
}
/**
* Gets the scaled energy level for the GUI.
* @param i - multiplier
@ -325,7 +238,7 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
@Override
public boolean canInterface(ForgeDirection from)
{
return canConnect(from);
return getConsumingSides().contains(from) || getOutputtingSides().contains(from);
}
@Override

View file

@ -142,12 +142,6 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements IPo
return false;
}
@Override
public float getVoltage()
{
return (float)(tier.VOLTAGE*Mekanism.TO_UE);
}
@Override
public String getType()
{

View file

@ -534,12 +534,6 @@ public class TileEntityLogisticalSorter extends TileEntityElectricBlock implemen
return EnumSet.noneOf(ForgeDirection.class);
}
@Override
public float getRequest(ForgeDirection direction)
{
return 0;
}
@Override
public boolean canSetFacing(int facing)
{

View file

@ -13,7 +13,6 @@ import mekanism.api.energy.ICableOutputter;
import mekanism.api.energy.IStrictEnergyAcceptor;
import mekanism.api.transmitters.IGridTransmitter;
import mekanism.api.transmitters.TransmissionType;
import mekanism.common.EnergyNetwork;
import mekanism.common.Mekanism;
import mekanism.common.tileentity.TileEntityElectricBlock;
import net.minecraft.tileentity.TileEntity;
@ -215,27 +214,6 @@ public final class CableUtils
return false;
}
/**
* Emits a defined amount of energy to the network, distributing between IC2-based and BuildCraft-based acceptors.
* @param amount - amount to send
* @param sender - sending TileEntity
* @param facing - direction the TileEntity is facing
* @return rejected energy
*/
public static double emitEnergyToNetwork(double amount, TileEntity sender, ForgeDirection facing)
{
TileEntity pointer = Coord4D.get(sender).getFromSide(facing).getTileEntity(sender.worldObj);
if(TransmissionType.checkTransmissionType(pointer, TransmissionType.ENERGY))
{
IGridTransmitter<EnergyNetwork> cable = (IGridTransmitter<EnergyNetwork>)pointer;
return cable.getTransmitterNetwork().emit(amount);
}
return amount;
}
public static void emit(TileEntityElectricBlock emitter)
{
if(!emitter.worldObj.isRemote && MekanismUtils.canFunction(emitter))
@ -310,55 +288,33 @@ public final class CableUtils
private static double emit_do_do(TileEntityElectricBlock from, TileEntity tileEntity, ForgeDirection side, double sendingEnergy)
{
if(TransmissionType.checkTransmissionType(tileEntity, TransmissionType.ENERGY))
{
sendingEnergy -= (sendingEnergy - emitEnergyToNetwork(sendingEnergy, from, side));
}
else if(tileEntity instanceof IStrictEnergyAcceptor)
if(tileEntity instanceof IStrictEnergyAcceptor)
{
IStrictEnergyAcceptor acceptor = (IStrictEnergyAcceptor)tileEntity;
sendingEnergy -= (sendingEnergy - acceptor.transferEnergyToAcceptor(side.getOpposite(), sendingEnergy));
}
else if(tileEntity instanceof IConductor)
{
ForgeDirection outputDirection = side;
float provide = from.getProvide(outputDirection);
if(provide > 0)
if(acceptor.canReceiveEnergy(side.getOpposite()))
{
IElectricityNetwork outputNetwork = ElectricityHelper.getNetworkFromTileEntity(tileEntity, outputDirection);
if(outputNetwork != null)
{
ElectricityPack request = outputNetwork.getRequest(from);
if(request.getWatts() > 0)
{
float ueSend = (float)(sendingEnergy*Mekanism.TO_UE);
ElectricityPack sendPack = ElectricityPack.min(ElectricityPack.getFromWatts(ueSend, from.getVoltage()), ElectricityPack.getFromWatts(provide, from.getVoltage()));
float rejectedPower = outputNetwork.produce(sendPack, from);
sendingEnergy -= (sendPack.getWatts() - rejectedPower)*Mekanism.FROM_UE;
}
}
sendingEnergy -= (sendingEnergy - acceptor.transferEnergyToAcceptor(side.getOpposite(), sendingEnergy));
}
}
else if(tileEntity instanceof IEnergyHandler)
{
IEnergyHandler handler = (IEnergyHandler)tileEntity;
int used = handler.receiveEnergy(side.getOpposite(), (int)Math.round(sendingEnergy*Mekanism.TO_TE), false);
sendingEnergy -= used*Mekanism.FROM_TE;
if(handler.canInterface(side.getOpposite()))
{
int used = handler.receiveEnergy(side.getOpposite(), (int)Math.round(sendingEnergy*Mekanism.TO_TE), false);
sendingEnergy -= used*Mekanism.FROM_TE;
}
}
else if(tileEntity instanceof IEnergySink)
{
double toSend = Math.min(sendingEnergy, Math.min(((IEnergySink)tileEntity).getMaxSafeInput(), ((IEnergySink)tileEntity).demandedEnergyUnits())*Mekanism.FROM_IC2);
double rejects = ((IEnergySink)tileEntity).injectEnergyUnits(side.getOpposite(), toSend*Mekanism.TO_IC2)*Mekanism.FROM_IC2;
sendingEnergy -= (toSend - rejects);
}
else if(tileEntity instanceof IElectrical)
{
double toSend = Math.min(sendingEnergy, ((IElectrical)tileEntity).getRequest(side.getOpposite())*Mekanism.FROM_UE);
ElectricityPack pack = ElectricityPack.getFromWatts((float)(toSend*Mekanism.TO_UE), ((IElectrical)tileEntity).getVoltage());
sendingEnergy -= (((IElectrical)tileEntity).receiveElectricity(side.getOpposite(), pack, true)*Mekanism.FROM_UE);
if(((IEnergySink)tileEntity).acceptsEnergyFrom(from, side.getOpposite()))
{
double toSend = Math.min(sendingEnergy, Math.min(((IEnergySink)tileEntity).getMaxSafeInput(), ((IEnergySink)tileEntity).demandedEnergyUnits())*Mekanism.FROM_IC2);
double rejects = ((IEnergySink)tileEntity).injectEnergyUnits(side.getOpposite(), toSend*Mekanism.TO_IC2)*Mekanism.FROM_IC2;
sendingEnergy -= (toSend - rejects);
}
}
else if(tileEntity instanceof IPowerReceptor && MekanismUtils.useBuildcraft())
{

View file

@ -27,7 +27,6 @@ import net.minecraftforge.fluids.FluidStack;
import org.lwjgl.input.Keyboard;
import universalelectricity.core.item.IItemElectric;
import cofh.api.energy.IEnergyContainerItem;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@ -44,7 +43,7 @@ import cpw.mods.fml.relauncher.SideOnly;
* @author AidanBrady
*
*/
public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, IItemElectric, ISpecialElectricItem, ISustainedInventory, ISustainedTank, IEnergyContainerItem
public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, ISpecialElectricItem, ISustainedInventory, ISustainedTank, IEnergyContainerItem
{
public Block metaBlock;
@ -96,12 +95,6 @@ public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, IIt
list.add(EnumColor.AQUA + "Inventory: " + EnumColor.GREY + (getInventory(itemstack) != null && getInventory(itemstack).tagCount() != 0));
}
}
@Override
public float getVoltage(ItemStack itemStack)
{
return (float)((itemStack.getItemDamage() == 3 ? 240 : 120)*Mekanism.TO_UE);
}
@Override
public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata)
@ -377,68 +370,6 @@ public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, IIt
return true;
}
@Override
public float recharge(ItemStack itemStack, float energy, boolean doRecharge)
{
if(canReceive(itemStack))
{
double energyNeeded = getMaxEnergy(itemStack)-getEnergy(itemStack);
double toReceive = Math.min(energy*Mekanism.FROM_UE, energyNeeded);
if(doRecharge)
{
setEnergy(itemStack, getEnergy(itemStack) + toReceive);
}
return (float)(toReceive*Mekanism.TO_UE);
}
return 0;
}
@Override
public float discharge(ItemStack itemStack, float energy, boolean doDischarge)
{
if(canSend(itemStack))
{
double energyRemaining = getEnergy(itemStack);
double toSend = Math.min((energy*Mekanism.FROM_UE), energyRemaining);
if(doDischarge)
{
setEnergy(itemStack, getEnergy(itemStack) - toSend);
}
return (float)(toSend*Mekanism.TO_UE);
}
return 0;
}
@Override
public float getElectricityStored(ItemStack theItem)
{
return (float)(getEnergy(theItem)*Mekanism.TO_UE);
}
@Override
public float getMaxElectricityStored(ItemStack theItem)
{
return (float)(getMaxEnergy(theItem)*Mekanism.TO_UE);
}
@Override
public void setElectricity(ItemStack itemStack, float joules)
{
setEnergy(itemStack, joules*Mekanism.TO_UE);
}
@Override
public float getTransfer(ItemStack itemStack)
{
return (float)(getMaxTransfer(itemStack)*Mekanism.TO_UE);
}
@Override
public IElectricItemManager getManager(ItemStack itemStack)
{

View file

@ -159,12 +159,6 @@ public class TileEntityHydrogenGenerator extends TileEntityGenerator implements
data.add(hydrogenStored);
return data;
}
@Override
public float getVoltage()
{
return 240;
}
@Override
public int receiveGas(ForgeDirection side, GasStack stack)