Added skystone, skystone block, skystone brick, skystone small brick, certus quartz, certus quartz pillar, chiseled certus quartz and fluix stars
To integrate these into the current system, some changes to the background had to be done, especially to the feature handler. It now uses an interface to work against which you can implement to get your own feature handler instead modifying the base one and add several special cases code
This commit is contained in:
@@ -18,9 +18,13 @@
|
||||
|
||||
package appeng.core;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.util.WeightedRandomChestContent;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
@@ -29,6 +33,14 @@ import net.minecraftforge.common.DimensionManager;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.oredict.RecipeSorter;
|
||||
import net.minecraftforge.oredict.RecipeSorter.Category;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.common.registry.VillagerRegistry;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.definitions.Blocks;
|
||||
@@ -90,6 +102,14 @@ import appeng.block.solids.OreQuartzCharged;
|
||||
import appeng.block.spatial.BlockMatrixFrame;
|
||||
import appeng.block.spatial.BlockSpatialIOPort;
|
||||
import appeng.block.spatial.BlockSpatialPylon;
|
||||
import appeng.block.stair.ChiseledQuartzStairBlock;
|
||||
import appeng.block.stair.FluixStairBlock;
|
||||
import appeng.block.stair.QuartzPillarStairBlock;
|
||||
import appeng.block.stair.QuartzStairBlock;
|
||||
import appeng.block.stair.SkyStoneBlockStairBlock;
|
||||
import appeng.block.stair.SkyStoneBrickStairBlock;
|
||||
import appeng.block.stair.SkyStoneSmallBrickStairBlock;
|
||||
import appeng.block.stair.SkyStoneStairBlock;
|
||||
import appeng.block.storage.BlockChest;
|
||||
import appeng.block.storage.BlockDrive;
|
||||
import appeng.block.storage.BlockIOPort;
|
||||
@@ -184,17 +204,9 @@ import appeng.recipes.ores.OreDictionaryHandler;
|
||||
import appeng.spatial.BiomeGenStorage;
|
||||
import appeng.spatial.StorageWorldProvider;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.util.ClassInstantiation;
|
||||
import appeng.util.Platform;
|
||||
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.common.registry.VillagerRegistry;
|
||||
|
||||
public class Registration
|
||||
{
|
||||
@@ -202,6 +214,7 @@ public class Registration
|
||||
final public static Registration instance = new Registration();
|
||||
|
||||
public final RecipeHandler recipeHandler;
|
||||
final private Multimap<AEFeature, Class> featuresToEntities = ArrayListMultimap.create();
|
||||
public BiomeGenBase storageBiome;
|
||||
|
||||
private Registration()
|
||||
@@ -209,9 +222,7 @@ public class Registration
|
||||
recipeHandler = new RecipeHandler();
|
||||
}
|
||||
|
||||
final private Multimap<AEFeature, Class> featuresToEntities = ArrayListMultimap.create();
|
||||
|
||||
public void PreInit(FMLPreInitializationEvent event)
|
||||
public void PreInit( FMLPreInitializationEvent event )
|
||||
{
|
||||
registerSpatial( false );
|
||||
|
||||
@@ -248,23 +259,23 @@ public class Registration
|
||||
AEItemDefinition materialItem = addFeature( ItemMultiMaterial.class );
|
||||
|
||||
Class materialClass = materials.getClass();
|
||||
for (MaterialType mat : MaterialType.values())
|
||||
for ( MaterialType mat : MaterialType.values() )
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( mat == MaterialType.InvalidType )
|
||||
((ItemMultiMaterial) materialItem.item()).createMaterial( mat );
|
||||
( ( ItemMultiMaterial ) materialItem.item() ).createMaterial( mat );
|
||||
else
|
||||
{
|
||||
Field f = materialClass.getField( "material" + mat.name() );
|
||||
IStackSrc is = ((ItemMultiMaterial) materialItem.item()).createMaterial( mat );
|
||||
IStackSrc is = ( ( ItemMultiMaterial ) materialItem.item() ).createMaterial( mat );
|
||||
if ( is != null )
|
||||
f.set( materials, new DamagedItemDefinition( is ) );
|
||||
else
|
||||
f.set( materials, new NullItemDefinition() );
|
||||
}
|
||||
}
|
||||
catch (Throwable err)
|
||||
catch ( Throwable err )
|
||||
{
|
||||
AELog.severe( "Error creating material: " + mat.name() );
|
||||
throw new RuntimeException( err );
|
||||
@@ -274,19 +285,19 @@ public class Registration
|
||||
AEItemDefinition partItem = addFeature( ItemMultiPart.class );
|
||||
|
||||
Class partClass = parts.getClass();
|
||||
for (PartType type : PartType.values())
|
||||
for ( PartType type : PartType.values() )
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( type == PartType.InvalidType )
|
||||
((ItemMultiPart) partItem.item()).createPart( type, null );
|
||||
( ( ItemMultiPart ) partItem.item() ).createPart( type, null );
|
||||
else
|
||||
{
|
||||
Field f = partClass.getField( "part" + type.name() );
|
||||
Enum variants[] = type.getVariants();
|
||||
if ( variants == null )
|
||||
{
|
||||
ItemStackSrc is = ((ItemMultiPart) partItem.item()).createPart( type, null );
|
||||
ItemStackSrc is = ( ( ItemMultiPart ) partItem.item() ).createPart( type, null );
|
||||
if ( is != null )
|
||||
f.set( parts, new DamagedItemDefinition( is ) );
|
||||
else
|
||||
@@ -298,11 +309,11 @@ public class Registration
|
||||
{
|
||||
ColoredItemDefinition def = new ColoredItemDefinition();
|
||||
|
||||
for (Enum v : variants)
|
||||
for ( Enum v : variants )
|
||||
{
|
||||
ItemStackSrc is = ((ItemMultiPart) partItem.item()).createPart( type, v );
|
||||
ItemStackSrc is = ( ( ItemMultiPart ) partItem.item() ).createPart( type, v );
|
||||
if ( is != null )
|
||||
def.add( (AEColor) v, is );
|
||||
def.add( ( AEColor ) v, is );
|
||||
}
|
||||
|
||||
f.set( parts, def );
|
||||
@@ -310,7 +321,7 @@ public class Registration
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Throwable err)
|
||||
catch ( Throwable err )
|
||||
{
|
||||
AELog.severe( "Error creating part: " + type.name() );
|
||||
throw new RuntimeException( err );
|
||||
@@ -424,7 +435,7 @@ public class Registration
|
||||
items.itemLumenPaintBall = lumenPaintBall = new ColoredItemDefinition();
|
||||
AEItemDefinition pb = addFeature( ItemPaintBall.class );
|
||||
|
||||
for (AEColor c : AEColor.values())
|
||||
for ( AEColor c : AEColor.values() )
|
||||
{
|
||||
if ( c != AEColor.Transparent )
|
||||
{
|
||||
@@ -433,6 +444,17 @@ public class Registration
|
||||
}
|
||||
}
|
||||
|
||||
// stairs
|
||||
this.addFeature( SkyStoneStairBlock.class, blocks.blockSkyStone.block(), 0 );
|
||||
this.addFeature( SkyStoneBlockStairBlock.class, blocks.blockSkyStone.block(), 1 );
|
||||
this.addFeature( SkyStoneBrickStairBlock.class, blocks.blockSkyStone.block(), 2 );
|
||||
this.addFeature( SkyStoneSmallBrickStairBlock.class, blocks.blockSkyStone.block(), 3 );
|
||||
this.addFeature( FluixStairBlock.class, blocks.blockFluix.block() );
|
||||
this.addFeature( QuartzStairBlock.class, blocks.blockQuartz.block() );
|
||||
this.addFeature( ChiseledQuartzStairBlock.class, blocks.blockQuartzChiseled.block() );
|
||||
this.addFeature( QuartzPillarStairBlock.class, blocks.blockQuartzPillar.block() );
|
||||
|
||||
// unsupported developer tools
|
||||
addFeature( ToolEraser.class );
|
||||
addFeature( ToolMeteoritePlacer.class );
|
||||
addFeature( ToolDebugCard.class );
|
||||
@@ -443,96 +465,71 @@ public class Registration
|
||||
addFeature( BlockCubeGenerator.class );
|
||||
}
|
||||
|
||||
private AEItemDefinition addFeature(Class c, Object... Args)
|
||||
private void registerSpatial( boolean force )
|
||||
{
|
||||
if ( !AEConfig.instance.isFeatureEnabled( AEFeature.SpatialIO ) )
|
||||
return;
|
||||
|
||||
try
|
||||
AEConfig config = AEConfig.instance;
|
||||
|
||||
if ( storageBiome == null )
|
||||
{
|
||||
java.lang.reflect.Constructor[] con = c.getConstructors();
|
||||
Object obj = null;
|
||||
|
||||
for (Constructor conItem : con)
|
||||
if ( force && config.storageBiomeID == -1 )
|
||||
{
|
||||
Class paramTypes[] = conItem.getParameterTypes();
|
||||
if ( paramTypes.length == Args.length )
|
||||
{
|
||||
boolean valid = true;
|
||||
config.storageBiomeID = Platform.findEmpty( BiomeGenBase.getBiomeGenArray() );
|
||||
if ( config.storageBiomeID == -1 )
|
||||
throw new RuntimeException( "Biome Array is full, please free up some Biome ID's or disable spatial." );
|
||||
|
||||
for (int idx = 0; idx < paramTypes.length; idx++)
|
||||
{
|
||||
Class cz = Args[idx].getClass();
|
||||
if ( !isClassMatch( paramTypes[idx], cz, Args[idx] ) )
|
||||
valid = false;
|
||||
}
|
||||
|
||||
if ( valid )
|
||||
{
|
||||
obj = conItem.newInstance( Args );
|
||||
break;
|
||||
}
|
||||
}
|
||||
storageBiome = new BiomeGenStorage( config.storageBiomeID );
|
||||
config.save();
|
||||
}
|
||||
|
||||
if ( obj instanceof IAEFeature )
|
||||
{
|
||||
IAEFeature feature = (IAEFeature) obj;
|
||||
|
||||
for (AEFeature f : feature.feature().getFeatures())
|
||||
featuresToEntities.put( f, c );
|
||||
|
||||
feature.feature().register();
|
||||
|
||||
feature.postInit();
|
||||
|
||||
return feature.feature();
|
||||
}
|
||||
else if ( obj == null )
|
||||
throw new RuntimeException( "No valid constructor found." );
|
||||
else
|
||||
throw new RuntimeException( "Non AE Feature Registered" );
|
||||
|
||||
if ( !force && config.storageBiomeID != -1 )
|
||||
storageBiome = new BiomeGenStorage( config.storageBiomeID );
|
||||
}
|
||||
catch (Throwable e)
|
||||
|
||||
if ( config.storageProviderID != -1 )
|
||||
{
|
||||
throw new RuntimeException( "Error with Feature: " + c.getName(), e );
|
||||
DimensionManager.registerProviderType( config.storageProviderID, StorageWorldProvider.class, false );
|
||||
}
|
||||
|
||||
if ( config.storageProviderID == -1 && force )
|
||||
{
|
||||
config.storageProviderID = -11;
|
||||
|
||||
while ( !DimensionManager.registerProviderType( config.storageProviderID, StorageWorldProvider.class, false ) )
|
||||
config.storageProviderID--;
|
||||
|
||||
config.save();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isClassMatch(Class expected, Class got, Object value)
|
||||
private AEItemDefinition addFeature( Class<? extends IAEFeature> featureClass, Object... args )
|
||||
{
|
||||
if ( value == null && !expected.isPrimitive() )
|
||||
return true;
|
||||
ClassInstantiation<IAEFeature> instantiation = new ClassInstantiation<IAEFeature>( featureClass, args );
|
||||
Optional<IAEFeature> instance = instantiation.get();
|
||||
|
||||
expected = condense( expected, Boolean.class, Character.class, Byte.class, Short.class, Integer.class, Long.class, Float.class, Double.class );
|
||||
got = condense( got, Boolean.class, Character.class, Byte.class, Short.class, Integer.class, Long.class, Float.class, Double.class );
|
||||
|
||||
if ( expected == got || expected.isAssignableFrom( got ) )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private Class condense(Class expected, Class... wrappers)
|
||||
{
|
||||
if ( expected.isPrimitive() )
|
||||
if ( instance.isPresent() )
|
||||
{
|
||||
for (Class clz : wrappers)
|
||||
IAEFeature feature = instance.get();
|
||||
|
||||
for ( AEFeature f : feature.handler().getFeatures() )
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( expected == clz.getField( "TYPE" ).get( null ) )
|
||||
return clz;
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
AELog.error( t );
|
||||
}
|
||||
this.featuresToEntities.put( f, featureClass );
|
||||
}
|
||||
|
||||
feature.handler().register();
|
||||
feature.postInit();
|
||||
|
||||
return feature.handler().getDefinition();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new RuntimeException( "Error with Feature: " + featureClass.getName() );
|
||||
}
|
||||
return expected;
|
||||
}
|
||||
|
||||
public void Init(FMLInitializationEvent event)
|
||||
public void Init( FMLInitializationEvent event )
|
||||
{
|
||||
// Perform ore camouflage!
|
||||
ItemMultiMaterial.instance.makeUnique();
|
||||
@@ -600,19 +597,19 @@ public class Registration
|
||||
CraftingManager.getInstance().getRecipeList().add( new FacadeRecipe() );
|
||||
}
|
||||
|
||||
public void PostInit(FMLPostInitializationEvent event)
|
||||
public void PostInit( FMLPostInitializationEvent event )
|
||||
{
|
||||
registerSpatial( true );
|
||||
|
||||
// default settings..
|
||||
((P2PTunnelRegistry) AEApi.instance().registries().p2pTunnel()).configure();
|
||||
( ( P2PTunnelRegistry ) AEApi.instance().registries().p2pTunnel() ).configure();
|
||||
|
||||
// add to localization..
|
||||
PlayerMessages.values();
|
||||
GuiText.values();
|
||||
|
||||
Api.instance.partHelper.initFMPSupport();
|
||||
((BlockCableBus) AEApi.instance().blocks().blockMultiPart.block()).setupTile();
|
||||
( ( BlockCableBus ) AEApi.instance().blocks().blockMultiPart.block() ).setupTile();
|
||||
|
||||
// Interface
|
||||
Upgrades.CRAFTING.registerItem( AEApi.instance().parts().partInterface.stack( 1 ), 1 );
|
||||
@@ -679,7 +676,7 @@ public class Registration
|
||||
// Inscriber
|
||||
Upgrades.SPEED.registerItem( AEApi.instance().blocks().blockInscriber.stack( 1 ), 3 );
|
||||
|
||||
AEApi.instance().registries().wireless().registerWirelessHandler( (IWirelessTermHandler) AEApi.instance().items().itemWirelessTerminal.item() );
|
||||
AEApi.instance().registries().wireless().registerWirelessHandler( ( IWirelessTermHandler ) AEApi.instance().items().itemWirelessTerminal.item() );
|
||||
|
||||
if ( AEConfig.instance.isFeatureEnabled( AEFeature.ChestLoot ) )
|
||||
{
|
||||
@@ -738,19 +735,19 @@ public class Registration
|
||||
/**
|
||||
* world gen
|
||||
*/
|
||||
for (WorldGenType type : WorldGenType.values())
|
||||
for ( WorldGenType type : WorldGenType.values() )
|
||||
{
|
||||
AEApi.instance().registries().worldgen().disableWorldGenForProviderID( type, StorageWorldProvider.class );
|
||||
|
||||
//nether
|
||||
// nether
|
||||
AEApi.instance().registries().worldgen().disableWorldGenForDimension( type, -1 );
|
||||
|
||||
//end
|
||||
// end
|
||||
AEApi.instance().registries().worldgen().disableWorldGenForDimension( type, 1 );
|
||||
}
|
||||
|
||||
//whitelist from config
|
||||
for(int dimension : AEConfig.instance.meteoriteDimensionWhitelist)
|
||||
// whitelist from config
|
||||
for ( int dimension : AEConfig.instance.meteoriteDimensionWhitelist )
|
||||
{
|
||||
AEApi.instance().registries().worldgen().enableWorldGenForDimension( WorldGenType.Meteorites, dimension );
|
||||
}
|
||||
@@ -761,43 +758,4 @@ public class Registration
|
||||
OreDictionaryHandler.instance.bakeRecipes();
|
||||
}
|
||||
|
||||
private void registerSpatial(boolean force)
|
||||
{
|
||||
if ( !AEConfig.instance.isFeatureEnabled( AEFeature.SpatialIO ) )
|
||||
return;
|
||||
|
||||
AEConfig config = AEConfig.instance;
|
||||
|
||||
if ( storageBiome == null )
|
||||
{
|
||||
if ( force && config.storageBiomeID == -1 )
|
||||
{
|
||||
config.storageBiomeID = Platform.findEmpty( BiomeGenBase.getBiomeGenArray() );
|
||||
if ( config.storageBiomeID == -1 )
|
||||
throw new RuntimeException( "Biome Array is full, please free up some Biome ID's or disable spatial." );
|
||||
|
||||
storageBiome = new BiomeGenStorage( config.storageBiomeID );
|
||||
config.save();
|
||||
}
|
||||
|
||||
if ( !force && config.storageBiomeID != -1 )
|
||||
storageBiome = new BiomeGenStorage( config.storageBiomeID );
|
||||
}
|
||||
|
||||
if ( config.storageProviderID != -1 )
|
||||
{
|
||||
DimensionManager.registerProviderType( config.storageProviderID, StorageWorldProvider.class, false );
|
||||
}
|
||||
|
||||
if ( config.storageProviderID == -1 && force )
|
||||
{
|
||||
config.storageProviderID = -11;
|
||||
|
||||
while (!DimensionManager.registerProviderType( config.storageProviderID, StorageWorldProvider.class, false ))
|
||||
config.storageProviderID--;
|
||||
|
||||
config.save();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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.core.features;
|
||||
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import appeng.block.AEBaseBlock;
|
||||
|
||||
|
||||
public class AEBlockDefinition extends BlockDefinition
|
||||
{
|
||||
private final AEBaseBlock block;
|
||||
|
||||
public AEBlockDefinition( AEBaseBlock block, boolean enabled )
|
||||
{
|
||||
super( block, enabled );
|
||||
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends TileEntity> entity()
|
||||
{
|
||||
return this.block.getTileEntityClass();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* 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.core.features;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
import appeng.api.util.AEItemDefinition;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.block.AEBaseItemBlock;
|
||||
import appeng.core.CommonHelper;
|
||||
import appeng.core.CreativeTab;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class AEBlockFeatureHandler implements IFeatureHandler
|
||||
{
|
||||
private final EnumSet<AEFeature> features;
|
||||
private final AEBaseBlock featured;
|
||||
private final FeatureNameExtractor extractor;
|
||||
private final boolean enabled;
|
||||
private final AEBlockDefinition definition;
|
||||
|
||||
public AEBlockFeatureHandler( EnumSet<AEFeature> features, AEBaseBlock featured, Optional<String> subName )
|
||||
{
|
||||
this.features = features;
|
||||
this.featured = featured;
|
||||
this.extractor = new FeatureNameExtractor( featured.getClass(), subName );
|
||||
this.enabled = new FeaturedActiveChecker( features ).get();
|
||||
this.definition = new AEBlockDefinition( featured, this.enabled );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFeatureAvailable()
|
||||
{
|
||||
return this.enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<AEFeature> getFeatures()
|
||||
{
|
||||
return this.features;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AEItemDefinition getDefinition()
|
||||
{
|
||||
return this.definition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register()
|
||||
{
|
||||
if ( this.enabled )
|
||||
{
|
||||
String name = this.extractor.get();
|
||||
this.featured.setCreativeTab( CreativeTab.instance );
|
||||
this.featured.setBlockName( /* "tile." */"appliedenergistics2." + name );
|
||||
this.featured.setBlockTextureName( "appliedenergistics2:" + name );
|
||||
|
||||
if ( Platform.isClient() )
|
||||
{
|
||||
CommonHelper.proxy.bindTileEntitySpecialRenderer( this.featured.getTileEntityClass(), this.featured );
|
||||
}
|
||||
|
||||
Class<? extends AEBaseItemBlock> itemBlockClass = this.featured.getItemBlockClass();
|
||||
|
||||
GameRegistry.registerBlock( this.featured, itemBlockClass, "tile." + name );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,13 +18,18 @@
|
||||
|
||||
package appeng.core.features;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockStairs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
import appeng.api.util.AEItemDefinition;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.block.AEBaseItemBlock;
|
||||
@@ -34,7 +39,7 @@ import appeng.core.CreativeTab;
|
||||
import appeng.core.CreativeTabFacade;
|
||||
import appeng.items.parts.ItemFacade;
|
||||
import appeng.util.Platform;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
|
||||
public class AEFeatureHandler implements AEItemDefinition
|
||||
{
|
||||
@@ -46,8 +51,10 @@ public class AEFeatureHandler implements AEItemDefinition
|
||||
|
||||
private Item ItemData;
|
||||
private Block BlockData;
|
||||
private BlockStairs stairData;
|
||||
|
||||
public AEFeatureHandler(EnumSet<AEFeature> features, IAEFeature feature, String subName) {
|
||||
public AEFeatureHandler( EnumSet<AEFeature> features, IAEFeature feature, String subName )
|
||||
{
|
||||
this.features = features;
|
||||
this.feature = feature;
|
||||
this.subName = subName;
|
||||
@@ -58,13 +65,86 @@ public class AEFeatureHandler implements AEItemDefinition
|
||||
if ( isFeatureAvailable() )
|
||||
{
|
||||
if ( feature instanceof Item )
|
||||
initItem( (Item) feature );
|
||||
if ( feature instanceof Block )
|
||||
initBlock( (Block) feature );
|
||||
{
|
||||
initItem( ( Item ) feature );
|
||||
}
|
||||
else if ( this.feature instanceof BlockStairs )
|
||||
{
|
||||
this.initStairBlock( ( BlockStairs ) this.feature );
|
||||
}
|
||||
else if ( feature instanceof Block )
|
||||
{
|
||||
initBlock( ( Block ) feature );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static String getName(Class o, String subName)
|
||||
public boolean isFeatureAvailable()
|
||||
{
|
||||
boolean enabled = true;
|
||||
|
||||
for ( AEFeature f : features )
|
||||
enabled = enabled && AEConfig.instance.isFeatureEnabled( f );
|
||||
|
||||
return enabled;
|
||||
}
|
||||
|
||||
private void initItem( Item i )
|
||||
{
|
||||
ItemData = i;
|
||||
|
||||
String name = getName( i.getClass(), subName );
|
||||
i.setTextureName( "appliedenergistics2:" + name );
|
||||
i.setUnlocalizedName( /* "item." */"appliedenergistics2." + name );
|
||||
|
||||
if ( i instanceof ItemFacade )
|
||||
i.setCreativeTab( CreativeTabFacade.instance );
|
||||
else
|
||||
i.setCreativeTab( CreativeTab.instance );
|
||||
|
||||
if ( name.equals( "ItemMaterial" ) )
|
||||
name = "ItemMultiMaterial";
|
||||
else if ( name.equals( "ItemPart" ) )
|
||||
name = "ItemMultiPart";
|
||||
|
||||
GameRegistry.registerItem( i, "item." + name );
|
||||
}
|
||||
|
||||
private void initStairBlock( BlockStairs stair )
|
||||
{
|
||||
this.stairData = stair;
|
||||
|
||||
String name = getName( stair.getClass(), subName );
|
||||
stair.setCreativeTab( CreativeTab.instance );
|
||||
stair.setBlockName( /* "tile." */"appliedenergistics2." + name );
|
||||
stair.setBlockTextureName( "appliedenergistics2:" + name );
|
||||
|
||||
GameRegistry.registerBlock( stair, "tile." + name );
|
||||
}
|
||||
|
||||
private void initBlock( Block b )
|
||||
{
|
||||
BlockData = b;
|
||||
|
||||
String name = getName( b.getClass(), subName );
|
||||
b.setCreativeTab( CreativeTab.instance );
|
||||
b.setBlockName( /* "tile." */"appliedenergistics2." + name );
|
||||
b.setBlockTextureName( "appliedenergistics2:" + name );
|
||||
|
||||
if ( Platform.isClient() && BlockData instanceof AEBaseBlock )
|
||||
{
|
||||
AEBaseBlock bb = ( AEBaseBlock ) b;
|
||||
CommonHelper.proxy.bindTileEntitySpecialRenderer( bb.getTileEntityClass(), bb );
|
||||
}
|
||||
|
||||
Class<? extends AEBaseItemBlock> itemBlock = AEBaseItemBlock.class;
|
||||
if ( b instanceof AEBaseBlock )
|
||||
itemBlock = ( ( AEBaseBlock ) b ).getItemBlockClass();
|
||||
|
||||
GameRegistry.registerBlock( b, itemBlock, "tile." + name );
|
||||
}
|
||||
|
||||
public static String getName( Class o, String subName )
|
||||
{
|
||||
String name = o.getSimpleName();
|
||||
|
||||
@@ -91,76 +171,42 @@ public class AEFeatureHandler implements AEItemDefinition
|
||||
return name;
|
||||
}
|
||||
|
||||
private void initItem(Item i)
|
||||
{
|
||||
ItemData = i;
|
||||
|
||||
String name = getName( i.getClass(), subName );
|
||||
i.setTextureName( "appliedenergistics2:" + name );
|
||||
i.setUnlocalizedName( /* "item." */"appliedenergistics2." + name );
|
||||
|
||||
if ( i instanceof ItemFacade )
|
||||
i.setCreativeTab( CreativeTabFacade.instance );
|
||||
else
|
||||
i.setCreativeTab( CreativeTab.instance );
|
||||
|
||||
if ( name.equals( "ItemMaterial" ) )
|
||||
name = "ItemMultiMaterial";
|
||||
else if ( name.equals( "ItemPart" ) )
|
||||
name = "ItemMultiPart";
|
||||
|
||||
GameRegistry.registerItem( i, "item." + name );
|
||||
}
|
||||
|
||||
private void initBlock(Block b)
|
||||
{
|
||||
BlockData = b;
|
||||
|
||||
String name = getName( b.getClass(), subName );
|
||||
b.setCreativeTab( CreativeTab.instance );
|
||||
b.setBlockName( /* "tile." */"appliedenergistics2." + name );
|
||||
b.setBlockTextureName( "appliedenergistics2:" + name );
|
||||
|
||||
if ( Platform.isClient() && BlockData instanceof AEBaseBlock )
|
||||
{
|
||||
AEBaseBlock bb = (AEBaseBlock) b;
|
||||
CommonHelper.proxy.bindTileEntitySpecialRenderer( bb.getTileEntityClass(), bb );
|
||||
}
|
||||
|
||||
Class<? extends AEBaseItemBlock> itemBlock = AEBaseItemBlock.class;
|
||||
if ( b instanceof AEBaseBlock )
|
||||
itemBlock = ((AEBaseBlock) b).getItemBlockClass();
|
||||
|
||||
GameRegistry.registerBlock( b, itemBlock, "tile." + name );
|
||||
}
|
||||
|
||||
public EnumSet<AEFeature> getFeatures()
|
||||
{
|
||||
return features.clone();
|
||||
}
|
||||
|
||||
public boolean isFeatureAvailable()
|
||||
{
|
||||
boolean enabled = true;
|
||||
|
||||
for (AEFeature f : features)
|
||||
enabled = enabled && AEConfig.instance.isFeatureEnabled( f );
|
||||
|
||||
return enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block block()
|
||||
{
|
||||
return BlockData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item item()
|
||||
{
|
||||
if ( this.ItemData != null )
|
||||
{
|
||||
return this.ItemData;
|
||||
}
|
||||
else if ( this.BlockData != null )
|
||||
{
|
||||
return Item.getItemFromBlock( this.BlockData );
|
||||
}
|
||||
else if ( this.stairData != null )
|
||||
{
|
||||
return Item.getItemFromBlock( this.stairData );
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends TileEntity> entity()
|
||||
{
|
||||
if ( BlockData instanceof AEBaseBlock )
|
||||
{
|
||||
AEBaseBlock bb = (AEBaseBlock) BlockData;
|
||||
AEBaseBlock bb = ( AEBaseBlock ) BlockData;
|
||||
return bb.getTileEntityClass();
|
||||
}
|
||||
|
||||
@@ -168,15 +214,7 @@ public class AEFeatureHandler implements AEItemDefinition
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item item()
|
||||
{
|
||||
if ( ItemData == null && BlockData != null )
|
||||
return Item.getItemFromBlock( BlockData );
|
||||
return ItemData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack stack(int stackSize)
|
||||
public ItemStack stack( int stackSize )
|
||||
{
|
||||
if ( isFeatureAvailable() )
|
||||
{
|
||||
@@ -190,11 +228,12 @@ public class AEFeatureHandler implements AEItemDefinition
|
||||
rv.stackSize = stackSize;
|
||||
return rv;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sameAsStack(ItemStack is)
|
||||
public boolean sameAsStack( ItemStack is )
|
||||
{
|
||||
return isFeatureAvailable() && Platform.isSameItemType( is, stack( 1 ) );
|
||||
}
|
||||
@@ -214,7 +253,7 @@ public class AEFeatureHandler implements AEItemDefinition
|
||||
* @return true if feature is available and the blocks are equal
|
||||
*/
|
||||
@Override
|
||||
public boolean sameAsBlock(IBlockAccess world, int x, int y, int z)
|
||||
public boolean sameAsBlock( IBlockAccess world, int x, int y, int z )
|
||||
{
|
||||
return isFeatureAvailable() && BlockData != null && world.getBlock( x, y, z ) == BlockData;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* 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.core.features;
|
||||
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import appeng.api.util.AEItemDefinition;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class BlockDefinition implements AEItemDefinition
|
||||
{
|
||||
private final Block block;
|
||||
private final boolean enabled;
|
||||
|
||||
public BlockDefinition( Block block, boolean enabled )
|
||||
{
|
||||
this.block = block;
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block block()
|
||||
{
|
||||
return this.block;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item item()
|
||||
{
|
||||
return Item.getItemFromBlock( this.block );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends TileEntity> entity()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack stack( int stackSize )
|
||||
{
|
||||
if ( this.enabled )
|
||||
{
|
||||
return new ItemStack( this.block );
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sameAsStack( ItemStack comparableItem )
|
||||
{
|
||||
return this.enabled && Platform.isSameItemType( comparableItem, this.stack( 1 ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sameAsBlock( IBlockAccess world, int x, int y, int z )
|
||||
{
|
||||
return this.enabled && world.getBlock( x, y, z ) == this.block;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* 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.core.features;
|
||||
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
|
||||
public class FeatureNameExtractor
|
||||
{
|
||||
private Class<?> clazz;
|
||||
private Optional<String> subName;
|
||||
|
||||
public FeatureNameExtractor( Class<?> clazz, Optional<String> subName )
|
||||
{
|
||||
this.clazz = clazz;
|
||||
this.subName = subName;
|
||||
}
|
||||
|
||||
public String get()
|
||||
{
|
||||
String name = this.clazz.getSimpleName();
|
||||
|
||||
if ( name.startsWith( "ItemMultiPart" ) )
|
||||
{
|
||||
name = name.replace( "ItemMultiPart", "ItemPart" );
|
||||
}
|
||||
else if ( name.startsWith( "ItemMultiMaterial" ) )
|
||||
{
|
||||
name = name.replace( "ItemMultiMaterial", "ItemMaterial" );
|
||||
}
|
||||
|
||||
if ( this.subName.isPresent() )
|
||||
{
|
||||
final String subName = this.subName.get();
|
||||
// simple hack to allow me to do get nice names for these without
|
||||
// mode code outside of AEBaseItem
|
||||
if ( subName.startsWith( "P2PTunnel" ) )
|
||||
{
|
||||
return "ItemPart.P2PTunnel";
|
||||
}
|
||||
else if ( subName.equals( "CertusQuartzTools" ) )
|
||||
{
|
||||
return name.replace( "Quartz", "CertusQuartz" );
|
||||
}
|
||||
else if ( subName.equals( "NetherQuartzTools" ) )
|
||||
{
|
||||
return name.replace( "Quartz", "NetherQuartz" );
|
||||
}
|
||||
|
||||
name += "." + subName;
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* 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.core.features;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import appeng.core.AEConfig;
|
||||
|
||||
|
||||
public class FeaturedActiveChecker
|
||||
{
|
||||
private EnumSet<AEFeature> features;
|
||||
|
||||
public FeaturedActiveChecker( EnumSet<AEFeature> features )
|
||||
{
|
||||
this.features = features;
|
||||
}
|
||||
|
||||
public boolean get()
|
||||
{
|
||||
for ( AEFeature f : this.features )
|
||||
{
|
||||
if ( !AEConfig.instance.isFeatureEnabled( f ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -18,11 +18,10 @@
|
||||
|
||||
package appeng.core.features;
|
||||
|
||||
|
||||
public interface IAEFeature
|
||||
{
|
||||
|
||||
public AEFeatureHandler feature();
|
||||
IFeatureHandler handler();
|
||||
|
||||
void postInit();
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* 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.core.features;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import appeng.api.util.AEItemDefinition;
|
||||
|
||||
|
||||
public interface IFeatureHandler
|
||||
{
|
||||
boolean isFeatureAvailable();
|
||||
|
||||
EnumSet<AEFeature> getFeatures();
|
||||
|
||||
AEItemDefinition getDefinition();
|
||||
|
||||
void register();
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* 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.core.features;
|
||||
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import appeng.api.util.AEItemDefinition;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class ItemDefinition implements AEItemDefinition
|
||||
{
|
||||
private final Item item;
|
||||
private final boolean enabled;
|
||||
|
||||
public ItemDefinition( Item item, boolean enabled )
|
||||
{
|
||||
this.item = item;
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block block()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item item()
|
||||
{
|
||||
return this.item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends TileEntity> entity()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack stack( int stackSize )
|
||||
{
|
||||
if ( this.enabled )
|
||||
{
|
||||
return new ItemStack( this.item );
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sameAsStack( ItemStack comparableItem )
|
||||
{
|
||||
return this.enabled && Platform.isSameItemType( comparableItem, this.stack( 1 ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sameAsBlock( IBlockAccess world, int x, int y, int z )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* 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.core.features;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
import appeng.api.util.AEItemDefinition;
|
||||
import appeng.core.CreativeTab;
|
||||
import appeng.core.CreativeTabFacade;
|
||||
import appeng.items.parts.ItemFacade;
|
||||
|
||||
|
||||
public class ItemFeatureHandler implements IFeatureHandler
|
||||
{
|
||||
private final EnumSet<AEFeature> features;
|
||||
private final Item item;
|
||||
private final FeatureNameExtractor extractor;
|
||||
private final boolean enabled;
|
||||
private final ItemDefinition definition;
|
||||
|
||||
public ItemFeatureHandler( EnumSet<AEFeature> features, Item item, IAEFeature featured, Optional<String> subName )
|
||||
{
|
||||
this.features = features;
|
||||
this.item = item;
|
||||
this.extractor = new FeatureNameExtractor( featured.getClass(), subName );
|
||||
this.enabled = new FeaturedActiveChecker( features ).get();
|
||||
this.definition = new ItemDefinition( item, this.enabled );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFeatureAvailable()
|
||||
{
|
||||
return this.enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<AEFeature> getFeatures()
|
||||
{
|
||||
return this.features;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AEItemDefinition getDefinition()
|
||||
{
|
||||
return this.definition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register()
|
||||
{
|
||||
String name = this.extractor.get();
|
||||
this.item.setTextureName( "appliedenergistics2:" + name );
|
||||
this.item.setUnlocalizedName( /* "item." */"appliedenergistics2." + name );
|
||||
|
||||
if ( this.item instanceof ItemFacade )
|
||||
{
|
||||
this.item.setCreativeTab( CreativeTabFacade.instance );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.item.setCreativeTab( CreativeTab.instance );
|
||||
}
|
||||
|
||||
if ( name.equals( "ItemMaterial" ) )
|
||||
{
|
||||
name = "ItemMultiMaterial";
|
||||
}
|
||||
else if ( name.equals( "ItemPart" ) )
|
||||
{
|
||||
name = "ItemMultiPart";
|
||||
}
|
||||
|
||||
GameRegistry.registerItem( this.item, "item." + name );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* 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.core.features;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import net.minecraft.block.BlockStairs;
|
||||
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
import appeng.api.util.AEItemDefinition;
|
||||
import appeng.core.CreativeTab;
|
||||
|
||||
|
||||
public class StairBlockFeatureHandler implements IFeatureHandler
|
||||
{
|
||||
private final EnumSet<AEFeature> features;
|
||||
private final BlockStairs stairs;
|
||||
private final FeatureNameExtractor extractor;
|
||||
private final boolean enabled;
|
||||
private final BlockDefinition definition;
|
||||
|
||||
public StairBlockFeatureHandler( EnumSet<AEFeature> features, BlockStairs stairs, Optional<String> subName )
|
||||
{
|
||||
this.features = features;
|
||||
this.stairs = stairs;
|
||||
this.extractor = new FeatureNameExtractor( stairs.getClass(), subName );
|
||||
this.enabled = new FeaturedActiveChecker( features ).get();
|
||||
this.definition = new BlockDefinition( stairs, this.enabled );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFeatureAvailable()
|
||||
{
|
||||
return this.enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<AEFeature> getFeatures()
|
||||
{
|
||||
return this.features;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AEItemDefinition getDefinition()
|
||||
{
|
||||
return this.definition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register()
|
||||
{
|
||||
String name = this.extractor.get();
|
||||
this.stairs.setCreativeTab( CreativeTab.instance );
|
||||
this.stairs.setBlockName( "appliedenergistics2." + name );
|
||||
this.stairs.setBlockTextureName( "appliedenergistics2:" + name );
|
||||
|
||||
GameRegistry.registerBlock( this.stairs, "tile." + name );
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user