Separated TileEntity and External Power Sink arguments to IC2 to emphasize that they don't necessarily need to be the same, and that a tile entity is required for IC2.

This commit is contained in:
Sebastian Hartte 2016-10-28 20:16:39 +02:00 committed by shartte
parent 344958aefb
commit 6e6e51dc20
3 changed files with 11 additions and 8 deletions

View file

@ -19,7 +19,9 @@
package appeng.integration.modules; package appeng.integration.modules;
import java.util.function.Function; import java.util.function.BiFunction;
import net.minecraft.tileentity.TileEntity;
import appeng.helpers.Reflected; import appeng.helpers.Reflected;
import appeng.integration.IIntegrationModule; import appeng.integration.IIntegrationModule;
@ -35,7 +37,7 @@ public class IC2 implements IIntegrationModule
@Reflected @Reflected
public static IC2 instance; public static IC2 instance;
private Function<IExternalPowerSink, IC2PowerSink> powerSinkFactory = ( sink -> IC2PowerSinkStub.INSTANCE ); private BiFunction<TileEntity, IExternalPowerSink, IC2PowerSink> powerSinkFactory = ( ( te, sink ) -> IC2PowerSinkStub.INSTANCE );
@Override @Override
public void init() throws Throwable public void init() throws Throwable
@ -51,8 +53,8 @@ public class IC2 implements IIntegrationModule
/** /**
* Create an IC2 power sink for the given external sink. * Create an IC2 power sink for the given external sink.
*/ */
public static IC2PowerSink createPowerSink( IExternalPowerSink externalSink ) public static IC2PowerSink createPowerSink( TileEntity tileEntity, IExternalPowerSink externalSink )
{ {
return instance.powerSinkFactory.apply( externalSink ); return instance.powerSinkFactory.apply( tileEntity, externalSink );
} }
} }

View file

@ -42,9 +42,9 @@ public class IC2PowerSinkAdapter extends BasicSink implements IC2PowerSink
private final Set<EnumFacing> validFaces = EnumSet.allOf( EnumFacing.class ); private final Set<EnumFacing> validFaces = EnumSet.allOf( EnumFacing.class );
public IC2PowerSinkAdapter( IExternalPowerSink powerSink ) public IC2PowerSinkAdapter( TileEntity tileEntity, IExternalPowerSink powerSink )
{ {
super( (TileEntity) powerSink, 0, Integer.MAX_VALUE ); super( tileEntity, 0, Integer.MAX_VALUE );
this.powerSink = powerSink; this.powerSink = powerSink;
} }

View file

@ -64,10 +64,11 @@ public abstract class AERootPoweredTile extends AEBaseInvTile implements IAEPowe
public AERootPoweredTile() public AERootPoweredTile()
{ {
forgeEnergyAdapter = new ForgeEnergyAdapter( this ); forgeEnergyAdapter = new ForgeEnergyAdapter( this );
if ( teslaConsumerCapability != null ) { if( teslaConsumerCapability != null )
{
teslaEnergyAdapter = new TeslaEnergyAdapter( this ); teslaEnergyAdapter = new TeslaEnergyAdapter( this );
} }
ic2Sink = IC2.createPowerSink(this); ic2Sink = IC2.createPowerSink( this, this );
ic2Sink.setValidFaces( internalPowerSides ); ic2Sink.setValidFaces( internalPowerSides );
} }