Splitted coremod into a container and loading plugin.

This commit is contained in:
yueh 2017-07-23 15:37:39 +02:00
parent e3bf52ff7b
commit f44cddf8d5
6 changed files with 85 additions and 65 deletions

View File

@ -68,7 +68,7 @@ jar {
}
minecraft {
coreMod = "appeng.coremod.AppEngCore"
coreMod = "appeng.coremod.AppEngLoadingPlugin"
version = minecraft_version + "-" + forge_version

View File

@ -19,10 +19,6 @@
package appeng.coremod;
import java.util.Map;
import javax.annotation.Nullable;
import com.google.common.eventbus.EventBus;
import net.minecraftforge.fml.common.DummyModContainer;
@ -31,18 +27,15 @@ 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.FMLRelaunchLog;
import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin;
import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin.MCVersion;
import appeng.core.AEConfig;
@MCVersion( "1.10.2" )
public final class AppEngCore extends DummyModContainer implements IFMLLoadingPlugin
public final class AppEngCoreContainer extends DummyModContainer
{
private final ModMetadata metadata = new ModMetadata();
public AppEngCore()
public AppEngCoreContainer()
{
FMLRelaunchLog.info( "[AppEng] Core Init" );
this.metadata.autogenerated = false;
@ -61,37 +54,6 @@ public final class AppEngCore extends DummyModContainer implements IFMLLoadingPl
{
}
@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()
{

View File

@ -0,0 +1,64 @@
/*
* 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 net.minecraftforge.fml.relauncher.IFMLLoadingPlugin;
@IFMLLoadingPlugin.MCVersion( "1.10.2" )
@IFMLLoadingPlugin.TransformerExclusions( { "appeng.coremod." } )
public class AppEngLoadingPlugin implements IFMLLoadingPlugin
{
@Override
public String[] getASMTransformerClass()
{
return new String[] { "appeng.coremod.transformer.IntegrationTransformer" };
}
@Override
public String getModContainerClass()
{
return "appeng.coremod.AppEngCoreContainer";
}
@Nullable
@Override
public String getSetupClass()
{
return null;
}
@Override
public void injectData( final Map<String, Object> data )
{
}
@Override
public String getAccessTransformerClass()
{
return null;
}
}

View File

@ -68,7 +68,7 @@ public final class MissingCoreMod extends CustomModLoadingErrorDisplayException
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 );
this.drawCenteredString( fontRenderer, "-Dfml.coreMods.load=appeng.coremod.AppEngCoreContainer", errorScreen.width / 2, offset, SHADOW_WHITE );
}
else
{

View File

@ -41,37 +41,22 @@ import appeng.integration.IntegrationType;
@Reflected
public final class ASMIntegration implements IClassTransformer
public final class IntegrationTransformer implements IClassTransformer
{
@Reflected
public ASMIntegration()
public IntegrationTransformer()
{
/**
* 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" ) )
if( basicClass == null )
{
return basicClass;
}

View File

@ -22,29 +22,38 @@ package appeng.coremod;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import org.junit.Before;
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_CLASS_NAME = appeng.coremod.AppEngCoreContainer.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()
appeng.coremod.transformer.IntegrationTransformer.class.getName()
};
private AppEngCore coreModContainer = new AppEngCore();
private AppEngCoreContainer coreModContainer;
private AppEngLoadingPlugin loadingPlugin;
@Before
public void setup()
{
this.coreModContainer = new AppEngCoreContainer();
this.loadingPlugin = new AppEngLoadingPlugin();
}
@Test
public void testTransformerStringsMatchActualClasses()
{
assertArrayEquals( EXPECTED_TRANSFORMERS, coreModContainer.getASMTransformerClass() );
assertArrayEquals( EXPECTED_TRANSFORMERS, loadingPlugin.getASMTransformerClass() );
}
@Test
public void testContainerClassExists()
{
assertEquals( EXPECTED_CONTAINER_CLASS_NAME, coreModContainer.getModContainerClass() );
assertEquals( EXPECTED_CONTAINER_CLASS_NAME, loadingPlugin.getModContainerClass() );
}
@Test