Add backwards support for MJ5 ( from MJ6 )
Add another try catch facade test...
This commit is contained in:
parent
80428aec4e
commit
0b04d2853e
4 changed files with 104 additions and 12 deletions
|
@ -1,7 +1,12 @@
|
||||||
package appeng.integration.abstraction;
|
package appeng.integration.abstraction;
|
||||||
|
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
import buildcraft.api.mj.IBatteryObject;
|
||||||
|
|
||||||
public interface IMJ6
|
public interface IMJ6
|
||||||
{
|
{
|
||||||
|
|
||||||
|
IBatteryObject provider(TileEntity te, ForgeDirection side);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,11 +121,18 @@ public class BC extends BaseModule implements IBC
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return is.getItem() instanceof ItemFacade && ItemFacade.getType( is ) == ItemFacade.TYPE_BASIC;
|
return is.getItem() instanceof ItemFacade && ItemFacade.getType( is ) == ItemFacade.FacadeType.Basic;
|
||||||
}
|
}
|
||||||
catch (Throwable t)
|
catch (Throwable t)
|
||||||
{
|
{
|
||||||
return is.getItem() instanceof ItemFacade;
|
try
|
||||||
|
{
|
||||||
|
return is.getItem() instanceof ItemFacade && ItemFacade.getType( is ) == ItemFacade.TYPE_BASIC;
|
||||||
|
}
|
||||||
|
catch (Throwable g)
|
||||||
|
{
|
||||||
|
return is.getItem() instanceof ItemFacade;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,17 @@
|
||||||
package appeng.integration.modules;
|
package appeng.integration.modules;
|
||||||
|
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
import appeng.integration.BaseModule;
|
import appeng.integration.BaseModule;
|
||||||
import appeng.integration.abstraction.IMJ6;
|
import appeng.integration.abstraction.IMJ6;
|
||||||
|
import appeng.transformer.annotations.integration.Method;
|
||||||
import buildcraft.api.mj.IBatteryObject;
|
import buildcraft.api.mj.IBatteryObject;
|
||||||
import buildcraft.api.mj.IBatteryProvider;
|
import buildcraft.api.mj.IBatteryProvider;
|
||||||
import buildcraft.api.mj.ISidedBatteryProvider;
|
import buildcraft.api.mj.ISidedBatteryProvider;
|
||||||
|
import buildcraft.api.mj.MjAPI;
|
||||||
|
import buildcraft.api.power.IPowerReceptor;
|
||||||
|
import buildcraft.api.power.PowerHandler.PowerReceiver;
|
||||||
|
import buildcraft.api.power.PowerHandler.Type;
|
||||||
|
|
||||||
public class MJ6 extends BaseModule implements IMJ6
|
public class MJ6 extends BaseModule implements IMJ6
|
||||||
{
|
{
|
||||||
|
@ -15,7 +22,6 @@ public class MJ6 extends BaseModule implements IMJ6
|
||||||
TestClass( IBatteryObject.class );
|
TestClass( IBatteryObject.class );
|
||||||
TestClass( IBatteryProvider.class );
|
TestClass( IBatteryProvider.class );
|
||||||
TestClass( ISidedBatteryProvider.class );
|
TestClass( ISidedBatteryProvider.class );
|
||||||
throw new RuntimeException( "Disabled For Now!" );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -28,4 +34,78 @@ public class MJ6 extends BaseModule implements IMJ6
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Method(iname = "MJ5")
|
||||||
|
public IBatteryObject provider(final TileEntity te, final ForgeDirection side)
|
||||||
|
{
|
||||||
|
if ( te instanceof IPowerReceptor )
|
||||||
|
{
|
||||||
|
final IPowerReceptor recp = (IPowerReceptor) te;
|
||||||
|
final PowerReceiver ph = recp.getPowerReceiver( side );
|
||||||
|
|
||||||
|
return new IBatteryObject() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setEnergyStored(double mj)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IBatteryObject reconfigure(double maxCapacity, double maxReceivedPerCycle, double minimumConsumption)
|
||||||
|
{
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double minimumConsumption()
|
||||||
|
{
|
||||||
|
return ph.getMinEnergyReceived();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double maxReceivedPerCycle()
|
||||||
|
{
|
||||||
|
return ph.getMaxEnergyReceived();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double maxCapacity()
|
||||||
|
{
|
||||||
|
return ph.getMaxEnergyStored();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String kind()
|
||||||
|
{
|
||||||
|
return MjAPI.DEFAULT_POWER_FRAMEWORK;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getEnergyStored()
|
||||||
|
{
|
||||||
|
return ph.getEnergyStored();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getEnergyRequested()
|
||||||
|
{
|
||||||
|
return ph.getMaxEnergyStored() - ph.getEnergyStored();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double addEnergy(double mj, boolean ignoreCycleLimit)
|
||||||
|
{
|
||||||
|
return ph.receiveEnergy( Type.PIPE, mj, side );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double addEnergy(double mj)
|
||||||
|
{
|
||||||
|
return ph.receiveEnergy( Type.PIPE, mj, side );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ import appeng.api.networking.ticking.TickingRequest;
|
||||||
import appeng.core.AppEng;
|
import appeng.core.AppEng;
|
||||||
import appeng.core.settings.TickRates;
|
import appeng.core.settings.TickRates;
|
||||||
import appeng.integration.abstraction.IMJ5;
|
import appeng.integration.abstraction.IMJ5;
|
||||||
|
import appeng.integration.abstraction.IMJ6;
|
||||||
import appeng.integration.abstraction.helpers.BaseMJperdition;
|
import appeng.integration.abstraction.helpers.BaseMJperdition;
|
||||||
import appeng.me.GridAccessException;
|
import appeng.me.GridAccessException;
|
||||||
import appeng.me.cache.helpers.TunnelCollection;
|
import appeng.me.cache.helpers.TunnelCollection;
|
||||||
|
@ -153,7 +154,13 @@ public class PartP2PBCPower extends PartP2PTunnel<PartP2PBCPower> implements IPo
|
||||||
{
|
{
|
||||||
TileEntity te = getWorld().getTileEntity( tile.xCoord + side.offsetX, tile.yCoord + side.offsetY, tile.zCoord + side.offsetZ );
|
TileEntity te = getWorld().getTileEntity( tile.xCoord + side.offsetX, tile.yCoord + side.offsetY, tile.zCoord + side.offsetZ );
|
||||||
if ( te != null )
|
if ( te != null )
|
||||||
return MjAPI.getMjBattery( te );
|
{
|
||||||
|
IBatteryObject bo = MjAPI.getMjBattery( te, MjAPI.DEFAULT_POWER_FRAMEWORK, side.getOpposite() );
|
||||||
|
if ( bo != null )
|
||||||
|
return bo;
|
||||||
|
if ( AppEng.instance.isIntegrationEnabled( "MJ5" ) )
|
||||||
|
return ((IMJ6) AppEng.instance.getIntegration( "MJ6" )).provider( te, side.getOpposite() );
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,13 +220,6 @@ public class PartP2PBCPower extends PartP2PTunnel<PartP2PBCPower> implements IPo
|
||||||
return tile.getWorldObj();
|
return tile.getWorldObj();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
@Method(iname = "MJ6")
|
|
||||||
public IBatteryObject getMjBattery(String kind)
|
|
||||||
{
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Method(iname = "MJ6")
|
@Method(iname = "MJ6")
|
||||||
public IBatteryObject getMjBattery(String kind, ForgeDirection direction)
|
public IBatteryObject getMjBattery(String kind, ForgeDirection direction)
|
||||||
|
@ -267,7 +267,7 @@ public class PartP2PBCPower extends PartP2PTunnel<PartP2PBCPower> implements IPo
|
||||||
@Method(iname = "MJ6")
|
@Method(iname = "MJ6")
|
||||||
private double addEnergyInternal(double mj, boolean cycleLimitMode, boolean ignoreCycleLimit)
|
private double addEnergyInternal(double mj, boolean cycleLimitMode, boolean ignoreCycleLimit)
|
||||||
{
|
{
|
||||||
if ( !output && proxy.isActive() )
|
if ( output || !proxy.isActive() )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
double originaInput = mj;
|
double originaInput = mj;
|
||||||
|
|
Loading…
Reference in a new issue