fix mod name
implement GTCEU Energy adapter
This commit is contained in:
+1
-1
@@ -57,7 +57,7 @@ tasks.withType(JavaCompile) {
|
|||||||
options.encoding = 'UTF-8'
|
options.encoding = 'UTF-8'
|
||||||
}
|
}
|
||||||
|
|
||||||
version = extended + "-" + aeversion + "-" + aechannel + "-" + aebuild + "-" + extendedversion
|
version = aeversion + "-" + aechannel + "-" + aebuild + "-" + extended + "-" + extendedversion
|
||||||
group = aegroup
|
group = aegroup
|
||||||
archivesBaseName = aebasename
|
archivesBaseName = aebasename
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ package appeng.capabilities;
|
|||||||
|
|
||||||
|
|
||||||
import com.jaquadro.minecraft.storagedrawers.api.capabilities.IItemRepository;
|
import com.jaquadro.minecraft.storagedrawers.api.capabilities.IItemRepository;
|
||||||
|
import gregtech.api.capability.IEnergyContainer;
|
||||||
import net.darkhax.tesla.api.ITeslaConsumer;
|
import net.darkhax.tesla.api.ITeslaConsumer;
|
||||||
import net.darkhax.tesla.api.ITeslaHolder;
|
import net.darkhax.tesla.api.ITeslaHolder;
|
||||||
import net.minecraft.nbt.NBTBase;
|
import net.minecraft.nbt.NBTBase;
|
||||||
@@ -57,6 +58,8 @@ public final class Capabilities
|
|||||||
|
|
||||||
public static Capability<IItemRepository> ITEM_REPOSITORY_CAPABILITY;
|
public static Capability<IItemRepository> ITEM_REPOSITORY_CAPABILITY;
|
||||||
|
|
||||||
|
public static Capability<IEnergyContainer> GTCE_ENERGY;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register AE2 provided capabilities.
|
* Register AE2 provided capabilities.
|
||||||
*/
|
*/
|
||||||
@@ -103,7 +106,19 @@ public final class Capabilities
|
|||||||
}
|
}
|
||||||
|
|
||||||
@CapabilityInject( IItemRepository.class )
|
@CapabilityInject( IItemRepository.class )
|
||||||
private static void capIItemRepositoryRegistered( Capability<IItemRepository> cap ) { ITEM_REPOSITORY_CAPABILITY = cap; }
|
private static void capIItemRepositoryRegistered( Capability<IItemRepository> cap )
|
||||||
|
{
|
||||||
|
ITEM_REPOSITORY_CAPABILITY = cap;
|
||||||
|
}
|
||||||
|
|
||||||
|
@CapabilityInject( IEnergyContainer.class )
|
||||||
|
private static void capIEnergyContainerRegistered( Capability<IEnergyContainer> cap )
|
||||||
|
{
|
||||||
|
if( IntegrationRegistry.INSTANCE.isEnabled( IntegrationType.GTCE ) )
|
||||||
|
{
|
||||||
|
GTCE_ENERGY = cap;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Create a storage implementation that does not do anything
|
// Create a storage implementation that does not do anything
|
||||||
private static <T> Capability.IStorage<T> createNullStorage()
|
private static <T> Capability.IStorage<T> createNullStorage()
|
||||||
|
|||||||
@@ -57,10 +57,16 @@ public class TileEnergyAcceptor extends AENetworkPowerTile
|
|||||||
}
|
}
|
||||||
catch( final GridAccessException e )
|
catch( final GridAccessException e )
|
||||||
{
|
{
|
||||||
return this.getInternalMaxPower();
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getInternalMaxPower()
|
||||||
|
{
|
||||||
|
return getFunnelPowerDemand( Long.MAX_VALUE );
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected double funnelPowerIntoStorage( final double power, final Actionable mode )
|
protected double funnelPowerIntoStorage( final double power, final Actionable mode )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ public abstract class AEBasePoweredTile extends AEBaseInvTile implements IAEPowe
|
|||||||
private EnumSet<EnumFacing> internalPowerSides = EnumSet.allOf( EnumFacing.class );
|
private EnumSet<EnumFacing> internalPowerSides = EnumSet.allOf( EnumFacing.class );
|
||||||
private final IEnergyStorage forgeEnergyAdapter;
|
private final IEnergyStorage forgeEnergyAdapter;
|
||||||
private Object teslaEnergyAdapter;
|
private Object teslaEnergyAdapter;
|
||||||
|
private GTCEEnergyAdapter gtceEnergyAdapter = null;
|
||||||
private IC2PowerSink ic2Sink;
|
private IC2PowerSink ic2Sink;
|
||||||
|
|
||||||
public AEBasePoweredTile()
|
public AEBasePoweredTile()
|
||||||
@@ -63,6 +63,11 @@ public abstract class AEBasePoweredTile extends AEBaseInvTile implements IAEPowe
|
|||||||
{
|
{
|
||||||
this.teslaEnergyAdapter = new TeslaEnergyAdapter( this );
|
this.teslaEnergyAdapter = new TeslaEnergyAdapter( this );
|
||||||
}
|
}
|
||||||
|
if( Capabilities.GTCE_ENERGY != null )
|
||||||
|
{
|
||||||
|
this.gtceEnergyAdapter = new GTCEEnergyAdapter( this );
|
||||||
|
}
|
||||||
|
|
||||||
this.ic2Sink = Integrations.ic2().createPowerSink( this, this );
|
this.ic2Sink = Integrations.ic2().createPowerSink( this, this );
|
||||||
this.ic2Sink.setValidFaces( this.internalPowerSides );
|
this.ic2Sink.setValidFaces( this.internalPowerSides );
|
||||||
}
|
}
|
||||||
@@ -284,6 +289,13 @@ public abstract class AEBasePoweredTile extends AEBaseInvTile implements IAEPowe
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if( capability == Capabilities.GTCE_ENERGY )
|
||||||
|
{
|
||||||
|
if( this.getPowerSides().contains( facing ) )
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return super.hasCapability( capability, facing );
|
return super.hasCapability( capability, facing );
|
||||||
}
|
}
|
||||||
@@ -306,7 +318,14 @@ public abstract class AEBasePoweredTile extends AEBaseInvTile implements IAEPowe
|
|||||||
return (T) this.teslaEnergyAdapter;
|
return (T) this.teslaEnergyAdapter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if( capability == Capabilities.GTCE_ENERGY )
|
||||||
|
{
|
||||||
|
if( this.getPowerSides().contains( facing ) )
|
||||||
|
{
|
||||||
|
return (T) this.gtceEnergyAdapter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return super.getCapability( capability, facing );
|
return super.getCapability( capability, facing );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,67 @@
|
|||||||
|
package appeng.tile.powersink;
|
||||||
|
|
||||||
|
import appeng.api.config.Actionable;
|
||||||
|
import appeng.api.config.PowerUnits;
|
||||||
|
import gregtech.api.capability.IEnergyContainer;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
|
||||||
|
|
||||||
|
public class GTCEEnergyAdapter implements IEnergyContainer
|
||||||
|
{
|
||||||
|
private final IExternalPowerSink sink;
|
||||||
|
|
||||||
|
GTCEEnergyAdapter( IExternalPowerSink sink )
|
||||||
|
{
|
||||||
|
this.sink = sink;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long acceptEnergyFromNetwork( EnumFacing enumFacing, long voltage, long amperage )
|
||||||
|
{
|
||||||
|
final double overflow = this.sink.injectExternalPower( PowerUnits.GTCEU, (double) voltage, Actionable.MODULATE );
|
||||||
|
|
||||||
|
return (long) ( voltage - overflow );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean inputsEnergy( EnumFacing enumFacing )
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long changeEnergy( long l )
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getEnergyStored()
|
||||||
|
{
|
||||||
|
return (long) Math.floor( PowerUnits.AE.convertTo( PowerUnits.GTCEU, this.sink.getAECurrentPower() ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getEnergyCapacity()
|
||||||
|
{
|
||||||
|
return (long) Math.floor( PowerUnits.AE.convertTo( PowerUnits.GTCEU, this.sink.getAEMaxPower() ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getInputAmperage()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getInputVoltage()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getEnergyCanBeInserted()
|
||||||
|
{
|
||||||
|
return this.getEnergyCapacity() - this.getEnergyStored();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user