Closes #593 Updating RF Integration to use version 1.7.10R1.0.2
The new update contained a split of the IEnergyHandler into the IEnergyReceiver and IEnergyProvider. Since all tiles in AE2 are basically IEnergyReceivers we use them and changed the detection of opposing tile entities from IEnergyHandler to IEnergyReceiver
This commit is contained in:
parent
2af5a17054
commit
825567c122
7 changed files with 133 additions and 134 deletions
|
@ -36,6 +36,6 @@ api_mekansim_version=1
|
||||||
api_mfr_version=1
|
api_mfr_version=1
|
||||||
api_railcraft_version=1
|
api_railcraft_version=1
|
||||||
api_rblocks_version=1
|
api_rblocks_version=1
|
||||||
api_rf_version=1
|
api_rf_version=2
|
||||||
api_rotarycraft_version=1
|
api_rotarycraft_version=1
|
||||||
dev_buildcraft_version=1
|
dev_buildcraft_version=1
|
||||||
|
|
|
@ -560,7 +560,7 @@ public class Registration
|
||||||
ph.registerNewLayer( "appeng.parts.layers.LayerIBatteryProvider", "buildcraft.api.mj.IBatteryProvider" );
|
ph.registerNewLayer( "appeng.parts.layers.LayerIBatteryProvider", "buildcraft.api.mj.IBatteryProvider" );
|
||||||
|
|
||||||
if ( AppEng.instance.isIntegrationEnabled( IntegrationType.RF ) )
|
if ( AppEng.instance.isIntegrationEnabled( IntegrationType.RF ) )
|
||||||
ph.registerNewLayer( "appeng.parts.layers.LayerIEnergyHandler", "cofh.api.energy.IEnergyHandler" );
|
ph.registerNewLayer( "appeng.parts.layers.LayerIEnergyHandler", "cofh.api.energy.IEnergyReceiver" );
|
||||||
|
|
||||||
FMLCommonHandler.instance().bus().register( TickHandler.instance );
|
FMLCommonHandler.instance().bus().register( TickHandler.instance );
|
||||||
MinecraftForge.EVENT_BUS.register( TickHandler.instance );
|
MinecraftForge.EVENT_BUS.register( TickHandler.instance );
|
||||||
|
|
|
@ -31,6 +31,8 @@ public class RF extends BaseModule
|
||||||
public static RF instance;
|
public static RF instance;
|
||||||
|
|
||||||
public RF() {
|
public RF() {
|
||||||
|
TestClass( cofh.api.energy.IEnergyReceiver.class );
|
||||||
|
TestClass( cofh.api.energy.IEnergyProvider.class );
|
||||||
TestClass( cofh.api.energy.IEnergyHandler.class );
|
TestClass( cofh.api.energy.IEnergyHandler.class );
|
||||||
TestClass( cofh.api.energy.IEnergyConnection.class );
|
TestClass( cofh.api.energy.IEnergyConnection.class );
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,40 +18,36 @@
|
||||||
|
|
||||||
package appeng.integration.modules.helpers;
|
package appeng.integration.modules.helpers;
|
||||||
|
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
|
||||||
import cofh.api.energy.IEnergyHandler;
|
|
||||||
|
|
||||||
public class NullRFHandler implements IEnergyHandler
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
|
import cofh.api.energy.IEnergyReceiver;
|
||||||
|
|
||||||
|
|
||||||
|
public class NullRFHandler implements IEnergyReceiver
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate)
|
public int receiveEnergy( ForgeDirection from, int maxReceive, boolean simulate )
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate)
|
public int getEnergyStored( ForgeDirection from )
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getEnergyStored(ForgeDirection from)
|
public int getMaxEnergyStored( ForgeDirection from )
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMaxEnergyStored(ForgeDirection from)
|
public boolean canConnectEnergy( ForgeDirection from )
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canConnectEnergy(ForgeDirection from)
|
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,12 @@ package appeng.parts.layers;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
import appeng.api.parts.IPart;
|
import appeng.api.parts.IPart;
|
||||||
import appeng.api.parts.LayerBase;
|
import appeng.api.parts.LayerBase;
|
||||||
|
|
||||||
|
import cofh.api.energy.IEnergyConnection;
|
||||||
import cofh.api.energy.IEnergyHandler;
|
import cofh.api.energy.IEnergyHandler;
|
||||||
|
import cofh.api.energy.IEnergyProvider;
|
||||||
|
import cofh.api.energy.IEnergyReceiver;
|
||||||
|
|
||||||
|
|
||||||
public class LayerIEnergyHandler extends LayerBase implements IEnergyHandler
|
public class LayerIEnergyHandler extends LayerBase implements IEnergyHandler
|
||||||
{
|
{
|
||||||
|
@ -29,9 +34,9 @@ public class LayerIEnergyHandler extends LayerBase implements IEnergyHandler
|
||||||
@Override
|
@Override
|
||||||
public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate)
|
public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate)
|
||||||
{
|
{
|
||||||
IPart part = getPart( from );
|
IPart part = this.getPart( from );
|
||||||
if ( part instanceof IEnergyHandler )
|
if ( part instanceof IEnergyReceiver )
|
||||||
return ((IEnergyHandler) part).receiveEnergy( from, maxReceive, simulate );
|
return ((IEnergyReceiver) part).receiveEnergy( from, maxReceive, simulate );
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -39,9 +44,9 @@ public class LayerIEnergyHandler extends LayerBase implements IEnergyHandler
|
||||||
@Override
|
@Override
|
||||||
public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate)
|
public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate)
|
||||||
{
|
{
|
||||||
IPart part = getPart( from );
|
IPart part = this.getPart( from );
|
||||||
if ( part instanceof IEnergyHandler )
|
if ( part instanceof IEnergyProvider )
|
||||||
return ((IEnergyHandler) part).extractEnergy( from, maxExtract, simulate );
|
return ((IEnergyProvider) part).extractEnergy( from, maxExtract, simulate );
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -49,9 +54,9 @@ public class LayerIEnergyHandler extends LayerBase implements IEnergyHandler
|
||||||
@Override
|
@Override
|
||||||
public int getEnergyStored(ForgeDirection from)
|
public int getEnergyStored(ForgeDirection from)
|
||||||
{
|
{
|
||||||
IPart part = getPart( from );
|
IPart part = this.getPart( from );
|
||||||
if ( part instanceof IEnergyHandler )
|
if ( part instanceof IEnergyProvider )
|
||||||
return ((IEnergyHandler) part).getEnergyStored( from );
|
return ((IEnergyProvider) part).getEnergyStored( from );
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -59,9 +64,9 @@ public class LayerIEnergyHandler extends LayerBase implements IEnergyHandler
|
||||||
@Override
|
@Override
|
||||||
public int getMaxEnergyStored(ForgeDirection from)
|
public int getMaxEnergyStored(ForgeDirection from)
|
||||||
{
|
{
|
||||||
IPart part = getPart( from );
|
IPart part = this.getPart( from );
|
||||||
if ( part instanceof IEnergyHandler )
|
if ( part instanceof IEnergyProvider )
|
||||||
return ((IEnergyHandler) part).getMaxEnergyStored( from );
|
return ((IEnergyProvider) part).getMaxEnergyStored( from );
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -69,9 +74,9 @@ public class LayerIEnergyHandler extends LayerBase implements IEnergyHandler
|
||||||
@Override
|
@Override
|
||||||
public boolean canConnectEnergy(ForgeDirection from)
|
public boolean canConnectEnergy(ForgeDirection from)
|
||||||
{
|
{
|
||||||
IPart part = getPart( from );
|
IPart part = this.getPart( from );
|
||||||
if ( part instanceof IEnergyHandler )
|
if ( part instanceof IEnergyConnection )
|
||||||
return ((IEnergyHandler) part).canConnectEnergy( from );
|
return ((IEnergyConnection) part).canConnectEnergy( from );
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
package appeng.parts.p2p;
|
package appeng.parts.p2p;
|
||||||
|
|
||||||
|
|
||||||
import java.util.Stack;
|
import java.util.Stack;
|
||||||
|
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
|
@ -25,6 +26,12 @@ import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.IIcon;
|
import net.minecraft.util.IIcon;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
|
import cofh.api.energy.IEnergyReceiver;
|
||||||
|
|
||||||
import appeng.api.config.PowerUnits;
|
import appeng.api.config.PowerUnits;
|
||||||
import appeng.api.config.TunnelType;
|
import appeng.api.config.TunnelType;
|
||||||
import appeng.core.AppEng;
|
import appeng.core.AppEng;
|
||||||
|
@ -34,18 +41,28 @@ import appeng.me.GridAccessException;
|
||||||
import appeng.transformer.annotations.integration.Interface;
|
import appeng.transformer.annotations.integration.Interface;
|
||||||
import appeng.transformer.annotations.integration.InterfaceList;
|
import appeng.transformer.annotations.integration.InterfaceList;
|
||||||
import appeng.util.Platform;
|
import appeng.util.Platform;
|
||||||
import cofh.api.energy.IEnergyHandler;
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
|
||||||
|
|
||||||
@InterfaceList(value = { @Interface(iface = "cofh.api.energy.IEnergyHandler", iname = "RF") })
|
|
||||||
public class PartP2PRFPower extends PartP2PTunnel<PartP2PRFPower> implements cofh.api.energy.IEnergyHandler
|
@InterfaceList( value = { @Interface( iface = "cofh.api.energy.IEnergyReceiver", iname = "RF" ) } )
|
||||||
|
public class PartP2PRFPower extends PartP2PTunnel<PartP2PRFPower> implements IEnergyReceiver
|
||||||
{
|
{
|
||||||
|
private static final ThreadLocal<Stack<PartP2PRFPower>> THREAD_STACK = new ThreadLocal<Stack<PartP2PRFPower>>();
|
||||||
|
/**
|
||||||
|
* Default element based on the null element pattern
|
||||||
|
*/
|
||||||
|
private static final IEnergyReceiver NULL_HANDLER = new NullRFHandler();
|
||||||
|
private boolean cachedTarget = false;
|
||||||
|
private IEnergyReceiver outputTarget;
|
||||||
|
|
||||||
private static final IEnergyHandler myNullHandler = new NullRFHandler();
|
public PartP2PRFPower( ItemStack is )
|
||||||
|
{
|
||||||
|
super( is );
|
||||||
|
|
||||||
boolean cachedTarget = false;
|
if ( !AppEng.instance.isIntegrationEnabled( IntegrationType.RF ) )
|
||||||
IEnergyHandler outputTarget;
|
{
|
||||||
|
throw new RuntimeException( "RF Not installed!" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TunnelType getTunnelType()
|
public TunnelType getTunnelType()
|
||||||
|
@ -53,61 +70,38 @@ public class PartP2PRFPower extends PartP2PTunnel<PartP2PRFPower> implements cof
|
||||||
return TunnelType.RF_POWER;
|
return TunnelType.RF_POWER;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PartP2PRFPower(ItemStack is) {
|
|
||||||
super( is );
|
|
||||||
|
|
||||||
if ( !AppEng.instance.isIntegrationEnabled( IntegrationType.RF ) )
|
|
||||||
throw new RuntimeException( "RF Not installed!" );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNeighborChanged()
|
public void onTunnelNetworkChange()
|
||||||
{
|
{
|
||||||
super.onNeighborChanged();
|
this.getHost().notifyNeighbors();
|
||||||
cachedTarget = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly( Side.CLIENT )
|
||||||
public IIcon getTypeTexture()
|
public IIcon getTypeTexture()
|
||||||
{
|
{
|
||||||
return Blocks.iron_block.getBlockTextureFromSide( 0 );
|
return Blocks.iron_block.getBlockTextureFromSide( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTunnelNetworkChange()
|
public void onNeighborChanged()
|
||||||
{
|
{
|
||||||
getHost().notifyNeighbors();
|
super.onNeighborChanged();
|
||||||
}
|
|
||||||
|
|
||||||
public float getPowerDrainPerTick()
|
this.cachedTarget = false;
|
||||||
{
|
|
||||||
return 0.5f;
|
|
||||||
}
|
|
||||||
|
|
||||||
static final ThreadLocal<Stack<PartP2PRFPower>> depth = new ThreadLocal<Stack<PartP2PRFPower>>();
|
|
||||||
|
|
||||||
private Stack<PartP2PRFPower> getDepth()
|
|
||||||
{
|
|
||||||
Stack<PartP2PRFPower> s = depth.get();
|
|
||||||
|
|
||||||
if ( s == null )
|
|
||||||
depth.set( s = new Stack<PartP2PRFPower>() );
|
|
||||||
|
|
||||||
return s;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate)
|
public int receiveEnergy( ForgeDirection from, int maxReceive, boolean simulate )
|
||||||
{
|
{
|
||||||
if ( output )
|
if ( this.output )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if ( isActive() )
|
if ( this.isActive() )
|
||||||
{
|
{
|
||||||
Stack<PartP2PRFPower> stack = getDepth();
|
Stack<PartP2PRFPower> stack = this.getDepth();
|
||||||
|
|
||||||
for (PartP2PRFPower t : stack)
|
for ( PartP2PRFPower t : stack )
|
||||||
if ( t == this )
|
if ( t == this )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -117,7 +111,7 @@ public class PartP2PRFPower extends PartP2PTunnel<PartP2PRFPower> implements cof
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
for (PartP2PRFPower t : getOutputs())
|
for ( PartP2PRFPower t : this.getOutputs() )
|
||||||
{
|
{
|
||||||
if ( Platform.getRandomInt() % 2 > 0 )
|
if ( Platform.getRandomInt() % 2 > 0 )
|
||||||
{
|
{
|
||||||
|
@ -132,7 +126,7 @@ public class PartP2PRFPower extends PartP2PTunnel<PartP2PRFPower> implements cof
|
||||||
|
|
||||||
if ( maxReceive > 0 )
|
if ( maxReceive > 0 )
|
||||||
{
|
{
|
||||||
for (PartP2PRFPower t : getOutputs())
|
for ( PartP2PRFPower t : this.getOutputs() )
|
||||||
{
|
{
|
||||||
int receiver = t.getOutput().receiveEnergy( t.side.getOpposite(), maxReceive, simulate );
|
int receiver = t.getOutput().receiveEnergy( t.side.getOpposite(), maxReceive, simulate );
|
||||||
maxReceive -= receiver;
|
maxReceive -= receiver;
|
||||||
|
@ -143,9 +137,9 @@ public class PartP2PRFPower extends PartP2PTunnel<PartP2PRFPower> implements cof
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QueueTunnelDrain( PowerUnits.RF, total );
|
this.QueueTunnelDrain( PowerUnits.RF, total );
|
||||||
}
|
}
|
||||||
catch (GridAccessException ignored)
|
catch ( GridAccessException ignored )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,23 +152,47 @@ public class PartP2PRFPower extends PartP2PTunnel<PartP2PRFPower> implements cof
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private Stack<PartP2PRFPower> getDepth()
|
||||||
public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate)
|
|
||||||
{
|
{
|
||||||
return 0;
|
Stack<PartP2PRFPower> s = THREAD_STACK.get();
|
||||||
|
|
||||||
|
if ( s == null )
|
||||||
|
THREAD_STACK.set( s = new Stack<PartP2PRFPower>() );
|
||||||
|
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
private IEnergyReceiver getOutput()
|
||||||
|
{
|
||||||
|
if ( this.output )
|
||||||
|
{
|
||||||
|
if ( !this.cachedTarget )
|
||||||
|
{
|
||||||
|
TileEntity self = this.getTile();
|
||||||
|
TileEntity te = self.getWorldObj().getTileEntity( self.xCoord + this.side.offsetX, self.yCoord + this.side.offsetY, self.zCoord + this.side.offsetZ );
|
||||||
|
this.outputTarget = te instanceof IEnergyReceiver ? ( IEnergyReceiver ) te : null;
|
||||||
|
this.cachedTarget = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( this.outputTarget == null || !this.outputTarget.canConnectEnergy( this.side.getOpposite() ) )
|
||||||
|
return NULL_HANDLER;
|
||||||
|
|
||||||
|
return this.outputTarget;
|
||||||
|
}
|
||||||
|
return NULL_HANDLER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getEnergyStored(ForgeDirection from)
|
public int getEnergyStored( ForgeDirection from )
|
||||||
{
|
{
|
||||||
if ( output || !isActive() )
|
if ( this.output || !this.isActive() )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
int total = 0;
|
int total = 0;
|
||||||
|
|
||||||
Stack<PartP2PRFPower> stack = getDepth();
|
Stack<PartP2PRFPower> stack = this.getDepth();
|
||||||
|
|
||||||
for (PartP2PRFPower t : stack)
|
for ( PartP2PRFPower t : stack )
|
||||||
if ( t == this )
|
if ( t == this )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -182,12 +200,12 @@ public class PartP2PRFPower extends PartP2PTunnel<PartP2PRFPower> implements cof
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
for (PartP2PRFPower t : getOutputs())
|
for ( PartP2PRFPower t : this.getOutputs() )
|
||||||
{
|
{
|
||||||
total += t.getOutput().getEnergyStored( t.side.getOpposite() );
|
total += t.getOutput().getEnergyStored( t.side.getOpposite() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (GridAccessException e)
|
catch ( GridAccessException e )
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -199,16 +217,16 @@ public class PartP2PRFPower extends PartP2PTunnel<PartP2PRFPower> implements cof
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMaxEnergyStored(ForgeDirection from)
|
public int getMaxEnergyStored( ForgeDirection from )
|
||||||
{
|
{
|
||||||
if ( output || !isActive() )
|
if ( this.output || !this.isActive() )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
int total = 0;
|
int total = 0;
|
||||||
|
|
||||||
Stack<PartP2PRFPower> stack = getDepth();
|
Stack<PartP2PRFPower> stack = this.getDepth();
|
||||||
|
|
||||||
for (PartP2PRFPower t : stack)
|
for ( PartP2PRFPower t : stack )
|
||||||
if ( t == this )
|
if ( t == this )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -216,12 +234,12 @@ public class PartP2PRFPower extends PartP2PTunnel<PartP2PRFPower> implements cof
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
for (PartP2PRFPower t : getOutputs())
|
for ( PartP2PRFPower t : this.getOutputs() )
|
||||||
{
|
{
|
||||||
total += t.getOutput().getMaxEnergyStored( t.side.getOpposite() );
|
total += t.getOutput().getMaxEnergyStored( t.side.getOpposite() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (GridAccessException e)
|
catch ( GridAccessException e )
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -232,28 +250,8 @@ public class PartP2PRFPower extends PartP2PTunnel<PartP2PRFPower> implements cof
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnergyHandler getOutput()
|
|
||||||
{
|
|
||||||
if ( output )
|
|
||||||
{
|
|
||||||
if ( !cachedTarget )
|
|
||||||
{
|
|
||||||
TileEntity self = getTile();
|
|
||||||
TileEntity te = self.getWorldObj().getTileEntity( self.xCoord + side.offsetX, self.yCoord + side.offsetY, self.zCoord + side.offsetZ );
|
|
||||||
outputTarget = te instanceof IEnergyHandler ? (IEnergyHandler) te : null;
|
|
||||||
cachedTarget = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( outputTarget == null || !outputTarget.canConnectEnergy( side.getOpposite() ) )
|
|
||||||
return myNullHandler;
|
|
||||||
|
|
||||||
return outputTarget;
|
|
||||||
}
|
|
||||||
return myNullHandler;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canConnectEnergy(ForgeDirection from)
|
public boolean canConnectEnergy( ForgeDirection from )
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,49 +18,47 @@
|
||||||
|
|
||||||
package appeng.tile.powersink;
|
package appeng.tile.powersink;
|
||||||
|
|
||||||
|
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
|
import cofh.api.energy.IEnergyReceiver;
|
||||||
|
|
||||||
import appeng.api.config.PowerUnits;
|
import appeng.api.config.PowerUnits;
|
||||||
import appeng.transformer.annotations.integration.Interface;
|
import appeng.transformer.annotations.integration.Interface;
|
||||||
import cofh.api.energy.IEnergyHandler;
|
|
||||||
|
|
||||||
@Interface(iname = "RF", iface = "cofh.api.energy.IEnergyHandler")
|
|
||||||
public abstract class RedstoneFlux extends RotaryCraft implements IEnergyHandler
|
@Interface( iname = "RF", iface = "cofh.api.energy.IEnergyReceiver" )
|
||||||
|
public abstract class RedstoneFlux extends RotaryCraft implements IEnergyReceiver
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
final public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate)
|
final public int receiveEnergy( ForgeDirection from, int maxReceive, boolean simulate )
|
||||||
{
|
{
|
||||||
final int networkRFDemand = (int) Math.floor( this.getExternalPowerDemand( PowerUnits.RF, maxReceive ) );
|
final int networkRFDemand = ( int ) Math.floor( this.getExternalPowerDemand( PowerUnits.RF, maxReceive ) );
|
||||||
final int usedRF = Math.min( maxReceive, networkRFDemand );
|
final int usedRF = Math.min( maxReceive, networkRFDemand );
|
||||||
|
|
||||||
if ( !simulate )
|
if ( !simulate )
|
||||||
{
|
{
|
||||||
this.injectExternalPower( PowerUnits.RF, usedRF );
|
this.injectExternalPower( PowerUnits.RF, usedRF );
|
||||||
}
|
}
|
||||||
|
|
||||||
return usedRF;
|
return usedRF;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
final public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate)
|
final public int getEnergyStored( ForgeDirection from )
|
||||||
{
|
{
|
||||||
return 0;
|
return ( int ) Math.floor( PowerUnits.AE.convertTo( PowerUnits.RF, this.getAECurrentPower() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
final public boolean canConnectEnergy(ForgeDirection from)
|
final public int getMaxEnergyStored( ForgeDirection from )
|
||||||
|
{
|
||||||
|
return ( int ) Math.floor( PowerUnits.AE.convertTo( PowerUnits.RF, this.getAEMaxPower() ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
final public boolean canConnectEnergy( ForgeDirection from )
|
||||||
{
|
{
|
||||||
return this.getPowerSides().contains( from );
|
return this.getPowerSides().contains( from );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
final public int getEnergyStored(ForgeDirection from)
|
|
||||||
{
|
|
||||||
return (int) Math.floor( PowerUnits.AE.convertTo( PowerUnits.RF, this.getAECurrentPower() ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
final public int getMaxEnergyStored(ForgeDirection from)
|
|
||||||
{
|
|
||||||
return (int) Math.floor( PowerUnits.AE.convertTo( PowerUnits.RF, this.getAEMaxPower() ) );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue