Updated caps to be manually disabled via config
Moved the cap injection to a method, allows them to be configurable. This is not possible for Forge Energy as it is injected before even the configuration are lodaed, thus violating their own capability contract to use the method injection to explicitly make it configurable. Updated the ratio key for forge energy to "ForgeEnergy" without a space
This commit is contained in:
@@ -26,8 +26,11 @@ import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.CapabilityInject;
|
||||
import net.minecraftforge.common.capabilities.CapabilityManager;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
|
||||
import appeng.api.storage.IStorageMonitorableAccessor;
|
||||
import appeng.integration.IntegrationRegistry;
|
||||
import appeng.integration.IntegrationType;
|
||||
|
||||
|
||||
/**
|
||||
@@ -40,15 +43,14 @@ public final class Capabilities
|
||||
{
|
||||
}
|
||||
|
||||
@CapabilityInject( IStorageMonitorableAccessor.class )
|
||||
public static Capability<IStorageMonitorableAccessor> STORAGE_MONITORABLE_ACCESSOR;
|
||||
|
||||
@CapabilityInject( ITeslaConsumer.class )
|
||||
public static Capability<ITeslaConsumer> TESLA_CONSUMER;
|
||||
|
||||
@CapabilityInject( ITeslaHolder.class )
|
||||
public static Capability<ITeslaHolder> TESLA_HOLDER;
|
||||
|
||||
public static Capability<IEnergyStorage> FORGE_ENERGY;
|
||||
|
||||
/**
|
||||
* Register AE2 provided capabilities.
|
||||
*/
|
||||
@@ -57,6 +59,36 @@ public final class Capabilities
|
||||
CapabilityManager.INSTANCE.register( IStorageMonitorableAccessor.class, createNullStorage(), NullMENetworkAccessor::new );
|
||||
}
|
||||
|
||||
@CapabilityInject( IStorageMonitorableAccessor.class )
|
||||
private static void capIStorageMonitorableAccessorRegistered( Capability<IStorageMonitorableAccessor> cap )
|
||||
{
|
||||
STORAGE_MONITORABLE_ACCESSOR = cap;
|
||||
}
|
||||
|
||||
@CapabilityInject( ITeslaConsumer.class )
|
||||
private static void capITeslaConsumerRegistered( Capability<ITeslaConsumer> cap )
|
||||
{
|
||||
if( IntegrationRegistry.INSTANCE.isEnabled( IntegrationType.TESLA ) )
|
||||
{
|
||||
TESLA_CONSUMER = cap;
|
||||
}
|
||||
}
|
||||
|
||||
@CapabilityInject( ITeslaHolder.class )
|
||||
private static void capITeslaHolderRegistered( Capability<ITeslaHolder> cap )
|
||||
{
|
||||
if( IntegrationRegistry.INSTANCE.isEnabled( IntegrationType.TESLA ) )
|
||||
{
|
||||
TESLA_HOLDER = cap;
|
||||
}
|
||||
}
|
||||
|
||||
@CapabilityInject( IEnergyStorage.class )
|
||||
private static void capIEnergyStorageRegistered( Capability<IEnergyStorage> cap )
|
||||
{
|
||||
FORGE_ENERGY = cap;
|
||||
}
|
||||
|
||||
// Create a storage implementation that does not do anything
|
||||
private static <T> Capability.IStorage<T> createNullStorage()
|
||||
{
|
||||
|
||||
@@ -146,7 +146,7 @@ public final class AEConfig extends Configuration implements IConfigurableObject
|
||||
MinecraftForge.EVENT_BUS.register( this );
|
||||
|
||||
PowerUnits.EU.conversionRatio = this.get( "PowerRatios", "IC2", DEFAULT_IC2_EXCHANGE ).getDouble( DEFAULT_IC2_EXCHANGE );
|
||||
PowerUnits.RF.conversionRatio = this.get( "PowerRatios", "Forge Energy", DEFAULT_RF_EXCHANGE ).getDouble( DEFAULT_RF_EXCHANGE );
|
||||
PowerUnits.RF.conversionRatio = this.get( "PowerRatios", "ForgeEnergy", DEFAULT_RF_EXCHANGE ).getDouble( DEFAULT_RF_EXCHANGE );
|
||||
|
||||
final double usageEffective = this.get( "PowerRatios", "UsageMultiplier", 1.0 ).getDouble( 1.0 );
|
||||
PowerMultiplier.CONFIG.multiplier = Math.max( 0.01, usageEffective );
|
||||
|
||||
@@ -41,6 +41,7 @@ import appeng.api.definitions.IItemDefinition;
|
||||
import appeng.api.definitions.IParts;
|
||||
import appeng.api.features.IP2PTunnelRegistry;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.capabilities.Capabilities;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
@@ -244,7 +245,7 @@ public final class P2PTunnelRegistry implements IP2PTunnelRegistry
|
||||
// Next, check if the Item you're holding supports Forge Energy
|
||||
for( EnumFacing face : EnumFacing.VALUES )
|
||||
{
|
||||
if( trigger.hasCapability( CapabilityEnergy.ENERGY, face ) )
|
||||
if( trigger.hasCapability( Capabilities.FORGE_ENERGY, face ) )
|
||||
{
|
||||
return TunnelType.FE_POWER;
|
||||
}
|
||||
|
||||
@@ -90,7 +90,9 @@ public enum IntegrationType
|
||||
{
|
||||
return new TheOneProbeModule();
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
TESLA( IntegrationSide.BOTH, "Tesla", "tesla" );
|
||||
|
||||
public final IntegrationSide side;
|
||||
public final String dspName;
|
||||
|
||||
@@ -64,14 +64,14 @@ class PoweredItemCapabilities implements ICapabilityProvider, IEnergyStorage
|
||||
@Override
|
||||
public boolean hasCapability( Capability<?> capability, @Nullable EnumFacing facing )
|
||||
{
|
||||
return capability == CapabilityEnergy.ENERGY || capability == Capabilities.TESLA_CONSUMER || capability == Capabilities.TESLA_HOLDER;
|
||||
return capability == Capabilities.FORGE_ENERGY || capability == Capabilities.TESLA_CONSUMER || capability == Capabilities.TESLA_HOLDER;
|
||||
}
|
||||
|
||||
@SuppressWarnings( "unchecked" )
|
||||
@Override
|
||||
public <T> T getCapability( Capability<T> capability, @Nullable EnumFacing facing )
|
||||
{
|
||||
if( capability == CapabilityEnergy.ENERGY )
|
||||
if( capability == Capabilities.FORGE_ENERGY )
|
||||
{
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ import net.minecraftforge.energy.IEnergyStorage;
|
||||
|
||||
import appeng.api.config.PowerUnits;
|
||||
import appeng.api.parts.IPartModel;
|
||||
import appeng.capabilities.Capabilities;
|
||||
import appeng.items.parts.PartModels;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.util.Platform;
|
||||
@@ -153,8 +154,8 @@ public class PartP2PFEPower extends PartP2PTunnel<PartP2PFEPower> implements IEn
|
||||
TileEntity self = this.getTile();
|
||||
TileEntity te = self.getWorld().getTileEntity( new BlockPos( self.getPos().getX() + this.getSide().xOffset, self.getPos()
|
||||
.getY() + this.getSide().yOffset, self.getPos().getZ() + this.getSide().zOffset ) );
|
||||
this.outputTarget = te.hasCapability( CapabilityEnergy.ENERGY, this.getSide().getOpposite().getFacing() ) ? te
|
||||
.getCapability( CapabilityEnergy.ENERGY, this.getSide().getOpposite().getFacing() ) : null;
|
||||
this.outputTarget = te.hasCapability( Capabilities.FORGE_ENERGY, this.getSide().getOpposite().getFacing() ) ? te
|
||||
.getCapability( Capabilities.FORGE_ENERGY, this.getSide().getOpposite().getFacing() ) : null;
|
||||
this.cachedTarget = true;
|
||||
}
|
||||
|
||||
@@ -233,7 +234,7 @@ public class PartP2PFEPower extends PartP2PTunnel<PartP2PFEPower> implements IEn
|
||||
@Override
|
||||
public boolean hasCapability( @Nonnull Capability<?> capability )
|
||||
{
|
||||
if( capability == CapabilityEnergy.ENERGY )
|
||||
if( capability == Capabilities.FORGE_ENERGY )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -245,7 +246,7 @@ public class PartP2PFEPower extends PartP2PTunnel<PartP2PFEPower> implements IEn
|
||||
@Override
|
||||
public <T> T getCapability( @Nonnull Capability<T> capability )
|
||||
{
|
||||
if( capability == CapabilityEnergy.ENERGY )
|
||||
if( capability == Capabilities.FORGE_ENERGY )
|
||||
{
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
@@ -284,7 +284,7 @@ public abstract class AERootPoweredTile extends AEBaseInvTile implements IAEPowe
|
||||
@Override
|
||||
public boolean hasCapability( Capability<?> capability, EnumFacing facing )
|
||||
{
|
||||
if( capability == CapabilityEnergy.ENERGY )
|
||||
if( capability == Capabilities.FORGE_ENERGY )
|
||||
{
|
||||
if( this.getPowerSides().contains( facing ) )
|
||||
{
|
||||
@@ -306,7 +306,7 @@ public abstract class AERootPoweredTile extends AEBaseInvTile implements IAEPowe
|
||||
@Override
|
||||
public <T> T getCapability( Capability<T> capability, @Nullable EnumFacing facing )
|
||||
{
|
||||
if( capability == CapabilityEnergy.ENERGY )
|
||||
if( capability == Capabilities.FORGE_ENERGY )
|
||||
{
|
||||
if( this.getPowerSides().contains( facing ) )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user