diff --git a/common/mekanism/common/block/BlockMachine.java b/common/mekanism/common/block/BlockMachine.java index 0eb86699a..047fee014 100644 --- a/common/mekanism/common/block/BlockMachine.java +++ b/common/mekanism/common/block/BlockMachine.java @@ -100,7 +100,7 @@ import cpw.mods.fml.relauncher.SideOnly; */ public class BlockMachine extends BlockContainer implements ISpecialBounds { - public Icon[][][] icons = new Icon[4096][16][16]; + public Icon[][] icons = new Icon[16][16]; public Random machineRand = new Random(); public BlockMachine(int id) @@ -117,34 +117,34 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds { if(blockID == Mekanism.machineBlockID) { - icons[blockID][0][0] = register.registerIcon("mekanism:EnrichmentChamberFrontOff"); - icons[blockID][0][1] = register.registerIcon("mekanism:EnrichmentChamberFrontOn"); - icons[blockID][0][2] = register.registerIcon("mekanism:SteelCasing"); - icons[blockID][1][0] = register.registerIcon("mekanism:OsmiumCompressorFrontOff"); - icons[blockID][1][1] = register.registerIcon("mekanism:OsmiumCompressorFrontOn"); - icons[blockID][1][2] = register.registerIcon("mekanism:SteelCasing"); - icons[blockID][2][0] = register.registerIcon("mekanism:CombinerFrontOff"); - icons[blockID][2][1] = register.registerIcon("mekanism:CombinerFrontOn"); - icons[blockID][2][2] = register.registerIcon("mekanism:SteelCasing"); - icons[blockID][3][0] = register.registerIcon("mekanism:CrusherFrontOff"); - icons[blockID][3][1] = register.registerIcon("mekanism:CrusherFrontOn"); - icons[blockID][3][2] = register.registerIcon("mekanism:SteelCasing"); - icons[blockID][5][0] = register.registerIcon("mekanism:BasicFactoryFront"); - icons[blockID][5][1] = register.registerIcon("mekanism:BasicFactorySide"); - icons[blockID][5][2] = register.registerIcon("mekanism:BasicFactoryTop"); - icons[blockID][6][0] = register.registerIcon("mekanism:AdvancedFactoryFront"); - icons[blockID][6][1] = register.registerIcon("mekanism:AdvancedFactorySide"); - icons[blockID][6][2] = register.registerIcon("mekanism:AdvancedFactoryTop"); - icons[blockID][7][0] = register.registerIcon("mekanism:EliteFactoryFront"); - icons[blockID][7][1] = register.registerIcon("mekanism:EliteFactorySide"); - icons[blockID][7][2] = register.registerIcon("mekanism:EliteFactoryTop"); - icons[blockID][9][0] = register.registerIcon("mekanism:PurificationChamberFrontOff"); - icons[blockID][9][1] = register.registerIcon("mekanism:PurificationChamberFrontOn"); - icons[blockID][9][2] = register.registerIcon("mekanism:SteelCasing"); - icons[blockID][10][0] = register.registerIcon("mekanism:EnergizedSmelterFrontOff"); - icons[blockID][10][1] = register.registerIcon("mekanism:EnergizedSmelterFrontOn"); - icons[blockID][10][2] = register.registerIcon("mekanism:SteelCasing"); - icons[blockID][11][0] = register.registerIcon("mekanism:Teleporter"); + icons[0][0] = register.registerIcon("mekanism:EnrichmentChamberFrontOff"); + icons[0][1] = register.registerIcon("mekanism:EnrichmentChamberFrontOn"); + icons[0][2] = register.registerIcon("mekanism:SteelCasing"); + icons[1][0] = register.registerIcon("mekanism:OsmiumCompressorFrontOff"); + icons[1][1] = register.registerIcon("mekanism:OsmiumCompressorFrontOn"); + icons[1][2] = register.registerIcon("mekanism:SteelCasing"); + icons[2][0] = register.registerIcon("mekanism:CombinerFrontOff"); + icons[2][1] = register.registerIcon("mekanism:CombinerFrontOn"); + icons[2][2] = register.registerIcon("mekanism:SteelCasing"); + icons[3][0] = register.registerIcon("mekanism:CrusherFrontOff"); + icons[3][1] = register.registerIcon("mekanism:CrusherFrontOn"); + icons[3][2] = register.registerIcon("mekanism:SteelCasing"); + icons[5][0] = register.registerIcon("mekanism:BasicFactoryFront"); + icons[5][1] = register.registerIcon("mekanism:BasicFactorySide"); + icons[5][2] = register.registerIcon("mekanism:BasicFactoryTop"); + icons[6][0] = register.registerIcon("mekanism:AdvancedFactoryFront"); + icons[6][1] = register.registerIcon("mekanism:AdvancedFactorySide"); + icons[6][2] = register.registerIcon("mekanism:AdvancedFactoryTop"); + icons[7][0] = register.registerIcon("mekanism:EliteFactoryFront"); + icons[7][1] = register.registerIcon("mekanism:EliteFactorySide"); + icons[7][2] = register.registerIcon("mekanism:EliteFactoryTop"); + icons[9][0] = register.registerIcon("mekanism:PurificationChamberFrontOff"); + icons[9][1] = register.registerIcon("mekanism:PurificationChamberFrontOn"); + icons[9][2] = register.registerIcon("mekanism:SteelCasing"); + icons[10][0] = register.registerIcon("mekanism:EnergizedSmelterFrontOff"); + icons[10][1] = register.registerIcon("mekanism:EnergizedSmelterFrontOn"); + icons[10][2] = register.registerIcon("mekanism:SteelCasing"); + icons[11][0] = register.registerIcon("mekanism:Teleporter"); } } @@ -289,107 +289,107 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds { if(side == 3) { - return icons[blockID][0][0]; + return icons[0][0]; } else { - return icons[blockID][0][2]; + return icons[0][2]; } } else if(meta == 1) { if(side == 3) { - return icons[blockID][1][0]; + return icons[1][0]; } else { - return icons[blockID][1][2]; + return icons[1][2]; } } else if(meta == 2) { if(side == 3) { - return icons[blockID][2][0]; + return icons[2][0]; } else { - return icons[blockID][2][2]; + return icons[2][2]; } } else if(meta == 3) { if(side == 3) { - return icons[blockID][3][0]; + return icons[3][0]; } else { - return icons[blockID][3][2]; + return icons[3][2]; } } else if(meta == 5) { if(side == 3) { - return icons[blockID][5][0]; + return icons[5][0]; } else if(side == 0 || side == 1) { - return icons[blockID][5][2]; + return icons[5][2]; } else { - return icons[blockID][5][1]; + return icons[5][1]; } } else if(meta == 6) { if(side == 3) { - return icons[blockID][6][0]; + return icons[6][0]; } else if(side == 0 || side == 1) { - return icons[blockID][6][2]; + return icons[6][2]; } else { - return icons[blockID][6][1]; + return icons[6][1]; } } else if(meta == 7) { if(side == 3) { - return icons[blockID][7][0]; + return icons[7][0]; } else if(side == 0 || side == 1) { - return icons[blockID][7][2]; + return icons[7][2]; } else { - return icons[blockID][7][1]; + return icons[7][1]; } } else if(meta == 9) { if(side == 3) { - return icons[blockID][9][0]; + return icons[9][0]; } else { - return icons[blockID][9][2]; + return icons[9][2]; } } else if(meta == 10) { if(side == 3) { - return icons[blockID][10][0]; + return icons[10][0]; } else { - return icons[blockID][10][2]; + return icons[10][2]; } } else if(meta == 11) { - return icons[blockID][11][0]; + return icons[11][0]; } } @@ -409,107 +409,107 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds { if(side == tileEntity.facing) { - return MekanismUtils.isActive(world, x, y, z) ? icons[blockID][0][1] : icons[blockID][0][0]; + return MekanismUtils.isActive(world, x, y, z) ? icons[0][1] : icons[0][0]; } else { - return icons[blockID][0][2]; + return icons[0][2]; } } else if(metadata == 1) { if(side == tileEntity.facing) { - return MekanismUtils.isActive(world, x, y, z) ? icons[blockID][1][1] : icons[blockID][1][0]; + return MekanismUtils.isActive(world, x, y, z) ? icons[1][1] : icons[1][0]; } else { - return icons[blockID][1][2]; + return icons[1][2]; } } else if(metadata == 2) { if(side == tileEntity.facing) { - return MekanismUtils.isActive(world, x, y, z) ? icons[blockID][2][1] : icons[blockID][2][0]; + return MekanismUtils.isActive(world, x, y, z) ? icons[2][1] : icons[2][0]; } else { - return icons[blockID][2][2]; + return icons[2][2]; } } else if(metadata == 3) { if(side == tileEntity.facing) { - return MekanismUtils.isActive(world, x, y, z) ? icons[blockID][3][1] : icons[blockID][3][0]; + return MekanismUtils.isActive(world, x, y, z) ? icons[3][1] : icons[3][0]; } else { - return icons[blockID][3][2]; + return icons[3][2]; } } else if(metadata == 5) { if(side == tileEntity.facing) { - return icons[blockID][5][0]; + return icons[5][0]; } else if(side == 0 || side == 1) { - return icons[blockID][5][2]; + return icons[5][2]; } else { - return icons[blockID][5][1]; + return icons[5][1]; } } else if(metadata == 6) { if(side == tileEntity.facing) { - return icons[blockID][6][0]; + return icons[6][0]; } else if(side == 0 || side == 1) { - return icons[blockID][6][2]; + return icons[6][2]; } else { - return icons[blockID][6][1]; + return icons[6][1]; } } else if(metadata == 7) { if(side == tileEntity.facing) { - return icons[blockID][7][0]; + return icons[7][0]; } else if(side == 0 || side == 1) { - return icons[blockID][7][2]; + return icons[7][2]; } else { - return icons[blockID][7][1]; + return icons[7][1]; } } else if(metadata == 9) { if(side == tileEntity.facing) { - return MekanismUtils.isActive(world, x, y, z) ? icons[blockID][9][1] : icons[blockID][9][0]; + return MekanismUtils.isActive(world, x, y, z) ? icons[9][1] : icons[9][0]; } else { - return icons[blockID][9][2]; + return icons[9][2]; } } else if(metadata == 10) { if(side == tileEntity.facing) { - return MekanismUtils.isActive(world, x, y, z) ? icons[blockID][10][1] : icons[blockID][10][0]; + return MekanismUtils.isActive(world, x, y, z) ? icons[10][1] : icons[10][0]; } else { - return icons[blockID][10][2]; + return icons[10][2]; } } else if(metadata == 11) { - return icons[blockID][11][0]; + return icons[11][0]; } } diff --git a/common/mekanism/common/tileentity/TileEntityElectricBlock.java b/common/mekanism/common/tileentity/TileEntityElectricBlock.java index ba6b50580..9a19ac6ce 100644 --- a/common/mekanism/common/tileentity/TileEntityElectricBlock.java +++ b/common/mekanism/common/tileentity/TileEntityElectricBlock.java @@ -77,7 +77,7 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i reconfigure(); } - public ForgeDirection getOutputtingSide() + public EnumSet getOutputtingSides() { return null; } @@ -95,7 +95,7 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i @Override public boolean canConnect(ForgeDirection direction) { - return getConsumingSides().contains(direction) || getOutputtingSide() == direction; + return getConsumingSides().contains(direction) || getOutputtingSides().contains(direction); } @Override @@ -224,7 +224,7 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i @Override public ElectricityPack provideElectricity(ForgeDirection from, ElectricityPack request, boolean doProvide) { - if(getOutputtingSide() == from) + if(getOutputtingSides().contains(from)) { double toSend = Math.min(getEnergy(), Math.min(getMaxOutput(), request.getWatts()*Mekanism.FROM_UE)); @@ -253,7 +253,7 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i @Override public float getProvide(ForgeDirection direction) { - return getOutputtingSide() == direction ? Math.min(getEnergyStored(), (float)(getMaxOutput()*Mekanism.TO_UE)) : 0; + return getOutputtingSides().contains(direction) ? Math.min(getEnergyStored(), (float)(getMaxOutput()*Mekanism.TO_UE)) : 0; } @Override @@ -305,7 +305,7 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i @Override public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) { - if(getOutputtingSide() == from) + if(getOutputtingSides().contains(from)) { double toSend = Math.min(getEnergy(), Math.min(getMaxOutput(), maxExtract*Mekanism.FROM_TE)); @@ -360,19 +360,19 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i @Override public boolean isTeleporterCompatible(ForgeDirection side) { - return side == getOutputtingSide(); + return getOutputtingSides().contains(side); } @Override public boolean canOutputTo(ForgeDirection side) { - return side == getOutputtingSide(); + return getOutputtingSides().contains(side); } @Override public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction) { - return direction != getOutputtingSide(); + return !getOutputtingSides().contains(direction); } @Override @@ -402,7 +402,7 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i @Override public boolean canReceiveEnergy(ForgeDirection side) { - return side != getOutputtingSide(); + return !getOutputtingSides().contains(side); } @Override diff --git a/common/mekanism/common/tileentity/TileEntityEnergyCube.java b/common/mekanism/common/tileentity/TileEntityEnergyCube.java index d88dae277..48f3f50b3 100644 --- a/common/mekanism/common/tileentity/TileEntityEnergyCube.java +++ b/common/mekanism/common/tileentity/TileEntityEnergyCube.java @@ -91,15 +91,15 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements IPo protected EnumSet getConsumingSides() { EnumSet set = EnumSet.allOf(ForgeDirection.class); - set.remove(getOutputtingSide()); + set.remove(getOutputtingSides()); return set; } @Override - public ForgeDirection getOutputtingSide() + public EnumSet getOutputtingSides() { - return ForgeDirection.getOrientation(facing); + return EnumSet.of(ForgeDirection.getOrientation(facing)); } @Override diff --git a/common/mekanism/common/util/CableUtils.java b/common/mekanism/common/util/CableUtils.java index fef523b23..e8b12b252 100644 --- a/common/mekanism/common/util/CableUtils.java +++ b/common/mekanism/common/util/CableUtils.java @@ -6,8 +6,8 @@ import ic2.api.energy.tile.IEnergySource; import java.util.ArrayList; import java.util.Arrays; -import java.util.HashSet; -import java.util.Set; +import java.util.EnumSet; +import java.util.List; import mekanism.api.Object3D; import mekanism.api.energy.ICableOutputter; @@ -17,7 +17,6 @@ import mekanism.api.transmitters.TransmissionType; import mekanism.common.EnergyNetwork; import mekanism.common.Mekanism; import mekanism.common.tileentity.TileEntityElectricBlock; -import mekanism.induction.common.tileentity.TileEntityTesla; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.ForgeDirection; import universalelectricity.core.block.IConductor; @@ -225,78 +224,130 @@ public final class CableUtils public static void emit(TileEntityElectricBlock emitter) { - if(!emitter.worldObj.isRemote && MekanismUtils.canFunction(emitter)) - { - TileEntity tileEntity = Object3D.get(emitter).getFromSide(emitter.getOutputtingSide()).getTileEntity(emitter.worldObj); + if(!emitter.worldObj.isRemote && MekanismUtils.canFunction(emitter)) + { + double sendingEnergy = Math.min(emitter.getEnergy(), emitter.getMaxOutput()); - if(emitter.getEnergy() > 0) + if(sendingEnergy > 0) { - if(TransmissionType.checkTransmissionType(tileEntity, TransmissionType.ENERGY)) - { - double energyToSend = Math.min(emitter.getEnergy(), emitter.getMaxOutput()); - emitter.setEnergy(emitter.getEnergy() - (energyToSend - emitEnergyToNetwork(energyToSend, emitter, emitter.getOutputtingSide()))); - return; - } - else if(tileEntity instanceof IStrictEnergyAcceptor) - { - IStrictEnergyAcceptor acceptor = (IStrictEnergyAcceptor)tileEntity; - double toSend = Math.min(emitter.getEnergy(), emitter.getMaxOutput()); - emitter.setEnergy(emitter.getEnergy() - (toSend - acceptor.transferEnergyToAcceptor(emitter.getOutputtingSide().getOpposite(), toSend))); - } - else if(tileEntity instanceof IEnergyHandler) - { - IEnergyHandler handler = (IEnergyHandler)tileEntity; - double toSend = Math.min(emitter.getEnergy(), emitter.getMaxOutput()); - int used = handler.receiveEnergy(emitter.getOutputtingSide().getOpposite(), (int)Math.round(toSend*Mekanism.TO_TE), false); - emitter.setEnergy(emitter.getEnergy() - used*Mekanism.FROM_TE); - } - else if(tileEntity instanceof IEnergySink) - { - double toSend = Math.min(emitter.getEnergy(), (((IEnergySink)tileEntity).getMaxSafeInput()*Mekanism.FROM_IC2)); - double rejects = ((IEnergySink)tileEntity).injectEnergyUnits(emitter.getOutputtingSide().getOpposite(), toSend*Mekanism.TO_IC2)*Mekanism.FROM_IC2; - emitter.setEnergy(emitter.getEnergy() - (toSend - rejects)); - } - else if(tileEntity instanceof IElectrical) - { - double toSend = Math.min(emitter.getEnergy(), ((IElectrical)tileEntity).getRequest(emitter.getOutputtingSide().getOpposite())*Mekanism.FROM_UE); - ElectricityPack pack = ElectricityPack.getFromWatts((float)(toSend*Mekanism.TO_UE), ((IElectrical)tileEntity).getVoltage()); - emitter.setEnergy(emitter.getEnergy() - (((IElectrical)tileEntity).receiveElectricity(emitter.getOutputtingSide().getOpposite(), pack, true)*Mekanism.FROM_UE)); - } - else if(tileEntity instanceof IPowerReceptor && MekanismUtils.useBuildcraft()) - { - PowerReceiver receiver = ((IPowerReceptor)tileEntity).getPowerReceiver(emitter.getOutputtingSide().getOpposite()); - - if(receiver != null) - { - double transferEnergy = Math.min(emitter.getEnergy(), Math.min(receiver.powerRequest()*Mekanism.FROM_BC, emitter.getMaxOutput())); - float sent = receiver.receiveEnergy(Type.STORAGE, (float)(transferEnergy*Mekanism.TO_BC), emitter.getOutputtingSide().getOpposite()); - emitter.setEnergy(emitter.getEnergy() - sent); - } - } + List outputtingSides = new ArrayList(); + boolean[] connectable = getConnections(emitter); + + for(ForgeDirection side : emitter.getOutputtingSides()) + { + if(connectable[side.ordinal()]) + { + outputtingSides.add(side); + } + } + + if(outputtingSides.size() > 0) + { + double totalToSend = sendingEnergy; + + boolean cont = false; + + do { + cont = false; + double prev = totalToSend; + totalToSend -= (totalToSend - emit_do(emitter, outputtingSides, totalToSend)); + + if(prev-totalToSend > 0 && totalToSend > 0) + { + cont = true; + } + } while(cont); + + emitter.setEnergy(emitter.getEnergy() - (sendingEnergy - totalToSend)); + } } - - if(tileEntity instanceof IConductor) - { - ForgeDirection outputDirection = emitter.getOutputtingSide(); - float provide = emitter.getProvide(outputDirection); - - if(provide > 0) - { - IElectricityNetwork outputNetwork = ElectricityHelper.getNetworkFromTileEntity(tileEntity, outputDirection); + } + } + + private static double emit_do(TileEntityElectricBlock emitter, List outputtingSides, double totalToSend) + { + double remains = totalToSend%outputtingSides.size(); + double splitSend = (totalToSend-remains)/outputtingSides.size(); - if(outputNetwork != null) + for(ForgeDirection side : outputtingSides) + { + TileEntity tileEntity = Object3D.get(emitter).getFromSide(side).getTileEntity(emitter.worldObj); + double toSend = splitSend+remains; + remains = 0; + + totalToSend -= (toSend - emit_do_do(emitter, tileEntity, side, toSend)); + } + + return totalToSend; + } + + /** + * @return rejects + */ + 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) + { + IStrictEnergyAcceptor acceptor = (IStrictEnergyAcceptor)tileEntity; + 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; + } + 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); + } + 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; + } + } + else if(tileEntity instanceof IConductor) + { + ForgeDirection outputDirection = side; + float provide = from.getProvide(outputDirection); + + if(provide > 0) + { + IElectricityNetwork outputNetwork = ElectricityHelper.getNetworkFromTileEntity(tileEntity, outputDirection); + + if(outputNetwork != null) + { + ElectricityPack request = outputNetwork.getRequest(from); + + if(request.getWatts() > 0) { - ElectricityPack request = outputNetwork.getRequest(emitter); - - if(request.getWatts() > 0) - { - ElectricityPack sendPack = ElectricityPack.min(ElectricityPack.getFromWatts(emitter.getEnergyStored(), emitter.getVoltage()), ElectricityPack.getFromWatts(provide, emitter.getVoltage())); - float rejectedPower = outputNetwork.produce(sendPack, emitter); - emitter.setEnergyStored(emitter.getEnergyStored() - (sendPack.getWatts() - rejectedPower)); - } + 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; } } } } + + return sendingEnergy; } } diff --git a/common/mekanism/generators/common/tileentity/TileEntityAdvancedSolarGenerator.java b/common/mekanism/generators/common/tileentity/TileEntityAdvancedSolarGenerator.java index 44d893457..230d4df6a 100644 --- a/common/mekanism/generators/common/tileentity/TileEntityAdvancedSolarGenerator.java +++ b/common/mekanism/generators/common/tileentity/TileEntityAdvancedSolarGenerator.java @@ -1,10 +1,12 @@ package mekanism.generators.common.tileentity; -import net.minecraftforge.common.ForgeDirection; +import java.util.EnumSet; + import mekanism.api.Object3D; import mekanism.common.IBoundingBlock; import mekanism.common.util.MekanismUtils; import mekanism.generators.common.MekanismGenerators; +import net.minecraftforge.common.ForgeDirection; public class TileEntityAdvancedSolarGenerator extends TileEntitySolarGenerator implements IBoundingBlock { @@ -14,9 +16,9 @@ public class TileEntityAdvancedSolarGenerator extends TileEntitySolarGenerator i } @Override - public ForgeDirection getOutputtingSide() + public EnumSet getOutputtingSides() { - return ForgeDirection.getOrientation(facing); + return EnumSet.of(ForgeDirection.getOrientation(facing)); } @Override diff --git a/common/mekanism/generators/common/tileentity/TileEntityBioGenerator.java b/common/mekanism/generators/common/tileentity/TileEntityBioGenerator.java index c68aebbd6..215079c34 100644 --- a/common/mekanism/generators/common/tileentity/TileEntityBioGenerator.java +++ b/common/mekanism/generators/common/tileentity/TileEntityBioGenerator.java @@ -1,13 +1,13 @@ package mekanism.generators.common.tileentity; import java.util.ArrayList; +import java.util.EnumSet; import mekanism.client.sound.Sound; import mekanism.common.FluidSlot; import mekanism.common.util.ChargeUtils; import mekanism.common.util.MekanismUtils; import mekanism.generators.common.MekanismGenerators; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.ForgeDirection; @@ -220,9 +220,9 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements IFlui } @Override - public ForgeDirection getOutputtingSide() + public EnumSet getOutputtingSides() { - return ForgeDirection.getOrientation(facing).getOpposite(); + return EnumSet.of(ForgeDirection.getOrientation(facing).getOpposite()); } @Override diff --git a/common/mekanism/generators/common/tileentity/TileEntityGenerator.java b/common/mekanism/generators/common/tileentity/TileEntityGenerator.java index 411c53586..b3c21617d 100644 --- a/common/mekanism/generators/common/tileentity/TileEntityGenerator.java +++ b/common/mekanism/generators/common/tileentity/TileEntityGenerator.java @@ -33,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 IEnergySource, IEnergyStorage, IPowerReceptor, IPeripheral, IActiveState, IHasSound, ICableOutputter, IRedstoneControl, IPowerEmitter +public abstract class TileEntityGenerator extends TileEntityElectricBlock implements IPowerReceptor, IPeripheral, IActiveState, IHasSound, IRedstoneControl, IPowerEmitter { /** Output per tick this generator can transfer. */ public double output; @@ -121,15 +121,9 @@ public abstract class TileEntityGenerator extends TileEntityElectricBlock implem } @Override - public ForgeDirection getOutputtingSide() + public EnumSet getOutputtingSides() { - return ForgeDirection.getOrientation(facing); - } - - @Override - public float getRequest(ForgeDirection direction) - { - return 0; + return EnumSet.of(ForgeDirection.getOrientation(facing)); } @Override @@ -187,72 +181,12 @@ public abstract class TileEntityGenerator extends TileEntityElectricBlock implem @Override public void detach(IComputerAccess computer) {} - @Override - public double getOutputEnergyUnitsPerTick() - { - return output*Mekanism.TO_IC2; - } - @Override public boolean canSetFacing(int side) { return side != 0 && side != 1; } - @Override - public boolean emitsEnergyTo(TileEntity receiver, ForgeDirection direction) - { - return direction == getOutputtingSide() && !(receiver instanceof TileEntityUniversalCable); - } - - @Override - public int getStored() - { - return (int)(getEnergy()*Mekanism.TO_IC2); - } - - @Override - public int getCapacity() - { - return (int)(getMaxEnergy()*Mekanism.TO_IC2); - } - - @Override - public int getOutput() - { - return (int)(output*Mekanism.TO_IC2); - } - - @Override - public boolean isTeleporterCompatible(ForgeDirection side) - { - return getOutputtingSide() == side; - } - - @Override - public int addEnergy(int amount) - { - return (int)(getEnergy()*Mekanism.TO_IC2); - } - - @Override - public void setStored(int energy) - { - setEnergy(energy*Mekanism.FROM_IC2); - } - - @Override - public double getOfferedEnergy() - { - return Math.min(getEnergy()*Mekanism.TO_IC2, getOutput()); - } - - @Override - public void drawEnergy(double amount) - { - setEnergy(getEnergy()-amount*Mekanism.FROM_IC2); - } - @Override public void handlePacketData(ByteArrayDataInput dataStream) { @@ -305,12 +239,6 @@ public abstract class TileEntityGenerator extends TileEntityElectricBlock implem return INFINITE_EXTENT_AABB; } - @Override - public boolean canOutputTo(ForgeDirection side) - { - return getOutputtingSide() == side; - } - @Override public String getSoundPath() { @@ -351,7 +279,7 @@ public abstract class TileEntityGenerator extends TileEntityElectricBlock implem @Override public boolean canEmitPowerFrom(ForgeDirection side) { - return getOutputtingSide() == side; + return getOutputtingSides().contains(side); } @Override diff --git a/common/mekanism/generators/common/tileentity/TileEntitySolarGenerator.java b/common/mekanism/generators/common/tileentity/TileEntitySolarGenerator.java index bac5d87b3..3590f12ff 100644 --- a/common/mekanism/generators/common/tileentity/TileEntitySolarGenerator.java +++ b/common/mekanism/generators/common/tileentity/TileEntitySolarGenerator.java @@ -178,9 +178,9 @@ public class TileEntitySolarGenerator extends TileEntityGenerator } @Override - public ForgeDirection getOutputtingSide() + public EnumSet getOutputtingSides() { - return ForgeDirection.getOrientation(0); + return EnumSet.of(ForgeDirection.getOrientation(0)); } @Override diff --git a/common/mekanism/induction/common/tileentity/TileEntityTesla.java b/common/mekanism/induction/common/tileentity/TileEntityTesla.java index c94678aaa..468e04c59 100644 --- a/common/mekanism/induction/common/tileentity/TileEntityTesla.java +++ b/common/mekanism/induction/common/tileentity/TileEntityTesla.java @@ -3,6 +3,7 @@ package mekanism.induction.common.tileentity; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; +import java.util.EnumSet; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -590,8 +591,8 @@ public class TileEntityTesla extends TileEntityElectricBlock implements ITesla } @Override - public ForgeDirection getOutputtingSide() + public EnumSet getOutputtingSides() { - return ForgeDirection.DOWN; + return EnumSet.of(ForgeDirection.DOWN); } } \ No newline at end of file