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:
@@ -21,11 +21,11 @@ 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 com.google.common.base.Optional;
|
||||
|
||||
import appeng.api.definitions.ITileDefinition;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.block.AEBaseItemBlock;
|
||||
import appeng.core.CommonHelper;
|
||||
@@ -33,21 +33,21 @@ import appeng.core.CreativeTab;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class AEBlockFeatureHandler implements IFeatureHandler
|
||||
public final 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;
|
||||
private final TileDefinition definition;
|
||||
|
||||
public AEBlockFeatureHandler( EnumSet<AEFeature> features, AEBaseBlock featured, Optional<String> subName )
|
||||
{
|
||||
this.features = features;
|
||||
final ActivityState state = new FeaturedActiveChecker( features ).getActivityState();
|
||||
|
||||
this.featured = featured;
|
||||
this.extractor = new FeatureNameExtractor( featured.getClass(), subName );
|
||||
this.enabled = new FeaturedActiveChecker( features ).get();
|
||||
this.definition = new AEBlockDefinition( featured, this.enabled );
|
||||
this.enabled = state == ActivityState.Enabled;
|
||||
this.definition = new TileDefinition( featured, state );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -57,13 +57,7 @@ public class AEBlockFeatureHandler implements IFeatureHandler
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<AEFeature> getFeatures()
|
||||
{
|
||||
return this.features;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AEItemDefinition getDefinition()
|
||||
public ITileDefinition getDefinition()
|
||||
{
|
||||
return this.definition;
|
||||
}
|
||||
|
||||
@@ -1,266 +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.core.features;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
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;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.CommonHelper;
|
||||
import appeng.core.CreativeTab;
|
||||
import appeng.core.CreativeTabFacade;
|
||||
import appeng.items.parts.ItemFacade;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class AEFeatureHandler implements AEItemDefinition
|
||||
{
|
||||
|
||||
private static final Pattern PATTERN_ITEM_MULTI_PART = Pattern.compile( "ItemMultiPart", Pattern.LITERAL );
|
||||
private static final Pattern PATTERN_ITEM_MULTI_MATERIAL = Pattern.compile( "ItemMultiMaterial", Pattern.LITERAL );
|
||||
private static final Pattern PATTERN_QUARTZ = Pattern.compile( "Quartz", Pattern.LITERAL );
|
||||
|
||||
private final EnumSet<AEFeature> features;
|
||||
|
||||
private final String subName;
|
||||
private final IAEFeature feature;
|
||||
|
||||
private Item ItemData;
|
||||
private Block BlockData;
|
||||
private BlockStairs stairData;
|
||||
|
||||
public AEFeatureHandler( EnumSet<AEFeature> features, IAEFeature feature, String subName )
|
||||
{
|
||||
this.features = features;
|
||||
this.feature = feature;
|
||||
this.subName = subName;
|
||||
}
|
||||
|
||||
public void register()
|
||||
{
|
||||
if ( this.isFeatureAvailable() )
|
||||
{
|
||||
if ( this.feature instanceof Item )
|
||||
{
|
||||
this.initItem( ( Item ) this.feature );
|
||||
}
|
||||
else if ( this.feature instanceof BlockStairs )
|
||||
{
|
||||
this.initStairBlock( ( BlockStairs ) this.feature );
|
||||
}
|
||||
else if ( this.feature instanceof Block )
|
||||
{
|
||||
this.initBlock( ( Block ) this.feature );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isFeatureAvailable()
|
||||
{
|
||||
boolean enabled = true;
|
||||
|
||||
for ( AEFeature f : this.features )
|
||||
enabled = enabled && AEConfig.instance.isFeatureEnabled( f );
|
||||
|
||||
return enabled;
|
||||
}
|
||||
|
||||
private void initItem( Item i )
|
||||
{
|
||||
this.ItemData = i;
|
||||
|
||||
String name = getName( i.getClass(), this.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(), this.subName );
|
||||
stair.setCreativeTab( CreativeTab.instance );
|
||||
stair.setBlockName( /* "tile." */"appliedenergistics2." + name );
|
||||
stair.setBlockTextureName( "appliedenergistics2:" + name );
|
||||
|
||||
GameRegistry.registerBlock( stair, "tile." + name );
|
||||
}
|
||||
|
||||
private void initBlock( Block b )
|
||||
{
|
||||
this.BlockData = b;
|
||||
|
||||
String name = getName( b.getClass(), this.subName );
|
||||
b.setCreativeTab( CreativeTab.instance );
|
||||
b.setBlockName( /* "tile." */"appliedenergistics2." + name );
|
||||
b.setBlockTextureName( "appliedenergistics2:" + name );
|
||||
|
||||
if ( Platform.isClient() && this.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();
|
||||
|
||||
if ( name.startsWith( "ItemMultiPart" ) )
|
||||
name = PATTERN_ITEM_MULTI_PART.matcher( name ).replaceAll( "ItemPart" );
|
||||
else if ( name.startsWith( "ItemMultiMaterial" ) )
|
||||
name = PATTERN_ITEM_MULTI_MATERIAL.matcher( name ).replaceAll( "ItemMaterial" );
|
||||
|
||||
if ( subName != null )
|
||||
{
|
||||
// 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";
|
||||
|
||||
if ( subName.equals( "CertusQuartzTools" ) )
|
||||
return PATTERN_QUARTZ.matcher( name ).replaceAll( "CertusQuartz" );
|
||||
if ( subName.equals( "NetherQuartzTools" ) )
|
||||
return PATTERN_QUARTZ.matcher( name ).replaceAll( "NetherQuartz" );
|
||||
|
||||
name += '.' + subName;
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
public EnumSet<AEFeature> getFeatures()
|
||||
{
|
||||
return this.features.clone();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block block()
|
||||
{
|
||||
return this.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 ( this.BlockData instanceof AEBaseBlock )
|
||||
{
|
||||
AEBaseBlock bb = ( AEBaseBlock ) this.BlockData;
|
||||
return bb.getTileEntityClass();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack stack( int stackSize )
|
||||
{
|
||||
if ( this.isFeatureAvailable() )
|
||||
{
|
||||
ItemStack rv;
|
||||
|
||||
if ( this.ItemData != null )
|
||||
rv = new ItemStack( this.ItemData );
|
||||
else
|
||||
rv = new ItemStack( this.BlockData );
|
||||
|
||||
rv.stackSize = stackSize;
|
||||
return rv;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sameAsStack( ItemStack is )
|
||||
{
|
||||
return this.isFeatureAvailable() && Platform.isSameItemType( is, this.stack( 1 ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* block at xyz in world is same if:
|
||||
*
|
||||
* - the feature is available
|
||||
* - the stored block data is not null
|
||||
* - and the stored block data is equal
|
||||
*
|
||||
* @param world world of block
|
||||
* @param x x pos of block
|
||||
* @param y y pos of block
|
||||
* @param z z pos of block
|
||||
*
|
||||
* @return true if feature is available and the blocks are equal
|
||||
*/
|
||||
@Override
|
||||
public boolean sameAsBlock( IBlockAccess world, int x, int y, int z )
|
||||
{
|
||||
return this.isFeatureAvailable() && this.BlockData != null && world.getBlock( x, y, z ) == this.BlockData;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package appeng.core.features;
|
||||
|
||||
|
||||
public enum ActivityState
|
||||
{
|
||||
Enabled, Disabled
|
||||
}
|
||||
@@ -21,62 +21,61 @@ package appeng.core.features;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import appeng.api.util.AEItemDefinition;
|
||||
import appeng.util.Platform;
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import appeng.api.definitions.IBlockDefinition;
|
||||
|
||||
|
||||
public class BlockDefinition implements AEItemDefinition
|
||||
public class BlockDefinition extends ItemDefinition implements IBlockDefinition
|
||||
{
|
||||
private final Block block;
|
||||
private final boolean enabled;
|
||||
|
||||
public BlockDefinition( Block block, boolean enabled )
|
||||
public BlockDefinition( Block block, ActivityState state )
|
||||
{
|
||||
super( Item.getItemFromBlock( block ), state );
|
||||
this.block = block;
|
||||
this.enabled = enabled;
|
||||
this.enabled = state == ActivityState.Enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block block()
|
||||
public Optional<Block> maybeBlock()
|
||||
{
|
||||
return this.block;
|
||||
return Optional.of( 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 )
|
||||
public Optional<ItemBlock> maybeItemBlock()
|
||||
{
|
||||
if ( this.enabled )
|
||||
{
|
||||
return new ItemStack( this.block );
|
||||
return Optional.of( new ItemBlock( this.block ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
return Optional.absent();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sameAsStack( ItemStack comparableItem )
|
||||
public final Optional<ItemStack> maybeStack( int stackSize )
|
||||
{
|
||||
return this.enabled && Platform.isSameItemType( comparableItem, this.stack( 1 ) );
|
||||
if ( this.enabled )
|
||||
{
|
||||
return Optional.of( new ItemStack( this.block ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
return Optional.absent();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sameAsBlock( IBlockAccess world, int x, int y, int z )
|
||||
public final boolean isSameAs( IBlockAccess world, int x, int y, int z )
|
||||
{
|
||||
return this.enabled && world.getBlock( x, y, z ) == this.block;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.api.util.AEColoredItemDefinition;
|
||||
|
||||
public class ColoredItemDefinition implements AEColoredItemDefinition
|
||||
public final class ColoredItemDefinition implements AEColoredItemDefinition
|
||||
{
|
||||
|
||||
final ItemStackSrc[] colors = new ItemStackSrc[17];
|
||||
|
||||
@@ -18,60 +18,53 @@
|
||||
|
||||
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 com.google.common.base.Optional;
|
||||
|
||||
public class DamagedItemDefinition implements AEItemDefinition
|
||||
import appeng.api.definitions.IItemDefinition;
|
||||
|
||||
|
||||
public final class DamagedItemDefinition implements IItemDefinition
|
||||
{
|
||||
private final IStackSrc source;
|
||||
|
||||
final IStackSrc src;
|
||||
|
||||
public DamagedItemDefinition(IStackSrc is) {
|
||||
this.src = is;
|
||||
public DamagedItemDefinition( IStackSrc source )
|
||||
{
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block block()
|
||||
public Optional<Item> maybeItem()
|
||||
{
|
||||
return null;
|
||||
final Item item = this.source.getItem();
|
||||
|
||||
return Optional.fromNullable( item );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item item()
|
||||
public Optional<ItemStack> maybeStack( int stackSize )
|
||||
{
|
||||
return this.src.getItem();
|
||||
final ItemStack stack = this.source.stack( stackSize );
|
||||
|
||||
return Optional.fromNullable( stack );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends TileEntity> entity()
|
||||
public boolean isSameAs( ItemStack comparableStack )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack stack(int stackSize)
|
||||
{
|
||||
return this.src.stack( stackSize );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sameAsStack(ItemStack comparableItem)
|
||||
{
|
||||
if ( comparableItem == null )
|
||||
if ( comparableStack == null )
|
||||
return false;
|
||||
|
||||
return comparableItem.getItem() == this.src.getItem() && comparableItem.getItemDamage() == this.src.getDamage();
|
||||
return comparableStack.getItem() == this.source.getItem() && comparableStack.getItemDamage() == this.source.getDamage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sameAsBlock(IBlockAccess world, int x, int y, int z)
|
||||
public boolean isSameAs( IBlockAccess world, int x, int y, int z )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,160 @@
|
||||
package appeng.core.features;
|
||||
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
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.definitions.IBlockDefinition;
|
||||
import appeng.api.definitions.IComparableDefinition;
|
||||
import appeng.api.definitions.IItemDefinition;
|
||||
import appeng.api.definitions.ITileDefinition;
|
||||
import appeng.api.util.AEItemDefinition;
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
public final class DefinitionConverter
|
||||
{
|
||||
public AEItemDefinition of( ITileDefinition definition )
|
||||
{
|
||||
return new AETile( definition );
|
||||
}
|
||||
|
||||
public AEItemDefinition of( IBlockDefinition definition )
|
||||
{
|
||||
return new AEBlock( definition );
|
||||
}
|
||||
|
||||
public AEItemDefinition of( IItemDefinition definition )
|
||||
{
|
||||
return new AEItem( definition );
|
||||
}
|
||||
|
||||
public AEItemDefinition of( IComparableDefinition definition )
|
||||
{
|
||||
return new AEComparable( definition );
|
||||
}
|
||||
|
||||
private static class AEComparable implements AEItemDefinition
|
||||
{
|
||||
private final IComparableDefinition definition;
|
||||
|
||||
public AEComparable( IComparableDefinition definition )
|
||||
{
|
||||
this.definition = definition;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Block block()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Item item()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Class<? extends TileEntity> entity()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ItemStack stack( int stackSize )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sameAsStack( ItemStack comparableItem )
|
||||
{
|
||||
return this.definition.isSameAs( comparableItem );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sameAsBlock( IBlockAccess world, int x, int y, int z )
|
||||
{
|
||||
return this.definition.isSameAs( world, x, y, z );
|
||||
}
|
||||
}
|
||||
|
||||
private static class AEItem extends AEComparable
|
||||
{
|
||||
private final IItemDefinition definition;
|
||||
|
||||
public AEItem( IItemDefinition definition )
|
||||
{
|
||||
super( definition );
|
||||
|
||||
this.definition = definition;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ItemStack stack( int stackSize )
|
||||
{
|
||||
return this.definition.maybeStack( stackSize ).orNull();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Item item()
|
||||
{
|
||||
return this.definition.maybeItem().orNull();
|
||||
}
|
||||
}
|
||||
|
||||
private static class AEBlock extends AEItem
|
||||
{
|
||||
private final IBlockDefinition definition;
|
||||
|
||||
public AEBlock( IBlockDefinition definition )
|
||||
{
|
||||
super( definition );
|
||||
|
||||
this.definition = definition;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Block block()
|
||||
{
|
||||
return this.definition.maybeBlock().orNull();
|
||||
}
|
||||
}
|
||||
|
||||
private static class AETile extends AEBlock
|
||||
{
|
||||
private final ITileDefinition definition;
|
||||
|
||||
public AETile( ITileDefinition definition )
|
||||
{
|
||||
super( definition );
|
||||
|
||||
this.definition = definition;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Class<? extends TileEntity> entity()
|
||||
{
|
||||
return this.definition.maybeEntity().orNull();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -19,30 +19,30 @@
|
||||
package appeng.core.features;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.Set;
|
||||
|
||||
import appeng.core.AEConfig;
|
||||
|
||||
|
||||
public class FeaturedActiveChecker
|
||||
{
|
||||
private final EnumSet<AEFeature> features;
|
||||
private final Set<AEFeature> features;
|
||||
|
||||
public FeaturedActiveChecker( EnumSet<AEFeature> features )
|
||||
public FeaturedActiveChecker( Set<AEFeature> features )
|
||||
{
|
||||
this.features = features;
|
||||
}
|
||||
|
||||
public boolean get()
|
||||
public ActivityState getActivityState()
|
||||
{
|
||||
for ( AEFeature f : this.features )
|
||||
{
|
||||
if ( !AEConfig.instance.isFeatureEnabled( f ) )
|
||||
{
|
||||
return false;
|
||||
return ActivityState.Disabled;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return ActivityState.Enabled;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,18 +19,14 @@
|
||||
package appeng.core.features;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import appeng.api.util.AEItemDefinition;
|
||||
import appeng.api.definitions.IItemDefinition;
|
||||
|
||||
|
||||
public interface IFeatureHandler
|
||||
{
|
||||
boolean isFeatureAvailable();
|
||||
|
||||
EnumSet<AEFeature> getFeatures();
|
||||
|
||||
AEItemDefinition getDefinition();
|
||||
IItemDefinition getDefinition();
|
||||
|
||||
void register();
|
||||
}
|
||||
|
||||
@@ -19,66 +19,54 @@
|
||||
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 com.google.common.base.Optional;
|
||||
|
||||
import appeng.api.definitions.IItemDefinition;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class ItemDefinition implements AEItemDefinition
|
||||
public class ItemDefinition implements IItemDefinition
|
||||
{
|
||||
private final Item item;
|
||||
private final boolean enabled;
|
||||
|
||||
public ItemDefinition( Item item, boolean enabled )
|
||||
public ItemDefinition( Item item, ActivityState state )
|
||||
{
|
||||
this.item = item;
|
||||
this.enabled = enabled;
|
||||
this.enabled = state == ActivityState.Enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block block()
|
||||
public final Optional<Item> maybeItem()
|
||||
{
|
||||
return null;
|
||||
return Optional.of( this.item );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item item()
|
||||
{
|
||||
return this.item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends TileEntity> entity()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack stack( int stackSize )
|
||||
public Optional<ItemStack> maybeStack( int stackSize )
|
||||
{
|
||||
if ( this.enabled )
|
||||
{
|
||||
return new ItemStack( this.item );
|
||||
return Optional.of( new ItemStack( this.item ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
return Optional.absent();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sameAsStack( ItemStack comparableItem )
|
||||
public final boolean isSameAs( ItemStack comparableStack )
|
||||
{
|
||||
return this.enabled && Platform.isSameItemType( comparableItem, this.stack( 1 ) );
|
||||
return this.enabled && Platform.isSameItemType( comparableStack, this.maybeStack( 1 ).get() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sameAsBlock( IBlockAccess world, int x, int y, int z )
|
||||
public boolean isSameAs( IBlockAccess world, int x, int y, int z )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -21,21 +21,20 @@ 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 com.google.common.base.Optional;
|
||||
|
||||
import appeng.api.definitions.IItemDefinition;
|
||||
import appeng.core.CreativeTab;
|
||||
import appeng.core.CreativeTabFacade;
|
||||
import appeng.items.parts.ItemFacade;
|
||||
|
||||
|
||||
public class ItemFeatureHandler implements IFeatureHandler
|
||||
public final class ItemFeatureHandler implements IFeatureHandler
|
||||
{
|
||||
private final EnumSet<AEFeature> features;
|
||||
private final Item item;
|
||||
private final FeatureNameExtractor extractor;
|
||||
private final boolean enabled;
|
||||
@@ -43,11 +42,12 @@ public class ItemFeatureHandler implements IFeatureHandler
|
||||
|
||||
public ItemFeatureHandler( EnumSet<AEFeature> features, Item item, IAEFeature featured, Optional<String> subName )
|
||||
{
|
||||
this.features = features;
|
||||
final ActivityState state = new FeaturedActiveChecker( features ).getActivityState();
|
||||
|
||||
this.item = item;
|
||||
this.extractor = new FeatureNameExtractor( featured.getClass(), subName );
|
||||
this.enabled = new FeaturedActiveChecker( features ).get();
|
||||
this.definition = new ItemDefinition( item, this.enabled );
|
||||
this.enabled = state == ActivityState.Enabled;
|
||||
this.definition = new ItemDefinition( item, state );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -57,13 +57,7 @@ public class ItemFeatureHandler implements IFeatureHandler
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<AEFeature> getFeatures()
|
||||
{
|
||||
return this.features;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AEItemDefinition getDefinition()
|
||||
public IItemDefinition getDefinition()
|
||||
{
|
||||
return this.definition;
|
||||
}
|
||||
@@ -71,28 +65,31 @@ public class ItemFeatureHandler implements IFeatureHandler
|
||||
@Override
|
||||
public void register()
|
||||
{
|
||||
String name = this.extractor.get();
|
||||
this.item.setTextureName( "appliedenergistics2:" + name );
|
||||
this.item.setUnlocalizedName( /* "item." */"appliedenergistics2." + name );
|
||||
if ( this.enabled )
|
||||
{
|
||||
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 ( 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";
|
||||
}
|
||||
if ( name.equals( "ItemMaterial" ) )
|
||||
{
|
||||
name = "ItemMultiMaterial";
|
||||
}
|
||||
else if ( name.equals( "ItemPart" ) )
|
||||
{
|
||||
name = "ItemMultiPart";
|
||||
}
|
||||
|
||||
GameRegistry.registerItem( this.item, "item." + name );
|
||||
GameRegistry.registerItem( this.item, "item." + name );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,24 +18,27 @@
|
||||
|
||||
package appeng.core.features;
|
||||
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.items.materials.MaterialType;
|
||||
|
||||
|
||||
public class MaterialStackSrc implements IStackSrc
|
||||
{
|
||||
|
||||
final MaterialType src;
|
||||
|
||||
public MaterialStackSrc(MaterialType src) {
|
||||
public MaterialStackSrc( MaterialType src )
|
||||
{
|
||||
assert src != null;
|
||||
|
||||
this.src = src;
|
||||
if ( src == null )
|
||||
throw new RuntimeException( "Invalid Item Stack" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack stack(int stackSize)
|
||||
public ItemStack stack( int stackSize )
|
||||
{
|
||||
return this.src.stack( stackSize );
|
||||
}
|
||||
@@ -51,5 +54,4 @@ public class MaterialStackSrc implements IStackSrc
|
||||
{
|
||||
return this.src.damageValue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* 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.regex.Pattern;
|
||||
|
||||
import appeng.items.AEBaseItem;
|
||||
|
||||
|
||||
/**
|
||||
* This class is used to rename items to match the persistent stored items.
|
||||
*
|
||||
* This can be removed, when a new iteration of minecraft arrives or a new world is used.
|
||||
* Remember to differentiate the currently renamed items later on correctly.
|
||||
*
|
||||
* @deprecated only a temporary solution for a rename
|
||||
*/
|
||||
@Deprecated
|
||||
public final class NameResolver
|
||||
{
|
||||
private static final Pattern ITEM_MULTI_PART = Pattern.compile( "ItemMultiPart", Pattern.LITERAL );
|
||||
private static final Pattern ITEM_MULTI_MATERIAL = Pattern.compile( "ItemMultiMaterial", Pattern.LITERAL );
|
||||
private static final Pattern QUARTZ = Pattern.compile( "Quartz", Pattern.LITERAL );
|
||||
|
||||
private final Class<? extends AEBaseItem> withOriginalName;
|
||||
|
||||
public NameResolver( Class<? extends AEBaseItem> withOriginalName)
|
||||
{
|
||||
this.withOriginalName = withOriginalName;
|
||||
}
|
||||
|
||||
public String getName( String subName )
|
||||
{
|
||||
String name = this.withOriginalName.getSimpleName();
|
||||
|
||||
if ( name.startsWith( "ItemMultiPart" ) )
|
||||
name = ITEM_MULTI_PART.matcher( name ).replaceAll( "ItemPart" );
|
||||
else if ( name.startsWith( "ItemMultiMaterial" ) )
|
||||
name = ITEM_MULTI_MATERIAL.matcher( name ).replaceAll( "ItemMaterial" );
|
||||
|
||||
if ( subName != null )
|
||||
{
|
||||
// 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";
|
||||
|
||||
if ( subName.equals( "CertusQuartzTools" ) )
|
||||
return QUARTZ.matcher( name ).replaceAll( "CertusQuartz" );
|
||||
if ( subName.equals( "NetherQuartzTools" ) )
|
||||
return QUARTZ.matcher( name ).replaceAll( "NetherQuartz" );
|
||||
|
||||
name += '.' + subName;
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
}
|
||||
@@ -1,68 +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.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;
|
||||
|
||||
public class NullItemDefinition implements AEItemDefinition
|
||||
{
|
||||
|
||||
@Override
|
||||
public Block block()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item item()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends TileEntity> entity()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack stack(int stackSize)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sameAsStack(ItemStack comparableItem)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sameAsBlock(IBlockAccess world, int x, int y, int z)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -21,19 +21,18 @@ 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 com.google.common.base.Optional;
|
||||
|
||||
import appeng.api.definitions.IBlockDefinition;
|
||||
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;
|
||||
@@ -41,39 +40,37 @@ public class StairBlockFeatureHandler implements IFeatureHandler
|
||||
|
||||
public StairBlockFeatureHandler( EnumSet<AEFeature> features, BlockStairs stairs, Optional<String> subName )
|
||||
{
|
||||
this.features = features;
|
||||
final ActivityState state = new FeaturedActiveChecker( features ).getActivityState();
|
||||
|
||||
this.stairs = stairs;
|
||||
this.extractor = new FeatureNameExtractor( stairs.getClass(), subName );
|
||||
this.enabled = new FeaturedActiveChecker( features ).get();
|
||||
this.definition = new BlockDefinition( stairs, this.enabled );
|
||||
this.enabled = state == ActivityState.Enabled;
|
||||
this.definition = new BlockDefinition( stairs, state );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFeatureAvailable()
|
||||
public final boolean isFeatureAvailable()
|
||||
{
|
||||
return this.enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<AEFeature> getFeatures()
|
||||
{
|
||||
return this.features;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AEItemDefinition getDefinition()
|
||||
public final IBlockDefinition getDefinition()
|
||||
{
|
||||
return this.definition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register()
|
||||
public final void register()
|
||||
{
|
||||
String name = this.extractor.get();
|
||||
this.stairs.setCreativeTab( CreativeTab.instance );
|
||||
this.stairs.setBlockName( "appliedenergistics2." + name );
|
||||
this.stairs.setBlockTextureName( "appliedenergistics2:" + name );
|
||||
if ( this.enabled )
|
||||
{
|
||||
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 );
|
||||
GameRegistry.registerBlock( this.stairs, "tile." + name );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+10
-5
@@ -21,23 +21,28 @@ package appeng.core.features;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import appeng.api.definitions.ITileDefinition;
|
||||
import appeng.block.AEBaseBlock;
|
||||
|
||||
|
||||
public class AEBlockDefinition extends BlockDefinition
|
||||
public final class TileDefinition extends BlockDefinition implements ITileDefinition
|
||||
{
|
||||
private final AEBaseBlock block;
|
||||
|
||||
public AEBlockDefinition( AEBaseBlock block, boolean enabled )
|
||||
public TileDefinition( AEBaseBlock block, ActivityState state )
|
||||
{
|
||||
super( block, enabled );
|
||||
super( block, state );
|
||||
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends TileEntity> entity()
|
||||
public Optional<? extends Class<? extends TileEntity>> maybeEntity()
|
||||
{
|
||||
return this.block.getTileEntityClass();
|
||||
final Class<? extends TileEntity> entity = this.block.getTileEntityClass();
|
||||
|
||||
return Optional.of( entity );
|
||||
}
|
||||
}
|
||||
@@ -18,67 +18,92 @@
|
||||
|
||||
package appeng.core.features;
|
||||
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import appeng.api.util.AEItemDefinition;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
public class WrappedDamageItemDefinition implements AEItemDefinition
|
||||
import appeng.api.definitions.ITileDefinition;
|
||||
|
||||
|
||||
public final class WrappedDamageItemDefinition implements ITileDefinition
|
||||
{
|
||||
private final ITileDefinition definition;
|
||||
private final int damage;
|
||||
|
||||
final AEItemDefinition baseItem;
|
||||
final int damage;
|
||||
|
||||
public WrappedDamageItemDefinition(AEItemDefinition def, int dmg) {
|
||||
this.baseItem = def;
|
||||
this.damage = dmg;
|
||||
public WrappedDamageItemDefinition( ITileDefinition definition, int damage )
|
||||
{
|
||||
this.definition = definition;
|
||||
this.damage = damage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block block()
|
||||
public Optional<? extends Class<? extends TileEntity>> maybeEntity()
|
||||
{
|
||||
return this.baseItem.block();
|
||||
return this.definition.maybeEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item item()
|
||||
public Optional<Block> maybeBlock()
|
||||
{
|
||||
return this.baseItem.item();
|
||||
return this.definition.maybeBlock();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends TileEntity> entity()
|
||||
public Optional<ItemBlock> maybeItemBlock()
|
||||
{
|
||||
return this.baseItem.entity();
|
||||
return this.definition.maybeItemBlock();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack stack(int stackSize)
|
||||
public Optional<Item> maybeItem()
|
||||
{
|
||||
if ( this.baseItem == null )
|
||||
return null;
|
||||
|
||||
return new ItemStack( this.baseItem.block(), stackSize, this.damage );
|
||||
return this.definition.maybeItem();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sameAsStack(ItemStack comparableItem)
|
||||
public Optional<ItemStack> maybeStack( final int stackSize )
|
||||
{
|
||||
if ( comparableItem == null )
|
||||
return this.definition.maybeBlock().transform( new BlockTransformFunction( stackSize ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSameAs( ItemStack comparableStack )
|
||||
{
|
||||
if ( comparableStack == null )
|
||||
return false;
|
||||
|
||||
return comparableItem.getItem() == this.baseItem.item() && comparableItem.getItemDamage() == this.damage;
|
||||
return this.definition.isSameAs( comparableStack ) && comparableStack.getItemDamage() == this.damage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sameAsBlock(IBlockAccess world, int x, int y, int z)
|
||||
public boolean isSameAs( IBlockAccess world, int x, int y, int z )
|
||||
{
|
||||
if ( this.block() != null )
|
||||
return world.getBlock( x, y, z ) == this.block() && world.getBlockMetadata( x, y, z ) == this.damage;
|
||||
return false;
|
||||
return this.definition.isSameAs( world, x, y, z ) && world.getBlockMetadata( x, y, z ) == this.damage;
|
||||
}
|
||||
|
||||
private class BlockTransformFunction implements Function<Block, ItemStack>
|
||||
{
|
||||
private final int stackSize;
|
||||
|
||||
public BlockTransformFunction( int stackSize )
|
||||
{
|
||||
this.stackSize = stackSize;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ItemStack apply( Block input )
|
||||
{
|
||||
return new ItemStack( input, this.stackSize, WrappedDamageItemDefinition.this.damage );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,10 @@ import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.TunnelType;
|
||||
import appeng.api.definitions.Parts;
|
||||
import appeng.api.definitions.IBlocks;
|
||||
import appeng.api.definitions.IDefinitions;
|
||||
import appeng.api.definitions.IItemDefinition;
|
||||
import appeng.api.definitions.IParts;
|
||||
import appeng.api.features.IP2PTunnelRegistry;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.util.Platform;
|
||||
@@ -78,14 +81,16 @@ public class P2PTunnelRegistry implements IP2PTunnelRegistry
|
||||
/**
|
||||
* attune based on lots of random item related stuff
|
||||
*/
|
||||
appeng.api.definitions.Blocks AEBlocks = AEApi.instance().blocks();
|
||||
Parts Parts = AEApi.instance().parts();
|
||||
final IDefinitions definitions = AEApi.instance().definitions();
|
||||
final IBlocks blocks = definitions.blocks();
|
||||
final IParts parts = definitions.parts();
|
||||
|
||||
this.addNewAttunement( blocks.iface(), TunnelType.ITEM );
|
||||
this.addNewAttunement( parts.iface(), TunnelType.ITEM );
|
||||
this.addNewAttunement( parts.storageBus(), TunnelType.ITEM );
|
||||
this.addNewAttunement( parts.importBus(), TunnelType.ITEM );
|
||||
this.addNewAttunement( parts.exportBus(), TunnelType.ITEM );
|
||||
|
||||
this.addNewAttunement( AEBlocks.blockInterface.stack( 1 ), TunnelType.ITEM );
|
||||
this.addNewAttunement( Parts.partInterface.stack( 1 ), TunnelType.ITEM );
|
||||
this.addNewAttunement( Parts.partStorageBus.stack( 1 ), TunnelType.ITEM );
|
||||
this.addNewAttunement( Parts.partImportBus.stack( 1 ), TunnelType.ITEM );
|
||||
this.addNewAttunement( Parts.partExportBus.stack( 1 ), TunnelType.ITEM );
|
||||
this.addNewAttunement( new ItemStack( Blocks.hopper ), TunnelType.ITEM );
|
||||
this.addNewAttunement( new ItemStack( Blocks.chest ), TunnelType.ITEM );
|
||||
this.addNewAttunement( new ItemStack( Blocks.trapped_chest ), TunnelType.ITEM );
|
||||
@@ -108,10 +113,18 @@ public class P2PTunnelRegistry implements IP2PTunnelRegistry
|
||||
|
||||
for (AEColor c : AEColor.values())
|
||||
{
|
||||
this.addNewAttunement( Parts.partCableGlass.stack( c, 1 ), TunnelType.ME );
|
||||
this.addNewAttunement( Parts.partCableCovered.stack( c, 1 ), TunnelType.ME );
|
||||
this.addNewAttunement( Parts.partCableSmart.stack( c, 1 ), TunnelType.ME );
|
||||
this.addNewAttunement( Parts.partCableDense.stack( c, 1 ), TunnelType.ME );
|
||||
this.addNewAttunement( parts.cableGlass().stack( c, 1 ), TunnelType.ME );
|
||||
this.addNewAttunement( parts.cableCovered().stack( c, 1 ), TunnelType.ME );
|
||||
this.addNewAttunement( parts.cableSmart().stack( c, 1 ), TunnelType.ME );
|
||||
this.addNewAttunement( parts.cableDense().stack( c, 1 ), TunnelType.ME );
|
||||
}
|
||||
}
|
||||
|
||||
private void addNewAttunement( IItemDefinition definition, TunnelType type )
|
||||
{
|
||||
for ( ItemStack definitionStack : definition.maybeStack( 1 ).asSet() )
|
||||
{
|
||||
this.addNewAttunement( definitionStack, type );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user