make it runnable

This commit is contained in:
thatsIch
2015-06-17 19:39:18 +02:00
parent 38afde724b
commit a95b9962b9
17 changed files with 1422 additions and 1583 deletions
+89 -102
View File
@@ -19,105 +19,92 @@
package appeng.tile.powersink;
import java.util.EnumSet;
import net.minecraft.tileentity.TileEntity;
import ic2.api.energy.tile.IEnergySink;
import appeng.api.config.PowerUnits;
import appeng.api.util.ForgeDirection;
import appeng.integration.IntegrationRegistry;
import appeng.integration.IntegrationType;
import appeng.integration.abstraction.IIC2;
import appeng.transformer.annotations.Integration.Interface;
import appeng.util.Platform;
@Interface( iname = "IC2", iface = "ic2.api.energy.tile.IEnergySink" )
public abstract class IC2 extends AERootPoweredTile implements IEnergySink
{
boolean isInIC2 = false;
@Override
public final boolean acceptsEnergyFrom( TileEntity emitter, ForgeDirection direction )
{
return this.getPowerSides().contains( direction );
}
@Override
public final double getDemandedEnergy()
{
return this.getExternalPowerDemand( PowerUnits.EU, Double.MAX_VALUE );
}
@Override
public final int getSinkTier()
{
return Integer.MAX_VALUE;
}
@Override
public final double injectEnergy( ForgeDirection directionFrom, double amount, double voltage )
{
// just store the excess in the current block, if I return the waste,
// IC2 will just disintegrate it - Oct 20th 2013
double overflow = PowerUnits.EU.convertTo( PowerUnits.AE, this.injectExternalPower( PowerUnits.EU, amount ) );
this.internalCurrentPower += overflow;
return 0; // see above comment.
}
@Override
public void invalidate()
{
super.invalidate();
this.removeFromENet();
}
private void removeFromENet()
{
if( IntegrationRegistry.INSTANCE.isEnabled( IntegrationType.IC2 ) )
{
IIC2 ic2Integration = (IIC2) IntegrationRegistry.INSTANCE.getInstance( IntegrationType.IC2 );
if( this.isInIC2 && Platform.isServer() && ic2Integration != null )
{
ic2Integration.removeFromEnergyNet( this );
this.isInIC2 = false;
}
}
}
@Override
public void onChunkUnload()
{
super.onChunkUnload();
this.removeFromENet();
}
@Override
public void onReady()
{
super.onReady();
this.addToENet();
}
private void addToENet()
{
if( IntegrationRegistry.INSTANCE.isEnabled( IntegrationType.IC2 ) )
{
IIC2 ic2Integration = (IIC2) IntegrationRegistry.INSTANCE.getInstance( IntegrationType.IC2 );
if( !this.isInIC2 && Platform.isServer() && ic2Integration != null )
{
ic2Integration.addToEnergyNet( this );
this.isInIC2 = true;
}
}
}
@Override
protected void setPowerSides( EnumSet<ForgeDirection> sides )
{
super.setPowerSides( sides );
this.removeFromENet();
this.addToENet();
}
}
//@Interface( iname = "IC2", iface = "ic2.api.energy.tile.IEnergySink" )
//public abstract class IC2 extends AERootPoweredTile implements IEnergySink
//{
//
// boolean isInIC2 = false;
//
// @Override
// public final boolean acceptsEnergyFrom( TileEntity emitter, ForgeDirection direction )
// {
// return this.getPowerSides().contains( direction );
// }
//
// @Override
// public final double getDemandedEnergy()
// {
// return this.getExternalPowerDemand( PowerUnits.EU, Double.MAX_VALUE );
// }
//
// @Override
// public final int getSinkTier()
// {
// return Integer.MAX_VALUE;
// }
//
// @Override
// public final double injectEnergy( ForgeDirection directionFrom, double amount, double voltage )
// {
// // just store the excess in the current block, if I return the waste,
// // IC2 will just disintegrate it - Oct 20th 2013
// double overflow = PowerUnits.EU.convertTo( PowerUnits.AE, this.injectExternalPower( PowerUnits.EU, amount ) );
// this.internalCurrentPower += overflow;
// return 0; // see above comment.
// }
//
// @Override
// public void invalidate()
// {
// super.invalidate();
// this.removeFromENet();
// }
//
// private void removeFromENet()
// {
// if( IntegrationRegistry.INSTANCE.isEnabled( IntegrationType.IC2 ) )
// {
// IIC2 ic2Integration = (IIC2) IntegrationRegistry.INSTANCE.getInstance( IntegrationType.IC2 );
// if( this.isInIC2 && Platform.isServer() && ic2Integration != null )
// {
// ic2Integration.removeFromEnergyNet( this );
// this.isInIC2 = false;
// }
// }
// }
//
// @Override
// public void onChunkUnload()
// {
// super.onChunkUnload();
// this.removeFromENet();
// }
//
// @Override
// public void onReady()
// {
// super.onReady();
// this.addToENet();
// }
//
// private void addToENet()
// {
// if( IntegrationRegistry.INSTANCE.isEnabled( IntegrationType.IC2 ) )
// {
// IIC2 ic2Integration = (IIC2) IntegrationRegistry.INSTANCE.getInstance( IntegrationType.IC2 );
// if( !this.isInIC2 && Platform.isServer() && ic2Integration != null )
// {
// ic2Integration.addToEnergyNet( this );
// this.isInIC2 = true;
// }
// }
// }
//
// @Override
// protected void setPowerSides( EnumSet<ForgeDirection> sides )
// {
// super.setPowerSides( sides );
// this.removeFromENet();
// this.addToENet();
// }
//}
@@ -19,51 +19,45 @@
package appeng.tile.powersink;
import mekanism.api.energy.IStrictEnergyAcceptor;
import appeng.api.config.PowerUnits;
import appeng.api.util.ForgeDirection;
import appeng.transformer.annotations.Integration.Interface;
@Interface( iname = "Mekanism", iface = "mekanism.api.energy.IStrictEnergyAcceptor" )
public abstract class MekJoules extends RedstoneFlux implements IStrictEnergyAcceptor
{
@Override
public double getEnergy()
{
return 0;
}
@Override
public void setEnergy( double energy )
{
double extra = this.injectExternalPower( PowerUnits.MK, energy );
this.internalCurrentPower += PowerUnits.MK.convertTo( PowerUnits.AE, extra );
}
@Override
public double getMaxEnergy()
{
return this.getExternalPowerDemand( PowerUnits.MK, 100000 );
}
@Override
public double transferEnergyToAcceptor( ForgeDirection side, double amount )
{
double demand = this.getExternalPowerDemand( PowerUnits.MK, Double.MAX_VALUE );
if( amount > demand )
{
amount = demand;
}
double overflow = this.injectExternalPower( PowerUnits.MK, amount );
return amount - overflow;
}
@Override
public boolean canReceiveEnergy( ForgeDirection side )
{
return this.getPowerSides().contains( side );
}
}
//@Interface( iname = "Mekanism", iface = "mekanism.api.energy.IStrictEnergyAcceptor" )
//public abstract class MekJoules extends RedstoneFlux implements IStrictEnergyAcceptor
//{
//
// @Override
// public double getEnergy()
// {
// return 0;
// }
//
// @Override
// public void setEnergy( double energy )
// {
// double extra = this.injectExternalPower( PowerUnits.MK, energy );
// this.internalCurrentPower += PowerUnits.MK.convertTo( PowerUnits.AE, extra );
// }
//
// @Override
// public double getMaxEnergy()
// {
// return this.getExternalPowerDemand( PowerUnits.MK, 100000 );
// }
//
// @Override
// public double transferEnergyToAcceptor( ForgeDirection side, double amount )
// {
// double demand = this.getExternalPowerDemand( PowerUnits.MK, Double.MAX_VALUE );
// if( amount > demand )
// {
// amount = demand;
// }
//
// double overflow = this.injectExternalPower( PowerUnits.MK, amount );
// return amount - overflow;
// }
//
// @Override
// public boolean canReceiveEnergy( ForgeDirection side )
// {
// return this.getPowerSides().contains( side );
// }
//}
@@ -19,44 +19,38 @@
package appeng.tile.powersink;
import cofh.api.energy.IEnergyReceiver;
import appeng.api.config.PowerUnits;
import appeng.api.util.ForgeDirection;
import appeng.transformer.annotations.Integration.Interface;
@Interface( iname = "RF", iface = "cofh.api.energy.IEnergyReceiver" )
public abstract class RedstoneFlux extends RotaryCraft implements IEnergyReceiver
{
@Override
public final int receiveEnergy( ForgeDirection from, int maxReceive, boolean simulate )
{
final int networkRFDemand = (int) Math.floor( this.getExternalPowerDemand( PowerUnits.RF, maxReceive ) );
final int usedRF = Math.min( maxReceive, networkRFDemand );
if( !simulate )
{
this.injectExternalPower( PowerUnits.RF, usedRF );
}
return usedRF;
}
@Override
public final int getEnergyStored( ForgeDirection from )
{
return (int) Math.floor( PowerUnits.AE.convertTo( PowerUnits.RF, this.getAECurrentPower() ) );
}
@Override
public final int getMaxEnergyStored( ForgeDirection from )
{
return (int) Math.floor( PowerUnits.AE.convertTo( PowerUnits.RF, this.getAEMaxPower() ) );
}
@Override
public final boolean canConnectEnergy( ForgeDirection from )
{
return this.getPowerSides().contains( from );
}
}
//@Interface( iname = "RF", iface = "cofh.api.energy.IEnergyReceiver" )
//public abstract class RedstoneFlux extends RotaryCraft implements IEnergyReceiver
//{
// @Override
// public final int receiveEnergy( ForgeDirection from, int maxReceive, boolean simulate )
// {
// final int networkRFDemand = (int) Math.floor( this.getExternalPowerDemand( PowerUnits.RF, maxReceive ) );
// final int usedRF = Math.min( maxReceive, networkRFDemand );
//
// if( !simulate )
// {
// this.injectExternalPower( PowerUnits.RF, usedRF );
// }
//
// return usedRF;
// }
//
// @Override
// public final int getEnergyStored( ForgeDirection from )
// {
// return (int) Math.floor( PowerUnits.AE.convertTo( PowerUnits.RF, this.getAECurrentPower() ) );
// }
//
// @Override
// public final int getMaxEnergyStored( ForgeDirection from )
// {
// return (int) Math.floor( PowerUnits.AE.convertTo( PowerUnits.RF, this.getAEMaxPower() ) );
// }
//
// @Override
// public final boolean canConnectEnergy( ForgeDirection from )
// {
// return this.getPowerSides().contains( from );
// }
//}
@@ -19,166 +19,151 @@
package appeng.tile.powersink;
import appeng.transformer.annotations.Integration;
import net.minecraft.world.World;
import Reika.RotaryCraft.API.Interfaces.Transducerable;
import Reika.RotaryCraft.API.Power.AdvancedShaftPowerReceiver;
import appeng.api.config.PowerUnits;
import appeng.api.util.ForgeDirection;
import appeng.tile.TileEvent;
import appeng.tile.events.TileEventType;
import appeng.transformer.annotations.Integration.Interface;
import appeng.transformer.annotations.Integration.InterfaceList;
import appeng.transformer.annotations.Integration.Method;
import appeng.util.Platform;
import java.util.ArrayList;
@InterfaceList( value = { @Interface( iname = "RotaryCraft", iface = "Reika.RotaryCraft.API.Power.AdvancedShaftPowerReceiver" ), @Interface( iname = "RotaryCraft", iface = "Reika.RotaryCraft.API.Interfaces.Transducerable") } )
public abstract class RotaryCraft extends IC2 implements AdvancedShaftPowerReceiver, Transducerable
{
private int omega = 0;
private int torque = 0;
private long power = 0;
private int alpha = 0;
private long currentPower = 0;
@TileEvent( TileEventType.TICK )
@Method( iname = "RotaryCraft" )
public void Tick_RotaryCraft()
{
if( this.worldObj != null && !this.worldObj.isRemote && this.currentPower > 0 )
{
this.injectExternalPower( PowerUnits.WA, this.currentPower );
this.currentPower = 0;
}
}
@Override
public final boolean addPower( int torque, int omega, long power, ForgeDirection side )
{
this.omega = omega;
this.torque = torque;
this.power = power;
this.currentPower += power;
return true;
}
@Override
public final int getOmega()
{
return this.omega;
}
@Override
public final int getTorque()
{
return this.torque;
}
@Override
public final long getPower()
{
return this.power;
}
@Override
public final String getName()
{
return "AE";
}
@Override
public final int getIORenderAlpha()
{
return this.alpha;
}
@Override
public final void setIORenderAlpha( int io )
{
this.alpha = io;
}
public final boolean canReadFromBlock( int x, int y, int z )
{
ForgeDirection side = ForgeDirection.UNKNOWN;
if( x == this.xCoord - 1 )
{
side = ForgeDirection.WEST;
}
else if( x == this.xCoord + 1 )
{
side = ForgeDirection.EAST;
}
else if( z == this.zCoord - 1 )
{
side = ForgeDirection.NORTH;
}
else if( z == this.zCoord + 1 )
{
side = ForgeDirection.SOUTH;
}
else if( y == this.yCoord - 1 )
{
side = ForgeDirection.DOWN;
}
else if( y == this.yCoord + 1 )
{
side = ForgeDirection.UP;
}
return this.getPowerSides().contains( side );
}
@Override
public final boolean canReadFrom( ForgeDirection side )
{
return this.getPowerSides().contains( side );
}
@Override
public final boolean isReceiving()
{
return true;
}
@Override
public final int getMinTorque( int available )
{
return 1;
}
@Override
public final ArrayList<String> getMessages( World world, int x, int y, int z, int side )
{
String out;
if( power >= 1000000000 )
{
out = String.format( "Receiving %.3f GW @ %d rad/s.", power / 1000000000.0D, omega );
}
else if( power >= 1000000 )
{
out = String.format( "Receiving %.3f MW @ %d rad/s.", power / 1000000.0D, omega );
}
else if( power >= 1000 )
{
out = String.format( "Receiving %.3f kW @ %d rad/s.", power / 1000.0D, omega );
}
else
{
out = String.format( "Receiving %d W @ %d rad/s.", power, omega );
}
ArrayList<String> messages = new ArrayList<String>( 1 );
messages.add( out );
return messages;
}
}
//@InterfaceList( value = { @Interface( iname = "RotaryCraft", iface = "Reika.RotaryCraft.API.Power.AdvancedShaftPowerReceiver" ), @Interface( iname = "RotaryCraft", iface = "Reika.RotaryCraft.API.Interfaces.Transducerable") } )
//public abstract class RotaryCraft extends IC2 implements AdvancedShaftPowerReceiver, Transducerable
//{
//
// private int omega = 0;
// private int torque = 0;
// private long power = 0;
// private int alpha = 0;
//
// private long currentPower = 0;
//
// @TileEvent( TileEventType.TICK )
// @Method( iname = "RotaryCraft" )
// public void Tick_RotaryCraft()
// {
// if( this.worldObj != null && !this.worldObj.isRemote && this.currentPower > 0 )
// {
// this.injectExternalPower( PowerUnits.WA, this.currentPower );
// this.currentPower = 0;
// }
// }
//
// @Override
// public final boolean addPower( int torque, int omega, long power, ForgeDirection side )
// {
// this.omega = omega;
// this.torque = torque;
// this.power = power;
//
// this.currentPower += power;
//
// return true;
//
// }
//
// @Override
// public final int getOmega()
// {
// return this.omega;
// }
//
// @Override
// public final int getTorque()
// {
// return this.torque;
// }
//
// @Override
// public final long getPower()
// {
// return this.power;
// }
//
// @Override
// public final String getName()
// {
// return "AE";
// }
//
// @Override
// public final int getIORenderAlpha()
// {
// return this.alpha;
// }
//
// @Override
// public final void setIORenderAlpha( int io )
// {
// this.alpha = io;
// }
//
// public final boolean canReadFromBlock( int x, int y, int z )
// {
// ForgeDirection side = ForgeDirection.UNKNOWN;
//
// if( x == this.xCoord - 1 )
// {
// side = ForgeDirection.WEST;
// }
// else if( x == this.xCoord + 1 )
// {
// side = ForgeDirection.EAST;
// }
// else if( z == this.zCoord - 1 )
// {
// side = ForgeDirection.NORTH;
// }
// else if( z == this.zCoord + 1 )
// {
// side = ForgeDirection.SOUTH;
// }
// else if( y == this.yCoord - 1 )
// {
// side = ForgeDirection.DOWN;
// }
// else if( y == this.yCoord + 1 )
// {
// side = ForgeDirection.UP;
// }
//
// return this.getPowerSides().contains( side );
// }
//
// @Override
// public final boolean canReadFrom( ForgeDirection side )
// {
// return this.getPowerSides().contains( side );
// }
//
// @Override
// public final boolean isReceiving()
// {
// return true;
// }
//
// @Override
// public final int getMinTorque( int available )
// {
// return 1;
// }
//
// @Override
// public final ArrayList<String> getMessages( World world, int x, int y, int z, int side )
// {
// String out;
// if( power >= 1000000000 )
// {
// out = String.format( "Receiving %.3f GW @ %d rad/s.", power / 1000000000.0D, omega );
// }
// else if( power >= 1000000 )
// {
// out = String.format( "Receiving %.3f MW @ %d rad/s.", power / 1000000.0D, omega );
// }
// else if( power >= 1000 )
// {
// out = String.format( "Receiving %.3f kW @ %d rad/s.", power / 1000.0D, omega );
// }
// else
// {
// out = String.format( "Receiving %d W @ %d rad/s.", power, omega );
// }
//
//
// ArrayList<String> messages = new ArrayList<String>( 1 );
// messages.add( out );
// return messages;
// }
//}