Fixes #675 No disabled feature should log spam or crash anymore.
Deprecates the old usage of the AEItemDefinitions via the direct method access of * blocks() * parts() * items() * materials() and thus use the new re-direct via definitions(). All definitions are now initialized, no matter what. But SubItems, Items and Blocks are not registered, if by chance are disabled.
This commit is contained in:
@@ -18,7 +18,8 @@
|
||||
|
||||
package appeng.integration.modules;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
@@ -36,9 +37,11 @@ import codechicken.multipart.MultiPartRegistry.IPartFactory;
|
||||
import codechicken.multipart.MultipartGenerator;
|
||||
import codechicken.multipart.TMultiPart;
|
||||
import codechicken.multipart.TileMultipart;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.definitions.Blocks;
|
||||
import appeng.api.definitions.IBlockDefinition;
|
||||
import appeng.api.definitions.IBlocks;
|
||||
import appeng.api.parts.IPartHost;
|
||||
import appeng.core.AELog;
|
||||
import appeng.fmp.CableBusPart;
|
||||
@@ -86,13 +89,15 @@ public class FMP implements IIntegrationModule, IPartFactory, IPartConverter, IF
|
||||
@Override
|
||||
public void init() throws Throwable
|
||||
{
|
||||
this.createAndRegister( AEApi.instance().blocks().blockQuartz.block(), 0 );
|
||||
this.createAndRegister( AEApi.instance().blocks().blockQuartzPillar.block(), 0 );
|
||||
this.createAndRegister( AEApi.instance().blocks().blockQuartzChiseled.block(), 0 );
|
||||
this.createAndRegister( AEApi.instance().blocks().blockSkyStone.block(), 0 );
|
||||
this.createAndRegister( AEApi.instance().blocks().blockSkyStone.block(), 1 );
|
||||
this.createAndRegister( AEApi.instance().blocks().blockSkyStone.block(), 2 );
|
||||
this.createAndRegister( AEApi.instance().blocks().blockSkyStone.block(), 3 );
|
||||
final IBlocks blocks = AEApi.instance().definitions().blocks();
|
||||
|
||||
this.createAndRegister( blocks.quartz(), 0 );
|
||||
this.createAndRegister( blocks.quartzPillar(), 0 );
|
||||
this.createAndRegister( blocks.quartzChiseled(), 0 );
|
||||
this.createAndRegister( blocks.skyStone(), 0 );
|
||||
this.createAndRegister( blocks.skyStone(), 1 );
|
||||
this.createAndRegister( blocks.skyStone(), 2 );
|
||||
this.createAndRegister( blocks.skyStone(), 3 );
|
||||
|
||||
PartRegistry[] reg = PartRegistry.values();
|
||||
|
||||
@@ -106,10 +111,12 @@ public class FMP implements IIntegrationModule, IPartFactory, IPartConverter, IF
|
||||
MultipartGenerator.registerPassThroughInterface( "appeng.helpers.AEMultiTile" );
|
||||
}
|
||||
|
||||
private void createAndRegister(Block block, int i)
|
||||
private void createAndRegister(IBlockDefinition definition, int i)
|
||||
{
|
||||
if ( block != null )
|
||||
for ( Block block : definition.maybeBlock().asSet() )
|
||||
{
|
||||
BlockMicroMaterial.createAndRegister( block, i );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -186,8 +193,20 @@ public class FMP implements IIntegrationModule, IPartFactory, IPartConverter, IF
|
||||
@Override
|
||||
public Iterable<Block> blockTypes()
|
||||
{
|
||||
Blocks def = AEApi.instance().blocks();
|
||||
return Arrays.asList( def.blockMultiPart.block(), def.blockQuartzTorch.block() );
|
||||
final IBlocks blocks = AEApi.instance().definitions().blocks();
|
||||
final List<Block> blockTypes = Lists.newArrayListWithCapacity( 2 );
|
||||
|
||||
this.addBlockTypes( blockTypes, blocks.multiPart() );
|
||||
this.addBlockTypes( blockTypes, blocks.quartzTorch() );
|
||||
|
||||
return blockTypes;
|
||||
}
|
||||
|
||||
private void addBlockTypes( Collection<Block> blockTypes, IBlockDefinition definition )
|
||||
{
|
||||
for ( Block block : definition.maybeBlock().asSet() )
|
||||
{
|
||||
blockTypes.add( block );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user