Permalink
Browse files

#2438: Added Tesla support with same conversion ratio as RF.

  • Loading branch information...
shartte committed Oct 19, 2016
1 parent 5578aba commit ec4bc8626668bd65f5f4a1b8b69d2ce53edd388e
View
@@ -20,3 +20,4 @@ waila_version=1.7.0-B3_1.9.4
# Provided APIs #
#########################################################
jei_version=3.12.7.312
tesla_version=1.10.2-1.2.1.49
@@ -28,6 +28,11 @@ repositories {
name = "JEI repo"
url "http://dvs1.progwml6.com/files/maven"
}
maven {
name = "Tesla repo"
url "http://maven.epoxide.xyz"
}
}
configurations {
@@ -41,6 +46,7 @@ dependencies {
// compile against provided APIs
compileOnly "mezz.jei:jei_${minecraft_version}:${jei_version}:api"
compileOnly "mcp.mobius.waila:Waila:${waila_version}"
compileOnly "net.darkhax.tesla:Tesla:${tesla_version}"
// at runtime, use the full JEI jar
runtime "mezz.jei:jei_${minecraft_version}:${jei_version}"
@@ -22,9 +22,11 @@
import java.util.EnumSet;
import javax.annotation.Nullable;
import net.darkhax.tesla.api.ITeslaConsumer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.CapabilityInject;
import net.minecraftforge.energy.CapabilityEnergy;
import net.minecraftforge.energy.IEnergyStorage;
@@ -41,6 +43,9 @@
public abstract class AERootPoweredTile extends AEBaseInvTile implements IAEPowerStorage, IExternalPowerSink
{
@CapabilityInject(ITeslaConsumer.class)
private static Capability<ITeslaConsumer> teslaConsumerCapability;
// values that determine general function, are set by inheriting classes if
// needed. These should generally remain static.
private double internalMaxPower = 10000;
@@ -50,10 +55,14 @@
private double internalCurrentPower = 0;
private EnumSet<EnumFacing> internalPowerSides = EnumSet.allOf( EnumFacing.class );
private final IEnergyStorage forgeEnergyAdapter;
private Object teslaEnergyAdapter;
public AERootPoweredTile()
{
forgeEnergyAdapter = new ForgeEnergyAdapter( this );
if ( teslaConsumerCapability != null ) {
teslaEnergyAdapter = new TeslaEnergyAdapter( this );
}
}
protected EnumSet<EnumFacing> getPowerSides()
@@ -252,6 +261,13 @@ public boolean hasCapability( Capability<?> capability, EnumFacing facing )
return true;
}
}
else if( capability == teslaConsumerCapability )
{
if( this.getPowerSides().contains( facing ) )
{
return true;
}
}
return super.hasCapability( capability, facing );
}
@@ -267,6 +283,13 @@ public boolean hasCapability( Capability<?> capability, EnumFacing facing )
return (T) forgeEnergyAdapter;
}
}
else if( capability == teslaConsumerCapability )
{
if( this.getPowerSides().contains( facing ) )
{
return (T) teslaEnergyAdapter;
}
}
return super.getCapability( capability, facing );
}
@@ -0,0 +1,39 @@
package appeng.tile.powersink;
import net.darkhax.tesla.api.ITeslaConsumer;
import appeng.api.config.PowerUnits;
/**
* Adapts an {@link IExternalPowerSink} to Forges {@link net.darkhax.tesla.api.ITeslaConsumer}.
*/
class TeslaEnergyAdapter implements ITeslaConsumer
{
private final IExternalPowerSink sink;
TeslaEnergyAdapter( IExternalPowerSink sink )
{
this.sink = sink;
}
@Override
public long givePower( long power, boolean simulated )
{
// Cut it down to what we can represent in a double
double powerDbl = (double) power;
double networkDemand = sink.getExternalPowerDemand( PowerUnits.RF, powerDbl );
long used = (long) Math.min( powerDbl, networkDemand );
if( !simulated )
{
sink.injectExternalPower( PowerUnits.RF, used );
}
return used;
}
}

5 comments on commit ec4bc86

@ozhound

This comment has been minimized.

Show comment
Hide comment
@ozhound

ozhound Oct 20, 2016

im a bit confused, this is in the master branch so is this for 1.10? also does the nightly build only run from the 1.10 branch. if these commits are in the master then does that mean that the nightly build will never update?

ozhound replied Oct 20, 2016

im a bit confused, this is in the master branch so is this for 1.10? also does the nightly build only run from the 1.10 branch. if these commits are in the master then does that mean that the nightly build will never update?

@shartte

This comment has been minimized.

Show comment
Hide comment
@shartte

shartte Oct 20, 2016

Contributor

@ozhound We've moved 1.10 to master. The nightlies should also be generated for the master branch by now. If they aren't, please let me know so I can take a look at it.

Contributor

shartte replied Oct 20, 2016

@ozhound We've moved 1.10 to master. The nightlies should also be generated for the master branch by now. If they aren't, please let me know so I can take a look at it.

@ozhound

This comment has been minimized.

Show comment
Hide comment
@ozhound

ozhound Oct 20, 2016

@shartte the current nightly build download contains the file "appliedenergistics2-rv4-nightly-41b875.jar" with a modification date of 17/10

ozhound replied Oct 20, 2016

@shartte the current nightly build download contains the file "appliedenergistics2-rv4-nightly-41b875.jar" with a modification date of 17/10

@Saereth

This comment has been minimized.

Show comment
Hide comment
@Saereth

Saereth replied Oct 20, 2016

@shartte

This comment has been minimized.

Show comment
Hide comment
@shartte

shartte Oct 20, 2016

Contributor

I updated the nightly build link to point to the master branch. This should now give the latest nightly. I'll talk to yueh about getting proper alpha builds up.

Contributor

shartte replied Oct 20, 2016

I updated the nightly build link to point to the master branch. This should now give the latest nightly. I'll talk to yueh about getting proper alpha builds up.

Please sign in to comment.