mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-25 14:24:35 +00:00
Forge Energy support, added full functionality for Tesla
This commit is contained in:
1 parent
5cea9502cb
commit
0e9f380bd7
27 files changed
+628
-133
No files matched your search
@@ -0,0 +1,39 @@
|
||||
package mekanism.common.integration.tesla;
|
||||
|
||||
import mekanism.api.MekanismConfig.general;
|
||||
import mekanism.common.tile.transmitter.TileEntityUniversalCable;
|
||||
import net.darkhax.tesla.api.ITeslaConsumer;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.fml.common.Optional.Interface;
|
||||
import net.minecraftforge.fml.common.Optional.Method;
|
||||
|
||||
@Interface(iface = "net.darkhax.tesla.api.ITeslaConsumer", modid = "tesla")
|
||||
public class TeslaCableIntegration implements ITeslaConsumer
|
||||
{
|
||||
public TileEntityUniversalCable tileEntity;
|
||||
|
||||
public EnumFacing side;
|
||||
|
||||
public TeslaCableIntegration(TileEntityUniversalCable tile, EnumFacing facing)
|
||||
{
|
||||
tileEntity = tile;
|
||||
side = facing;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "tesla")
|
||||
public long givePower(long power, boolean simulated)
|
||||
{
|
||||
return rfToTesla(tileEntity.receiveEnergy(side, teslaToRF(power), simulated));
|
||||
}
|
||||
|
||||
public long rfToTesla(int rf)
|
||||
{
|
||||
return (long)Math.round(rf*general.FROM_RF*general.TO_TESLA);
|
||||
}
|
||||
|
||||
public int teslaToRF(long tesla)
|
||||
{
|
||||
return (int)Math.round(Math.min(Integer.MAX_VALUE, tesla*general.FROM_TESLA*general.TO_RF));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user