Removes coremod (#3038)

From now on every integration must not rely on method stripping through
a coremod or @Optional. Notable example for a very good solution is IC2.

As consequence this drops all support for RF and mods must support on of
our supported energy types. At the time of writing, ForgeEnergy and
IC2/EU.
This commit is contained in:
yueh 2017-08-17 21:16:57 +02:00 committed by GitHub
parent 8a7450168b
commit c4fa21c193
43 changed files with 320 additions and 1596 deletions

View file

@ -58,7 +58,6 @@ archivesBaseName = aebasename
// Add Coremod Manifest
jar {
manifest {
attributes 'FMLCorePluginContainsFMLMod': 'true'
attributes 'FMLAT': 'appeng_at.cfg'
}
@ -74,8 +73,6 @@ jar {
}
minecraft {
coreMod = "appeng.coremod.AppEngCore"
version = minecraft_version + "-" + forge_version
replaceIn "AEConfig.java"

View file

@ -28,7 +28,6 @@ public enum TunnelType
{
ME, // Network Tunnel
IC2_POWER, // EU Tunnel
RF_POWER, // RF Tunnel
FE_POWER, // Forge Energy tunnel
REDSTONE, // Redstone Tunnel
FLUID, // Fluid Tunnel

View file

@ -82,8 +82,6 @@ public interface IParts
IItemDefinition p2PTunnelEU();
IItemDefinition p2PTunnelRF();
IItemDefinition p2PTunnelFE();
IItemDefinition p2PTunnelLight();

View file

@ -62,7 +62,6 @@ import appeng.core.AppEng;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketAssemblerAnimation;
import appeng.core.sync.packets.PacketValueConfig;
import appeng.coremod.MissingCoreMod;
import appeng.entity.EntityFloatingItem;
import appeng.entity.EntityTinyTNTPrimed;
import appeng.entity.RenderFloatingItem;
@ -241,12 +240,6 @@ public class ClientHelper extends ServerHelper
mc.world.markBlockRangeForRenderUpdate( x - range, y - range, z - range, x + range, y + range, z + range );
}
@Override
public void missingCoreMod()
{
throw new MissingCoreMod();
}
@SubscribeEvent
public void postPlayerRender( final RenderLivingEvent.Pre p )
{

View file

@ -33,7 +33,6 @@ import net.minecraft.world.biome.Biome;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.SidedProxy;
@ -57,6 +56,7 @@ import appeng.core.sync.network.NetworkHandler;
import appeng.core.worlddata.WorldData;
import appeng.hooks.TickHandler;
import appeng.integration.IntegrationRegistry;
import appeng.integration.IntegrationType;
import appeng.recipes.CustomRecipeConfig;
import appeng.recipes.CustomRecipeForgeConfiguration;
import appeng.server.AECommand;
@ -139,11 +139,6 @@ public final class AppEng
@EventHandler
private void preInit( final FMLPreInitializationEvent event )
{
if( !Loader.isModLoaded( "appliedenergistics2-core" ) )
{
AppEng.proxy.missingCoreMod();
}
final Stopwatch watch = Stopwatch.createStarted();
this.configDirectory = new File( event.getModConfigurationDirectory().getPath(), "AppliedEnergistics2" );
this.recipeDirectory = new File( this.configDirectory, "aerecipes" );
@ -171,6 +166,11 @@ public final class AppEng
CreativeTabFacade.init();
}
for( final IntegrationType type : IntegrationType.values() )
{
IntegrationRegistry.INSTANCE.add( type );
}
this.registration.preInitialize( event );
if( Platform.isClient() )

View file

@ -62,6 +62,4 @@ public abstract class CommonHelper
public abstract void updateRenderMode( EntityPlayer player );
public abstract void missingCoreMod();
}

View file

@ -240,16 +240,6 @@ final class Registration
// final Runnable recipeLoader = new RecipeLoader( recipeDirectory, customRecipeConfig, this.recipeHandler );
// recipeLoader.run();
if( IntegrationRegistry.INSTANCE.isEnabled( IntegrationType.RF ) )
{
partHelper.registerNewLayer( "appeng.parts.layers.LayerIEnergyHandler", "cofh.redstoneflux.api.IEnergyReceiver" );
}
// if (IntegrationRegistry.INSTANCE.isEnabled(IntegrationType.RF)) {
// partHelper.registerNewLayer("appeng.parts.layers.LayerIEnergyStorager",
// "net.minecraftforge.common.capabilities.ICapabilityProvider");
// }
//
// if( IntegrationRegistry.INSTANCE.isEnabled( IntegrationType.OpenComputers ) )
// {
// partHelper.registerNewLayer( "appeng.parts.layers.LayerSidedEnvironment",

View file

@ -64,7 +64,6 @@ public final class ApiParts implements IParts
private final IItemDefinition p2PTunnelItems;
private final IItemDefinition p2PTunnelFluids;
private final IItemDefinition p2PTunnelEU;
private final IItemDefinition p2PTunnelRF;
private final IItemDefinition p2PTunnelFE;
private final IItemDefinition p2PTunnelLight;
// private final IItemDefinition p2PTunnelOpenComputers;
@ -118,7 +117,6 @@ public final class ApiParts implements IParts
this.p2PTunnelItems = new DamagedItemDefinition( "part.tunnel.item", itemPart.createPart( PartType.P2P_TUNNEL_ITEMS ) );
this.p2PTunnelFluids = new DamagedItemDefinition( "part.tunnel.fluid", itemPart.createPart( PartType.P2P_TUNNEL_FLUIDS ) );
this.p2PTunnelEU = new DamagedItemDefinition( "part.tunnel.eu", itemPart.createPart( PartType.P2P_TUNNEL_IC2 ) );
this.p2PTunnelRF = new DamagedItemDefinition( "part.tunnel.rf", itemPart.createPart( PartType.P2P_TUNNEL_RF ) );
this.p2PTunnelFE = new DamagedItemDefinition( "part.tunnel.fe", itemPart.createPart( PartType.P2P_TUNNEL_FE ) );
this.p2PTunnelLight = new DamagedItemDefinition( "part.tunnel.light", itemPart.createPart( PartType.P2P_TUNNEL_LIGHT ) );
// this.p2PTunnelOpenComputers = new DamagedItemDefinition( itemMultiPart.createPart(
@ -303,12 +301,6 @@ public final class ApiParts implements IParts
return this.p2PTunnelEU;
}
@Override
public IItemDefinition p2PTunnelRF()
{
return this.p2PTunnelRF;
}
@Override
public IItemDefinition p2PTunnelFE()
{

View file

@ -113,7 +113,6 @@ public enum AEFeature
DENSE_ENERGY_CELLS( "DenseEnergyCells", Constants.CATEGORY_HIGHER_CAPACITY ),
DENSE_CABLES( "DenseCables", Constants.CATEGORY_HIGHER_CAPACITY ),
P2P_TUNNEL_RF( "P2PTunnelRF", Constants.CATEGORY_P2P_TUNNELS ),
P2P_TUNNEL_ME( "P2PTunnelME", Constants.CATEGORY_P2P_TUNNELS ),
P2P_TUNNEL_ITEMS( "P2PTunnelItems", Constants.CATEGORY_P2P_TUNNELS ),
P2P_TUNNEL_REDSTONE( "P2PTunnelRedstone", Constants.CATEGORY_P2P_TUNNELS ),

View file

@ -73,22 +73,12 @@ public final class P2PTunnelRegistry implements IP2PTunnelRegistry
this.addNewAttunement( blocks.energyCell(), TunnelType.FE_POWER );
this.addNewAttunement( blocks.energyCellCreative(), TunnelType.FE_POWER );
/**
* RF tunnel items
*/
this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_0", 0 ), TunnelType.RF_POWER ); // leadstone
// fluxduct
this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_0", 1 ), TunnelType.RF_POWER ); // hardened
// fluxduct
this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_0", 2 ), TunnelType.RF_POWER ); // redstone
// fluxduct
this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_0", 3 ), TunnelType.RF_POWER ); // signalum
// fluxduct
this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_0", 4 ), TunnelType.RF_POWER ); // resonant
// fluxduct
this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_0", 5 ), TunnelType.RF_POWER ); // cryo-stabilized
// fluxduct
this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_0", 0 ), TunnelType.FE_POWER );
this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_0", 1 ), TunnelType.FE_POWER );
this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_0", 2 ), TunnelType.FE_POWER );
this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_0", 3 ), TunnelType.FE_POWER );
this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_0", 4 ), TunnelType.FE_POWER );
this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_0", 5 ), TunnelType.FE_POWER );
/**
* EU tunnel items
@ -174,15 +164,15 @@ public final class P2PTunnelRegistry implements IP2PTunnelRegistry
* attune based on the ItemStack's modId
*/
this.addNewAttunement( "thermaldynamics", TunnelType.RF_POWER );
this.addNewAttunement( "thermalexpansion", TunnelType.RF_POWER );
this.addNewAttunement( "thermalfoundation", TunnelType.RF_POWER );
this.addNewAttunement( "thermaldynamics", TunnelType.FE_POWER );
this.addNewAttunement( "thermalexpansion", TunnelType.FE_POWER );
this.addNewAttunement( "thermalfoundation", TunnelType.FE_POWER );
// TODO: Remove when confirmed that the official 1.12 version of EnderIO will support FE.
this.addNewAttunement( "enderio", TunnelType.RF_POWER );
this.addNewAttunement( "enderio", TunnelType.FE_POWER );
// TODO: Remove when confirmed that the official 1.12 version of Mekanism will support FE.
this.addNewAttunement( "mekanism", TunnelType.RF_POWER );
this.addNewAttunement( "mekanism", TunnelType.FE_POWER );
// TODO: Remove when support for RFTools' Powercells support is added
this.addNewAttunement( "rftools", TunnelType.RF_POWER );
this.addNewAttunement( "rftools", TunnelType.FE_POWER );
this.addNewAttunement( "ic2", TunnelType.IC2_POWER );
}

View file

@ -89,7 +89,6 @@ public enum GuiText
FluidTunnel,
OCTunnel,
LightTunnel,
RFTunnel,
FETunnel,
PressureTunnel,

View file

@ -1,133 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.coremod;
import java.util.Map;
import javax.annotation.Nullable;
import com.google.common.eventbus.EventBus;
import org.apache.logging.log4j.Level;
import net.minecraftforge.fml.common.DummyModContainer;
import net.minecraftforge.fml.common.FMLLog;
import net.minecraftforge.fml.common.LoadController;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.ModMetadata;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin;
import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin.MCVersion;
import appeng.core.AEConfig;
@MCVersion( "1.12" )
public final class AppEngCore extends DummyModContainer implements IFMLLoadingPlugin
{
private final ModMetadata metadata = new ModMetadata();
public AppEngCore()
{
FMLLog.log( "AE2-CORE", Level.INFO, "[AppEng] Core Init" );
this.metadata.autogenerated = false;
this.metadata.authorList.add( "AlgorithmX2" );
this.metadata.credits = "AlgorithmX2";
this.metadata.modId = this.getModId();
this.metadata.version = this.getVersion();
this.metadata.name = this.getName();
this.metadata.url = "http://ae2.ae-mod.info";
this.metadata.logoFile = "assets/appliedenergistics2/meta/logo.png";
this.metadata.description = "Embedded Coremod for Applied Energistics 2";
}
@EventHandler
public void load( final FMLInitializationEvent event )
{
}
@Override
public String[] getASMTransformerClass()
{
return new String[] { "appeng.coremod.transformer.ASMIntegration" };
}
@Override
public String getModContainerClass()
{
return "appeng.coremod.AppEngCore";
}
@Nullable
@Override
public String getSetupClass()
{
return null;
}
@Override
public void injectData( final Map<String, Object> data )
{
}
@Override
public String getAccessTransformerClass()
{
return null;
}
@Override
public ModMetadata getMetadata()
{
return this.metadata;
}
@Override
public String getModId()
{
return "appliedenergistics2-core";
}
@Override
public String getName()
{
return "Applied Energistics 2 Core";
}
@Override
public String getVersion()
{
return AEConfig.VERSION;
}
@Override
public boolean registerBus( final EventBus bus, final LoadController controller )
{
return true;
}
@Override
public String getDisplayVersion()
{
return this.getVersion();
}
}

View file

@ -1,100 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.coremod;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiErrorScreen;
import net.minecraftforge.fml.client.CustomModLoadingErrorDisplayException;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly( Side.CLIENT )
public final class MissingCoreMod extends CustomModLoadingErrorDisplayException
{
private static final int SHADOW_WHITE = 0xeeeeee;
private static final int COLOR_WHITE = 0xffffff;
private static final long serialVersionUID = -966774766922821652L;
private static final int SCREEN_OFFSET = 15;
private boolean deobf = false;
@Override
public void initGui( final GuiErrorScreen errorScreen, final FontRenderer fontRenderer )
{
final Class<?> clz = errorScreen.getClass();
try
{
clz.getField( "mc" );
this.deobf = true;
}
catch( final Throwable ignored )
{
}
}
@Override
public void drawScreen( final GuiErrorScreen errorScreen, final FontRenderer fontRenderer, final int mouseRelX, final int mouseRelY, final float tickTime )
{
int offset = 10;
this.drawCenteredString( fontRenderer, "Sorry, couldn't load AE2 properly.", errorScreen.width / 2, offset, COLOR_WHITE );
offset += SCREEN_OFFSET;
this.drawCenteredString( fontRenderer, "Please make sure that AE2 is installed into your mods folder.", errorScreen.width / 2, offset, SHADOW_WHITE );
offset += 2 * SCREEN_OFFSET;
if( this.deobf )
{
offset += SCREEN_OFFSET;
this.drawCenteredString( fontRenderer, "In a developer environment add the following too your args,", errorScreen.width / 2, offset, COLOR_WHITE );
offset += SCREEN_OFFSET;
this.drawCenteredString( fontRenderer, "-Dfml.coreMods.load=appeng.coremod.AppEngCore", errorScreen.width / 2, offset, SHADOW_WHITE );
}
else
{
this.drawCenteredString( fontRenderer, "Your launcher may refer to this by different names,", errorScreen.width / 2, offset, COLOR_WHITE );
offset += SCREEN_OFFSET + 5;
this.drawCenteredString( fontRenderer, "MultiMC calls this tab \"Loader Mods\"", errorScreen.width / 2, offset, SHADOW_WHITE );
offset += SCREEN_OFFSET;
this.drawCenteredString( fontRenderer, "Magic Launcher calls this tab \"External Mods\"", errorScreen.width / 2, offset, SHADOW_WHITE );
offset += SCREEN_OFFSET;
this.drawCenteredString( fontRenderer, "Most other launchers refer to this tab as just \"Mods\"", errorScreen.width / 2, offset, SHADOW_WHITE );
offset += 2 * SCREEN_OFFSET;
this.drawCenteredString( fontRenderer, "Also make sure that the AE2 file is a .jar, and not a .zip", errorScreen.width / 2, offset, COLOR_WHITE );
}
}
private void drawCenteredString( final FontRenderer fontRenderer, final String string, final int x, final int y, final int colour )
{
final String reEncoded = string.replaceAll( "\\P{InBasic_Latin}", "" );
final int reEncodedWidth = fontRenderer.getStringWidth( reEncoded );
final int centeredX = x - reEncodedWidth / 2;
fontRenderer.drawStringWithShadow( string, centeredX, y, colour );
}
}

View file

@ -1,54 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.coremod.annotations;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import appeng.integration.IntegrationType;
public @interface Integration
{
@Retention( RetentionPolicy.RUNTIME )
@Target( ElementType.TYPE )
@interface InterfaceList
{
Interface[] value();
}
@Retention( RetentionPolicy.RUNTIME )
@Target( ElementType.TYPE )
@interface Interface
{
String iface();
IntegrationType iname();
}
@Retention( RetentionPolicy.RUNTIME )
@Target( ElementType.METHOD )
@interface Method
{
IntegrationType iname();
}
}

View file

@ -1,255 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.coremod.transformer;
import java.util.Iterator;
import javax.annotation.Nullable;
import org.apache.logging.log4j.Level;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.Type;
import org.objectweb.asm.tree.AnnotationNode;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.MethodNode;
import net.minecraft.launchwrapper.IClassTransformer;
import net.minecraftforge.fml.common.FMLLog;
import appeng.coremod.annotations.Integration;
import appeng.helpers.Reflected;
import appeng.integration.IntegrationRegistry;
import appeng.integration.IntegrationType;
@Reflected
public final class ASMIntegration implements IClassTransformer
{
@Reflected
public ASMIntegration()
{
/**
* Side, Display Name, ModID ClassPostFix
*/
for( final IntegrationType type : IntegrationType.values() )
{
IntegrationRegistry.INSTANCE.add( type );
}
// integrationModules.add( IntegrationSide.BOTH, "Thermal Expansion", "ThermalExpansion", IntegrationType.TE );
// integrationModules.add( IntegrationSide.BOTH, "Mystcraft", "Mystcraft", IntegrationType.Mystcraft );
// integrationModules.add( IntegrationSide.BOTH, "Greg Tech", "gregtech_addon", IntegrationType.GT );
// integrationModules.add( IntegrationSide.BOTH, "Universal Electricity", null, IntegrationType.UE );
// integrationModules.add( IntegrationSide.BOTH, "Logistics Pipes", "LogisticsPipes|Main", IntegrationType.LP );
// integrationModules.add( IntegrationSide.BOTH, "Better Storage", IntegrationType.betterstorage );
// integrationModules.add( IntegrationSide.BOTH, "Forestry", "Forestry", IntegrationType.Forestry );
// integrationModules.add( IntegrationSide.BOTH, "Mekanism", "Mekanism", IntegrationType.Mekanism );
}
@Nullable
@Override
public byte[] transform( final String name, final String transformedName, final byte[] basicClass )
{
if( basicClass == null || transformedName.startsWith( "appeng.coremod" ) )
{
return basicClass;
}
if( transformedName.startsWith( "appeng." ) )
{
final ClassNode classNode = new ClassNode();
final ClassReader classReader = new ClassReader( basicClass );
classReader.accept( classNode, 0 );
try
{
final boolean reWrite = this.removeOptionals( classNode );
if( reWrite )
{
final ClassWriter writer = new ClassWriter( ClassWriter.COMPUTE_MAXS );
classNode.accept( writer );
return writer.toByteArray();
}
}
catch( final Throwable t )
{
t.printStackTrace();
}
}
return basicClass;
}
private boolean removeOptionals( final ClassNode classNode )
{
boolean changed = false;
if( classNode.visibleAnnotations != null )
{
for( final AnnotationNode an : classNode.visibleAnnotations )
{
if( this.hasAnnotation( an, Integration.Interface.class ) )
{
if( this.stripInterface( classNode, Integration.Interface.class, an ) )
{
changed = true;
}
}
else if( this.hasAnnotation( an, Integration.InterfaceList.class ) )
{
for( final Object o : ( (Iterable) an.values.get( 1 ) ) )
{
if( this.stripInterface( classNode, Integration.InterfaceList.class, (AnnotationNode) o ) )
{
changed = true;
}
}
}
}
}
final Iterator<MethodNode> i = classNode.methods.iterator();
while( i.hasNext() )
{
final MethodNode mn = i.next();
if( mn.visibleAnnotations != null )
{
for( final AnnotationNode an : mn.visibleAnnotations )
{
if( this.hasAnnotation( an, Integration.Method.class ) )
{
if( this.stripMethod( classNode, mn, i, Integration.Method.class, an ) )
{
changed = true;
}
}
}
}
}
if( changed )
{
this.log( "Updated " + classNode.name );
}
return changed;
}
private boolean hasAnnotation( final AnnotationNode ann, final Class<?> annotation )
{
return ann.desc.equals( Type.getDescriptor( annotation ) );
}
private boolean stripInterface( final ClassNode classNode, final Class<?> class1, final AnnotationNode an )
{
if( an.values.size() != 4 )
{
throw new IllegalArgumentException( "Unable to handle Interface annotation on " + classNode.name );
}
String iFace = null;
if( an.values.get( 0 ).equals( "iface" ) )
{
iFace = (String) an.values.get( 1 );
}
else if( an.values.get( 2 ).equals( "iface" ) )
{
iFace = (String) an.values.get( 3 );
}
String iName = null;
if( an.values.get( 0 ).equals( "iname" ) )
{
iName = ( (String[]) an.values.get( 1 ) )[1];
}
else if( an.values.get( 2 ).equals( "iname" ) )
{
iName = ( (String[]) an.values.get( 3 ) )[1];
}
if( iName != null && iFace != null )
{
final IntegrationType type = IntegrationType.valueOf( iName );
if( !IntegrationRegistry.INSTANCE.isEnabled( type ) )
{
this.log( "Removing Interface " + iFace + " from " + classNode.name + " because " + iName + " integration is disabled." );
classNode.interfaces.remove( iFace.replace( '.', '/' ) );
return true;
}
else
{
this.log( "Allowing Interface " + iFace + " from " + classNode.name + " because " + iName + " integration is enabled." );
}
}
else
{
throw new IllegalStateException( "Unable to handle Method annotation on " + classNode.name );
}
return false;
}
private boolean stripMethod( final ClassNode classNode, final MethodNode mn, final Iterator<MethodNode> i, final Class class1, final AnnotationNode an )
{
if( an.values.size() != 2 )
{
throw new IllegalArgumentException( "Unable to handle Method annotation on " + classNode.name );
}
String iName = null;
if( an.values.get( 0 ).equals( "iname" ) )
{
iName = ( (String[]) an.values.get( 1 ) )[1];
}
if( iName != null )
{
final IntegrationType type = IntegrationType.valueOf( iName );
if( !IntegrationRegistry.INSTANCE.isEnabled( type ) )
{
this.log( "Removing Method " + mn.name + " from " + classNode.name + " because " + iName + " integration is disabled." );
i.remove();
return true;
}
else
{
this.log( "Allowing Method " + mn.name + " from " + classNode.name + " because " + iName + " integration is enabled." );
}
}
else
{
throw new IllegalStateException( "Unable to handle Method annotation on " + classNode.name );
}
return false;
}
private void log( final String string )
{
FMLLog.log( "AE2-CORE", Level.INFO, string );
}
}

View file

@ -21,7 +21,6 @@ package appeng.integration;
import appeng.integration.modules.ic2.IC2Module;
import appeng.integration.modules.jei.JEIModule;
import appeng.integration.modules.rf.RFModule;
import appeng.integration.modules.theoneprobe.TheOneProbeModule;
import appeng.integration.modules.waila.WailaModule;
@ -39,24 +38,6 @@ public enum IntegrationType
RC( IntegrationSide.BOTH, "Railcraft", "railcraft" ),
RF( IntegrationSide.BOTH, "RedstoneFlux Power - Tiles", "redstoneflux" )
{
@Override
public IIntegrationModule createInstance()
{
return new RFModule();
}
},
RFItem( IntegrationSide.BOTH, "RedstoneFlux Power - Items", "redstoneflux" )
{
@Override
public IIntegrationModule createInstance()
{
return new RFModule();
}
},
MFR( IntegrationSide.BOTH, "Mine Factory Reloaded", "minefactoryreloaded" ),
Waila( IntegrationSide.BOTH, "Waila", "waila" )

View file

@ -24,7 +24,6 @@ import appeng.integration.abstraction.IInvTweaks;
import appeng.integration.abstraction.IJEI;
import appeng.integration.abstraction.IMekanism;
import appeng.integration.abstraction.IRC;
import appeng.integration.abstraction.IRF;
/**
@ -43,8 +42,6 @@ public final class Integrations
static IInvTweaks invTweaks = new IInvTweaks.Stub();
static IRF redstoneflux = new IRF.Stub();
private Integrations()
{
}
@ -104,10 +101,4 @@ public final class Integrations
return invTweaks;
}
static IRF setRedstoneFlux( IRF redstoneflux )
{
Integrations.redstoneflux = redstoneflux;
return redstoneflux;
}
}

View file

@ -1,34 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2017, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.abstraction;
import appeng.integration.IIntegrationModule;
/**
* @author GuntherDW
*/
public interface IRF
{
class Stub extends IIntegrationModule.Stub implements IRF
{
}
}

View file

@ -1,39 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2017, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.rf;
import appeng.integration.IIntegrationModule;
import appeng.integration.IntegrationHelper;
/**
* @author GuntherDW
*/
public class RFModule implements IIntegrationModule
{
public RFModule()
{
IntegrationHelper.testClassExistence( this, cofh.redstoneflux.api.IEnergyContainerItem.class );
IntegrationHelper.testClassExistence( this, cofh.redstoneflux.api.IEnergyProvider.class );
IntegrationHelper.testClassExistence( this, cofh.redstoneflux.api.IEnergyConnection.class );
IntegrationHelper.testClassExistence( this, cofh.redstoneflux.api.IEnergyContainerItem.class );
}
}

View file

@ -65,7 +65,6 @@ import appeng.parts.p2p.PartP2PFluids;
import appeng.parts.p2p.PartP2PIC2Power;
import appeng.parts.p2p.PartP2PItems;
import appeng.parts.p2p.PartP2PLight;
import appeng.parts.p2p.PartP2PRFPower;
import appeng.parts.p2p.PartP2PRedstone;
import appeng.parts.p2p.PartP2PTunnelME;
import appeng.parts.reporting.PartConversionMonitor;
@ -270,16 +269,6 @@ public enum PartType
}
},
P2P_TUNNEL_RF( 466, "p2p_tunnel_rf", EnumSet.of( AEFeature.P2P_TUNNEL, AEFeature.P2P_TUNNEL_RF ), EnumSet
.of( IntegrationType.RF ), PartP2PRFPower.class, GuiText.RFTunnel )
{
@Override
String getUnlocalizedName()
{
return "p2p_tunnel";
}
},
P2P_TUNNEL_LIGHT( 467, "p2p_tunnel_light", EnumSet.of( AEFeature.P2P_TUNNEL, AEFeature.P2P_TUNNEL_LIGHT ), EnumSet
.noneOf( IntegrationType.class ), PartP2PLight.class, GuiText.LightTunnel )
{

View file

@ -1,66 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.items.tools.powered.powersink;
import net.minecraft.item.ItemStack;
import cofh.redstoneflux.api.IEnergyContainerItem;
import appeng.api.config.Actionable;
import appeng.api.config.PowerUnits;
import appeng.coremod.annotations.Integration.Interface;
import appeng.integration.IntegrationType;
@Interface( iface = "cofh.redstoneflux.api.IEnergyContainerItem", iname = IntegrationType.RFItem )
public abstract class RedstoneFlux extends AEBasePoweredItem implements IEnergyContainerItem
{
public RedstoneFlux( final double powerCapacity )
{
super( powerCapacity );
}
@Override
public int receiveEnergy( final ItemStack is, final int maxReceive, final boolean simulate )
{
final double convertedPower = PowerUnits.RF.convertTo( PowerUnits.AE, maxReceive );
final double overflow = (int) this.injectAEPower( is, convertedPower, simulate ? Actionable.SIMULATE : Actionable.MODULATE );
return (int) ( maxReceive - overflow );
}
@Override
public int extractEnergy( final ItemStack container, final int maxExtract, final boolean simulate )
{
return 0;
}
@Override
public int getEnergyStored( final ItemStack is )
{
return (int) PowerUnits.AE.convertTo( PowerUnits.RF, this.getAECurrentPower( is ) );
}
@Override
public int getMaxEnergyStored( final ItemStack is )
{
return (int) PowerUnits.AE.convertTo( PowerUnits.RF, this.getAEMaxPower( is ) );
}
}

View file

@ -1,95 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.parts.layers;
import net.minecraft.util.EnumFacing;
import cofh.redstoneflux.api.IEnergyConnection;
import cofh.redstoneflux.api.IEnergyHandler;
import cofh.redstoneflux.api.IEnergyProvider;
import cofh.redstoneflux.api.IEnergyReceiver;
import appeng.api.parts.IPart;
import appeng.api.parts.LayerBase;
public class LayerIEnergyHandler extends LayerBase implements IEnergyHandler, IEnergyReceiver, IEnergyProvider
{
@Override
public int receiveEnergy( EnumFacing from, int maxReceive, boolean simulate )
{
IPart part = this.getPart( from );
if( part instanceof IEnergyReceiver )
{
return ( (IEnergyReceiver) part ).receiveEnergy( from, maxReceive, simulate );
}
return 0;
}
@Override
public int extractEnergy( EnumFacing from, int maxExtract, boolean simulate )
{
IPart part = this.getPart( from );
if( part instanceof IEnergyProvider )
{
return ( (IEnergyProvider) part ).extractEnergy( from, maxExtract, simulate );
}
return 0;
}
@Override
public int getEnergyStored( EnumFacing from )
{
IPart part = this.getPart( from );
if( part instanceof IEnergyProvider )
{
return ( (IEnergyProvider) part ).getEnergyStored( from );
}
return 0;
}
@Override
public int getMaxEnergyStored( EnumFacing from )
{
IPart part = this.getPart( from );
if( part instanceof IEnergyProvider )
{
return ( (IEnergyProvider) part ).getMaxEnergyStored( from );
}
return 0;
}
@Override
public boolean canConnectEnergy( EnumFacing from )
{
IPart part = this.getPart( from );
if( part instanceof IEnergyConnection )
{
return ( (IEnergyConnection) part ).canConnectEnergy( from );
}
return false;
}
}

View file

@ -1,236 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.parts.p2p;
import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import cofh.redstoneflux.api.IEnergyReceiver;
import appeng.api.config.PowerUnits;
import appeng.api.parts.IPartModel;
import appeng.coremod.annotations.Integration.Interface;
import appeng.coremod.annotations.Integration.InterfaceList;
import appeng.integration.IntegrationType;
import appeng.items.parts.PartModels;
import appeng.me.GridAccessException;
@InterfaceList( value = { @Interface( iface = "cofh.redstoneflux.api.IEnergyReceiver", iname = IntegrationType.RF ) } )
public final class PartP2PRFPower extends PartP2PTunnel<PartP2PRFPower> implements IEnergyReceiver
{
private static final P2PModels MODELS = new P2PModels( "part/p2p/p2p_tunnel_rf" );
private static final IEnergyReceiver NULL_ENERGY_RECEIVER = new NullEnergyReceiver();
private boolean cachedTarget = false;
private IEnergyReceiver outputTarget;
public PartP2PRFPower( ItemStack is )
{
super( is );
}
@PartModels
public static List<IPartModel> getModels()
{
return MODELS.getModels();
}
@Override
public IPartModel getStaticModels()
{
return MODELS.getModel( this.isPowered(), this.isActive() );
}
@Override
public void onTunnelNetworkChange()
{
this.getHost().notifyNeighbors();
}
@Override
public void onNeighborChanged( IBlockAccess w, BlockPos pos, BlockPos neighbor )
{
super.onNeighborChanged( w, pos, neighbor );
this.cachedTarget = false;
}
@Override
public int receiveEnergy( EnumFacing from, int maxReceive, boolean simulate )
{
if( this.isOutput() )
{
return 0;
}
if( this.isActive() )
{
int total = 0;
try
{
final int outputTunnels = this.getOutputs().size();
if( outputTunnels == 0 )
{
return 0;
}
final int amountPerOutput = maxReceive / outputTunnels;
int overflow = maxReceive % amountPerOutput;
for( PartP2PRFPower target : this.getOutputs() )
{
final IEnergyReceiver output = target.getOutput();
final int toSend = amountPerOutput + overflow;
final int received = output.receiveEnergy( target.getSide().getFacing().getOpposite(), toSend, simulate );
overflow = toSend - received;
total += received;
}
this.queueTunnelDrain( PowerUnits.RF, total );
}
catch( GridAccessException ignored )
{
}
return total;
}
return 0;
}
private IEnergyReceiver getOutput()
{
if( this.isOutput() )
{
if( !this.cachedTarget )
{
final TileEntity self = this.getTile();
final 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 instanceof IEnergyReceiver ? (IEnergyReceiver) te : null;
this.cachedTarget = true;
}
if( this.outputTarget != null && this.outputTarget.canConnectEnergy( this.getSide().getOpposite().getFacing() ) )
{
return this.outputTarget;
}
}
return NULL_ENERGY_RECEIVER;
}
@Override
public int getEnergyStored( EnumFacing from )
{
if( this.isOutput() || !this.isActive() )
{
return 0;
}
int total = 0;
try
{
for( PartP2PRFPower t : this.getOutputs() )
{
total += t.getOutput().getEnergyStored( this.getSide().getOpposite().getFacing() );
}
}
catch( GridAccessException e )
{
return 0;
}
return total;
}
@Override
public int getMaxEnergyStored( EnumFacing from )
{
if( this.isOutput() || !this.isActive() )
{
return 0;
}
int total = 0;
try
{
for( PartP2PRFPower t : this.getOutputs() )
{
total += t.getOutput().getMaxEnergyStored( this.getSide().getOpposite().getFacing() );
}
}
catch( GridAccessException e )
{
return 0;
}
return total;
}
@Override
public boolean canConnectEnergy( EnumFacing from )
{
return true;
}
private static class NullEnergyReceiver implements IEnergyReceiver
{
@Override
public int getEnergyStored( EnumFacing from )
{
return 0;
}
@Override
public int getMaxEnergyStored( EnumFacing from )
{
return 0;
}
@Override
public boolean canConnectEnergy( EnumFacing from )
{
return true;
}
@Override
public int receiveEnergy( EnumFacing from, int maxReceive, boolean simulate )
{
return 0;
}
}
}

View file

@ -222,10 +222,6 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
newType = parts.p2PTunnelLight().maybeStack( 1 ).orElse( ItemStack.EMPTY );
break;
case RF_POWER:
newType = parts.p2PTunnelRF().maybeStack( 1 ).orElse( ItemStack.EMPTY );
break;
case FE_POWER:
newType = parts.p2PTunnelFE().maybeStack( 1 ).orElse( ItemStack.EMPTY );
break;

View file

@ -162,12 +162,6 @@ public class ServerHelper extends CommonHelper
this.renderModeBased = player;
}
@Override
public void missingCoreMod()
{
throw new IllegalStateException( "Unable to Load Core Mod, please verify that AE2 is properly install in the mods folder, with a .jar extension." );
}
protected CableRenderMode renderModeForPlayer( final EntityPlayer player )
{
if( player != null )

View file

@ -19,7 +19,308 @@
package appeng.tile.powersink;
public abstract class AEBasePoweredTile extends RedstoneFlux
import java.util.EnumSet;
import javax.annotation.Nullable;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.energy.IEnergyStorage;
import appeng.api.config.AccessRestriction;
import appeng.api.config.Actionable;
import appeng.api.config.PowerMultiplier;
import appeng.api.config.PowerUnits;
import appeng.api.networking.energy.IAEPowerStorage;
import appeng.api.networking.events.MENetworkPowerStorage.PowerEventType;
import appeng.capabilities.Capabilities;
import appeng.integration.Integrations;
import appeng.integration.abstraction.IC2PowerSink;
import appeng.tile.AEBaseInvTile;
import appeng.tile.TileEvent;
import appeng.tile.events.TileEventType;
public abstract class AEBasePoweredTile extends AEBaseInvTile implements IAEPowerStorage, IExternalPowerSink
{
// values that determine general function, are set by inheriting classes if
// needed. These should generally remain static.
private double internalMaxPower = 10000;
private boolean internalPublicPowerStorage = false;
private AccessRestriction internalPowerFlow = AccessRestriction.READ_WRITE;
// the current power buffer.
private double internalCurrentPower = 0;
private EnumSet<EnumFacing> internalPowerSides = EnumSet.allOf( EnumFacing.class );
private final IEnergyStorage forgeEnergyAdapter;
private Object teslaEnergyAdapter;
private IC2PowerSink ic2Sink;
public AEBasePoweredTile()
{
this.forgeEnergyAdapter = new ForgeEnergyAdapter( this );
if( Capabilities.TESLA_CONSUMER != null )
{
this.teslaEnergyAdapter = new TeslaEnergyAdapter( this );
}
this.ic2Sink = Integrations.ic2().createPowerSink( this, this );
this.ic2Sink.setValidFaces( this.internalPowerSides );
}
protected EnumSet<EnumFacing> getPowerSides()
{
return this.internalPowerSides.clone();
}
protected void setPowerSides( final EnumSet<EnumFacing> sides )
{
this.internalPowerSides = sides;
this.ic2Sink.setValidFaces( sides );
// trigger re-calc!
}
@TileEvent( TileEventType.WORLD_NBT_WRITE )
public void writeToNBT_AERootPoweredTile( final NBTTagCompound data )
{
data.setDouble( "internalCurrentPower", this.getInternalCurrentPower() );
}
@TileEvent( TileEventType.WORLD_NBT_READ )
public void readFromNBT_AERootPoweredTile( final NBTTagCompound data )
{
this.setInternalCurrentPower( data.getDouble( "internalCurrentPower" ) );
}
@Override
public final double getExternalPowerDemand( final PowerUnits externalUnit, final double maxPowerRequired )
{
return PowerUnits.AE.convertTo( externalUnit, Math.max( 0.0, this.getFunnelPowerDemand( externalUnit.convertTo( PowerUnits.AE, maxPowerRequired ) ) ) );
}
protected double getFunnelPowerDemand( final double maxRequired )
{
return this.getInternalMaxPower() - this.getInternalCurrentPower();
}
@Override
public final double injectExternalPower( final PowerUnits input, final double amt )
{
return PowerUnits.AE.convertTo( input, this.funnelPowerIntoStorage( input.convertTo( PowerUnits.AE, amt ), Actionable.MODULATE ) );
}
protected double funnelPowerIntoStorage( final double power, final Actionable mode )
{
return this.injectAEPower( power, mode );
}
@Override
public final double injectAEPower( double amt, final Actionable mode )
{
if( amt < 0.000001 )
{
return 0;
}
if( mode == Actionable.SIMULATE )
{
final double fakeBattery = this.getInternalCurrentPower() + amt;
if( fakeBattery > this.getInternalMaxPower() )
{
return fakeBattery - this.getInternalMaxPower();
}
return 0;
}
else
{
if( this.getInternalCurrentPower() < 0.01 && amt > 0.01 )
{
this.PowerEvent( PowerEventType.PROVIDE_POWER );
}
this.setInternalCurrentPower( this.getInternalCurrentPower() + amt );
if( this.getInternalCurrentPower() > this.getInternalMaxPower() )
{
amt = this.getInternalCurrentPower() - this.getInternalMaxPower();
this.setInternalCurrentPower( this.getInternalMaxPower() );
return amt;
}
return 0;
}
}
protected void PowerEvent( final PowerEventType x )
{
// nothing.
}
@Override
public final double getAEMaxPower()
{
return this.getInternalMaxPower();
}
@Override
public final double getAECurrentPower()
{
return this.getInternalCurrentPower();
}
@Override
public final boolean isAEPublicPowerStorage()
{
return this.isInternalPublicPowerStorage();
}
@Override
public final AccessRestriction getPowerFlow()
{
return this.getInternalPowerFlow();
}
@Override
public final double extractAEPower( final double amt, final Actionable mode, final PowerMultiplier multiplier )
{
return multiplier.divide( this.extractAEPower( multiplier.multiply( amt ), mode ) );
}
protected double extractAEPower( double amt, final Actionable mode )
{
if( mode == Actionable.SIMULATE )
{
if( this.getInternalCurrentPower() > amt )
{
return amt;
}
return this.getInternalCurrentPower();
}
final boolean wasFull = this.getInternalCurrentPower() >= this.getInternalMaxPower() - 0.001;
if( wasFull && amt > 0.001 )
{
this.PowerEvent( PowerEventType.REQUEST_POWER );
}
if( this.getInternalCurrentPower() > amt )
{
this.setInternalCurrentPower( this.getInternalCurrentPower() - amt );
return amt;
}
amt = this.getInternalCurrentPower();
this.setInternalCurrentPower( 0 );
return amt;
}
public double getInternalCurrentPower()
{
return this.internalCurrentPower;
}
public void setInternalCurrentPower( final double internalCurrentPower )
{
this.internalCurrentPower = internalCurrentPower;
}
public double getInternalMaxPower()
{
return this.internalMaxPower;
}
public void setInternalMaxPower( final double internalMaxPower )
{
this.internalMaxPower = internalMaxPower;
}
private boolean isInternalPublicPowerStorage()
{
return this.internalPublicPowerStorage;
}
public void setInternalPublicPowerStorage( final boolean internalPublicPowerStorage )
{
this.internalPublicPowerStorage = internalPublicPowerStorage;
}
private AccessRestriction getInternalPowerFlow()
{
return this.internalPowerFlow;
}
public void setInternalPowerFlow( final AccessRestriction internalPowerFlow )
{
this.internalPowerFlow = internalPowerFlow;
}
@Override
public void onReady()
{
super.onReady();
this.ic2Sink.onLoad();
}
@Override
public void onChunkUnload()
{
super.onChunkUnload();
this.ic2Sink.onChunkUnload();
}
@Override
public void invalidate()
{
super.invalidate();
this.ic2Sink.invalidate();
}
@Override
public boolean hasCapability( Capability<?> capability, EnumFacing facing )
{
if( capability == Capabilities.FORGE_ENERGY )
{
if( this.getPowerSides().contains( facing ) )
{
return true;
}
}
else if( capability == Capabilities.TESLA_CONSUMER )
{
if( this.getPowerSides().contains( facing ) )
{
return true;
}
}
return super.hasCapability( capability, facing );
}
@SuppressWarnings( "unchecked" )
@Override
public <T> T getCapability( Capability<T> capability, @Nullable EnumFacing facing )
{
if( capability == Capabilities.FORGE_ENERGY )
{
if( this.getPowerSides().contains( facing ) )
{
return (T) this.forgeEnergyAdapter;
}
}
else if( capability == Capabilities.TESLA_CONSUMER )
{
if( this.getPowerSides().contains( facing ) )
{
return (T) this.teslaEnergyAdapter;
}
}
return super.getCapability( capability, facing );
}
}

View file

@ -1,326 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.tile.powersink;
import java.util.EnumSet;
import javax.annotation.Nullable;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.energy.IEnergyStorage;
import appeng.api.config.AccessRestriction;
import appeng.api.config.Actionable;
import appeng.api.config.PowerMultiplier;
import appeng.api.config.PowerUnits;
import appeng.api.networking.energy.IAEPowerStorage;
import appeng.api.networking.events.MENetworkPowerStorage.PowerEventType;
import appeng.capabilities.Capabilities;
import appeng.integration.Integrations;
import appeng.integration.abstraction.IC2PowerSink;
import appeng.tile.AEBaseInvTile;
import appeng.tile.TileEvent;
import appeng.tile.events.TileEventType;
public abstract class AERootPoweredTile extends AEBaseInvTile implements IAEPowerStorage, IExternalPowerSink
{
// values that determine general function, are set by inheriting classes if
// needed. These should generally remain static.
private double internalMaxPower = 10000;
private boolean internalPublicPowerStorage = false;
private AccessRestriction internalPowerFlow = AccessRestriction.READ_WRITE;
// the current power buffer.
private double internalCurrentPower = 0;
private EnumSet<EnumFacing> internalPowerSides = EnumSet.allOf( EnumFacing.class );
private final IEnergyStorage forgeEnergyAdapter;
private Object teslaEnergyAdapter;
private IC2PowerSink ic2Sink;
public AERootPoweredTile()
{
this.forgeEnergyAdapter = new ForgeEnergyAdapter( this );
if( Capabilities.TESLA_CONSUMER != null )
{
this.teslaEnergyAdapter = new TeslaEnergyAdapter( this );
}
this.ic2Sink = Integrations.ic2().createPowerSink( this, this );
this.ic2Sink.setValidFaces( this.internalPowerSides );
}
protected EnumSet<EnumFacing> getPowerSides()
{
return this.internalPowerSides.clone();
}
protected void setPowerSides( final EnumSet<EnumFacing> sides )
{
this.internalPowerSides = sides;
this.ic2Sink.setValidFaces( sides );
// trigger re-calc!
}
@TileEvent( TileEventType.WORLD_NBT_WRITE )
public void writeToNBT_AERootPoweredTile( final NBTTagCompound data )
{
data.setDouble( "internalCurrentPower", this.getInternalCurrentPower() );
}
@TileEvent( TileEventType.WORLD_NBT_READ )
public void readFromNBT_AERootPoweredTile( final NBTTagCompound data )
{
this.setInternalCurrentPower( data.getDouble( "internalCurrentPower" ) );
}
@Override
public final double getExternalPowerDemand( final PowerUnits externalUnit, final double maxPowerRequired )
{
return PowerUnits.AE.convertTo( externalUnit, Math.max( 0.0, this.getFunnelPowerDemand( externalUnit.convertTo( PowerUnits.AE, maxPowerRequired ) ) ) );
}
protected double getFunnelPowerDemand( final double maxRequired )
{
return this.getInternalMaxPower() - this.getInternalCurrentPower();
}
@Override
public final double injectExternalPower( final PowerUnits input, final double amt )
{
return PowerUnits.AE.convertTo( input, this.funnelPowerIntoStorage( input.convertTo( PowerUnits.AE, amt ), Actionable.MODULATE ) );
}
protected double funnelPowerIntoStorage( final double power, final Actionable mode )
{
return this.injectAEPower( power, mode );
}
@Override
public final double injectAEPower( double amt, final Actionable mode )
{
if( amt < 0.000001 )
{
return 0;
}
if( mode == Actionable.SIMULATE )
{
final double fakeBattery = this.getInternalCurrentPower() + amt;
if( fakeBattery > this.getInternalMaxPower() )
{
return fakeBattery - this.getInternalMaxPower();
}
return 0;
}
else
{
if( this.getInternalCurrentPower() < 0.01 && amt > 0.01 )
{
this.PowerEvent( PowerEventType.PROVIDE_POWER );
}
this.setInternalCurrentPower( this.getInternalCurrentPower() + amt );
if( this.getInternalCurrentPower() > this.getInternalMaxPower() )
{
amt = this.getInternalCurrentPower() - this.getInternalMaxPower();
this.setInternalCurrentPower( this.getInternalMaxPower() );
return amt;
}
return 0;
}
}
protected void PowerEvent( final PowerEventType x )
{
// nothing.
}
@Override
public final double getAEMaxPower()
{
return this.getInternalMaxPower();
}
@Override
public final double getAECurrentPower()
{
return this.getInternalCurrentPower();
}
@Override
public final boolean isAEPublicPowerStorage()
{
return this.isInternalPublicPowerStorage();
}
@Override
public final AccessRestriction getPowerFlow()
{
return this.getInternalPowerFlow();
}
@Override
public final double extractAEPower( final double amt, final Actionable mode, final PowerMultiplier multiplier )
{
return multiplier.divide( this.extractAEPower( multiplier.multiply( amt ), mode ) );
}
protected double extractAEPower( double amt, final Actionable mode )
{
if( mode == Actionable.SIMULATE )
{
if( this.getInternalCurrentPower() > amt )
{
return amt;
}
return this.getInternalCurrentPower();
}
final boolean wasFull = this.getInternalCurrentPower() >= this.getInternalMaxPower() - 0.001;
if( wasFull && amt > 0.001 )
{
this.PowerEvent( PowerEventType.REQUEST_POWER );
}
if( this.getInternalCurrentPower() > amt )
{
this.setInternalCurrentPower( this.getInternalCurrentPower() - amt );
return amt;
}
amt = this.getInternalCurrentPower();
this.setInternalCurrentPower( 0 );
return amt;
}
public double getInternalCurrentPower()
{
return this.internalCurrentPower;
}
public void setInternalCurrentPower( final double internalCurrentPower )
{
this.internalCurrentPower = internalCurrentPower;
}
public double getInternalMaxPower()
{
return this.internalMaxPower;
}
public void setInternalMaxPower( final double internalMaxPower )
{
this.internalMaxPower = internalMaxPower;
}
private boolean isInternalPublicPowerStorage()
{
return this.internalPublicPowerStorage;
}
public void setInternalPublicPowerStorage( final boolean internalPublicPowerStorage )
{
this.internalPublicPowerStorage = internalPublicPowerStorage;
}
private AccessRestriction getInternalPowerFlow()
{
return this.internalPowerFlow;
}
public void setInternalPowerFlow( final AccessRestriction internalPowerFlow )
{
this.internalPowerFlow = internalPowerFlow;
}
@Override
public void onReady()
{
super.onReady();
this.ic2Sink.onLoad();
}
@Override
public void onChunkUnload()
{
super.onChunkUnload();
this.ic2Sink.onChunkUnload();
}
@Override
public void invalidate()
{
super.invalidate();
this.ic2Sink.invalidate();
}
@Override
public boolean hasCapability( Capability<?> capability, EnumFacing facing )
{
if( capability == Capabilities.FORGE_ENERGY )
{
if( this.getPowerSides().contains( facing ) )
{
return true;
}
}
else if( capability == Capabilities.TESLA_CONSUMER )
{
if( this.getPowerSides().contains( facing ) )
{
return true;
}
}
return super.hasCapability( capability, facing );
}
@SuppressWarnings( "unchecked" )
@Override
public <T> T getCapability( Capability<T> capability, @Nullable EnumFacing facing )
{
if( capability == Capabilities.FORGE_ENERGY )
{
if( this.getPowerSides().contains( facing ) )
{
return (T) this.forgeEnergyAdapter;
}
}
else if( capability == Capabilities.TESLA_CONSUMER )
{
if( this.getPowerSides().contains( facing ) )
{
return (T) this.teslaEnergyAdapter;
}
}
return super.getCapability( capability, facing );
}
}

View file

@ -1,65 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.tile.powersink;
import net.minecraft.util.EnumFacing;
import cofh.redstoneflux.api.IEnergyReceiver;
import appeng.api.config.PowerUnits;
import appeng.coremod.annotations.Integration.Interface;
import appeng.integration.IntegrationType;
@Interface( iname = IntegrationType.RF, iface = "cofh.redstoneflux.api.IEnergyReceiver" )
public abstract class RedstoneFlux extends AERootPoweredTile implements IEnergyReceiver
{
@Override
public final int receiveEnergy( final EnumFacing from, final int maxReceive, final 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( final EnumFacing from )
{
return (int) Math.floor( PowerUnits.AE.convertTo( PowerUnits.RF, this.getAECurrentPower() ) );
}
@Override
public final int getMaxEnergyStored( final EnumFacing from )
{
return (int) Math.floor( PowerUnits.AE.convertTo( PowerUnits.RF, this.getAEMaxPower() ) );
}
@Override
public final boolean canConnectEnergy( final EnumFacing from )
{
return this.getPowerSides().contains( from );
}
}

View file

@ -73,7 +73,6 @@ gui.appliedenergistics2.FluidTunnel=Tekutina
gui.appliedenergistics2.RedstoneTunnel=Rudit
gui.appliedenergistics2.EUTunnel=EU
gui.appliedenergistics2.FETunnel=FE
gui.appliedenergistics2.RFTunnel=RF
gui.appliedenergistics2.LightTunnel=Světlo
gui.appliedenergistics2.security.extract.name=Vybrat

View file

@ -100,7 +100,6 @@ gui.appliedenergistics2.FluidTunnel=Flüssigkeiten
gui.appliedenergistics2.RedstoneTunnel=Redstone
gui.appliedenergistics2.EUTunnel=EU
gui.appliedenergistics2.FETunnel=FE
gui.appliedenergistics2.RFTunnel=RF
gui.appliedenergistics2.LightTunnel=Licht
gui.appliedenergistics2.OCTunnel=OpenComputers
gui.appliedenergistics2.PressureTunnel=Druck

View file

@ -100,7 +100,6 @@ gui.appliedenergistics2.FluidTunnel=Fluid
gui.appliedenergistics2.RedstoneTunnel=Redstone
gui.appliedenergistics2.EUTunnel=EU
gui.appliedenergistics2.FETunnel=FE
gui.appliedenergistics2.RFTunnel=RF
gui.appliedenergistics2.LightTunnel=Light
gui.appliedenergistics2.OCTunnel=OpenComputers
gui.appliedenergistics2.PressureTunnel=Pressure

View file

@ -73,7 +73,6 @@ gui.appliedenergistics2.FluidTunnel=Fluidos
gui.appliedenergistics2.RedstoneTunnel=Redstone
gui.appliedenergistics2.EUTunnel=EU
gui.appliedenergistics2.FETunnel=FE
gui.appliedenergistics2.RFTunnel=RF
gui.appliedenergistics2.LightTunnel=Luz
gui.appliedenergistics2.security.extract.name=Retirar

View file

@ -100,7 +100,6 @@ gui.appliedenergistics2.FluidTunnel=Fluide
gui.appliedenergistics2.RedstoneTunnel=Redstone
gui.appliedenergistics2.EUTunnel=EU
gui.appliedenergistics2.FETunnel=FE
gui.appliedenergistics2.RFTunnel=RF
gui.appliedenergistics2.LightTunnel=Lumière
gui.appliedenergistics2.OCTunnel=OpenComputers
gui.appliedenergistics2.PressureTunnel=Pression

View file

@ -101,7 +101,6 @@ gui.appliedenergistics2.FluidTunnel=Folyadék Csatorna
gui.appliedenergistics2.RedstoneTunnel=Vöröskő Csatorna
gui.appliedenergistics2.EUTunnel=EU Csatorna
gui.appliedenergistics2.FETunnel=FE Csatorna
gui.appliedenergistics2.RFTunnel=RF Csatorna
gui.appliedenergistics2.LightTunnel=Fény Csatorna
gui.appliedenergistics2.OCTunnel=OpenComputers
gui.appliedenergistics2.PressureTunnel=Nyomás

View file

@ -90,7 +90,6 @@ gui.appliedenergistics2.FluidTunnel=Fluido
gui.appliedenergistics2.RedstoneTunnel=Pietrarossa
gui.appliedenergistics2.EUTunnel=EU
gui.appliedenergistics2.FETunnel=FE
gui.appliedenergistics2.RFTunnel=RF
gui.appliedenergistics2.LightTunnel=Luce
gui.appliedenergistics2.security.extract.name=Estrai

View file

@ -83,7 +83,6 @@ gui.appliedenergistics2.FluidTunnel=액체
gui.appliedenergistics2.RedstoneTunnel=레드스톤
gui.appliedenergistics2.EUTunnel=EU
gui.appliedenergistics2.FETunnel=FE
gui.appliedenergistics2.RFTunnel=RF
gui.appliedenergistics2.LightTunnel=빛
gui.appliedenergistics2.security.extract.name=Withdraw

View file

@ -100,7 +100,6 @@ gui.appliedenergistics2.FluidTunnel=Fluido
gui.appliedenergistics2.RedstoneTunnel=Redstone
gui.appliedenergistics2.EUTunnel=EU
gui.appliedenergistics2.FETunnel=FE
gui.appliedenergistics2.RFTunnel=RF
gui.appliedenergistics2.LightTunnel=Luz
gui.appliedenergistics2.OCTunnel=OpenComputers
gui.appliedenergistics2.PressureTunnel=Pressão

View file

@ -100,7 +100,6 @@ gui.appliedenergistics2.FluidTunnel=Жидкость
gui.appliedenergistics2.RedstoneTunnel=Красный камень
gui.appliedenergistics2.EUTunnel=EU
gui.appliedenergistics2.FETunnel=FE
gui.appliedenergistics2.RFTunnel=RF
gui.appliedenergistics2.LightTunnel=Свет
gui.appliedenergistics2.OCTunnel=OpenComputers
gui.appliedenergistics2.PressureTunnel=Давление

View file

@ -100,7 +100,6 @@ gui.appliedenergistics2.FluidTunnel=液体
gui.appliedenergistics2.RedstoneTunnel=红石
gui.appliedenergistics2.EUTunnel=EU
gui.appliedenergistics2.FETunnel=FE
gui.appliedenergistics2.RFTunnel=RF
gui.appliedenergistics2.LightTunnel=光
gui.appliedenergistics2.OCTunnel=OpenComputers
gui.appliedenergistics2.PressureTunnel=气压

View file

@ -73,7 +73,6 @@ gui.appliedenergistics2.FluidTunnel=液體
gui.appliedenergistics2.RedstoneTunnel=紅石
gui.appliedenergistics2.EUTunnel=EU
gui.appliedenergistics2.FETunnel=FE
gui.appliedenergistics2.RFTunnel=RF
gui.appliedenergistics2.LightTunnel=光
gui.appliedenergistics2.security.extract.name=取出

View file

@ -1,6 +0,0 @@
{
"parent": "appliedenergistics2:item/part/p2p_tunnel",
"textures": {
"type": "minecraft:blocks/iron_block"
}
}

View file

@ -1,6 +0,0 @@
{
"parent": "appliedenergistics2:part/p2p/p2p_tunnel_base",
"textures": {
"type": "minecraft:blocks/iron_block"
}
}

View file

@ -1,56 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.coremod;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
public class AppEngCoreTest
{
private final static String EXPECTED_CONTAINER_CLASS_NAME = appeng.coremod.AppEngCore.class.getName();
private final static String EXPECTED_CONTAINER_MOD_ID = "appliedenergistics2-core";
private final static String[] EXPECTED_TRANSFORMERS = new String[] {
appeng.coremod.transformer.ASMIntegration.class.getName()
};
private AppEngCore coreModContainer = new AppEngCore();
@Test
public void testTransformerStringsMatchActualClasses()
{
assertArrayEquals( EXPECTED_TRANSFORMERS, this.coreModContainer.getASMTransformerClass() );
}
@Test
public void testContainerClassExists()
{
assertEquals( EXPECTED_CONTAINER_CLASS_NAME, this.coreModContainer.getModContainerClass() );
}
@Test
public void testContainerModId()
{
assertEquals( EXPECTED_CONTAINER_MOD_ID, this.coreModContainer.getModId() );
}
}