Applied-Energistics-2-tiler.../core/features/registries/P2PTunnelRegistry.java

102 lines
3.7 KiB
Java
Raw Normal View History

package appeng.core.features.registries;
import java.util.HashMap;
2014-02-09 02:34:52 +01:00
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.oredict.OreDictionary;
2014-01-24 17:31:29 +01:00
import appeng.api.AEApi;
import appeng.api.config.TunnelType;
2014-01-24 17:31:29 +01:00
import appeng.api.definitions.Parts;
import appeng.api.features.IP2PTunnelRegistry;
import appeng.api.util.AEColor;
import appeng.util.Platform;
public class P2PTunnelRegistry implements IP2PTunnelRegistry
{
HashMap<ItemStack, TunnelType> Tunnels = new HashMap();
2014-01-24 17:31:29 +01:00
public void configure()
{
/**
* attune based on most redstone base items.
*/
2014-02-09 02:34:52 +01:00
addNewAttunement( new ItemStack( Items.redstone ), TunnelType.REDSTONE );
addNewAttunement( new ItemStack( Items.repeater ), TunnelType.REDSTONE );
addNewAttunement( new ItemStack( Blocks.redstone_lamp ), TunnelType.REDSTONE );
addNewAttunement( new ItemStack( Blocks.unpowered_comparator ), TunnelType.REDSTONE );
addNewAttunement( new ItemStack( Blocks.powered_comparator ), TunnelType.REDSTONE );
addNewAttunement( new ItemStack( Blocks.powered_repeater ), TunnelType.REDSTONE );
addNewAttunement( new ItemStack( Blocks.unpowered_repeater ), TunnelType.REDSTONE );
addNewAttunement( new ItemStack( Blocks.daylight_detector ), TunnelType.REDSTONE );
addNewAttunement( new ItemStack( Blocks.redstone_wire ), TunnelType.REDSTONE );
addNewAttunement( new ItemStack( Blocks.redstone_block ), TunnelType.REDSTONE );
addNewAttunement( new ItemStack( Blocks.lever ), TunnelType.REDSTONE );
2014-01-24 17:31:29 +01:00
/**
* attune based on lots of random item related stuff
*/
2014-02-09 02:34:52 +01:00
appeng.api.definitions.Blocks AEBlocks = AEApi.instance().blocks();
2014-01-24 17:31:29 +01:00
Parts Parts = AEApi.instance().parts();
2014-02-09 02:34:52 +01:00
addNewAttunement( AEBlocks.blockInterface.stack( 1 ), TunnelType.ITEM );
2014-01-24 17:31:29 +01:00
addNewAttunement( Parts.partInterface.stack( 1 ), TunnelType.ITEM );
addNewAttunement( Parts.partStorageBus.stack( 1 ), TunnelType.ITEM );
addNewAttunement( Parts.partImportBus.stack( 1 ), TunnelType.ITEM );
addNewAttunement( Parts.partExportBus.stack( 1 ), TunnelType.ITEM );
2014-02-09 02:34:52 +01:00
addNewAttunement( new ItemStack( Blocks.hopper ), TunnelType.ITEM );
addNewAttunement( new ItemStack( Blocks.chest ), TunnelType.ITEM );
addNewAttunement( new ItemStack( Blocks.trapped_chest ), TunnelType.ITEM );
2014-01-24 17:31:29 +01:00
/**
* attune based on lots of random item related stuff
*/
2014-02-09 02:34:52 +01:00
addNewAttunement( new ItemStack( Items.bucket ), TunnelType.FLUID );
addNewAttunement( new ItemStack( Items.lava_bucket ), TunnelType.FLUID );
addNewAttunement( new ItemStack( Items.milk_bucket ), TunnelType.FLUID );
addNewAttunement( new ItemStack( Items.water_bucket ), TunnelType.FLUID );
for (AEColor c : AEColor.values())
{
addNewAttunement( Parts.partCableGlass.stack( c, 1 ), TunnelType.ME );
addNewAttunement( Parts.partCableCovered.stack( c, 1 ), TunnelType.ME );
addNewAttunement( Parts.partCableSmart.stack( c, 1 ), TunnelType.ME );
addNewAttunement( Parts.partCableDense.stack( c, 1 ), TunnelType.ME );
}
2014-01-24 17:31:29 +01:00
}
@Override
public void addNewAttunement(ItemStack trigger, TunnelType type)
{
2014-05-02 08:03:02 +02:00
if ( type == null || trigger == null )
return;
Tunnels.put( trigger, type );
}
@Override
public TunnelType getTunnelTypeByItem(ItemStack trigger)
{
2014-05-02 07:40:46 +02:00
if ( trigger != null )
{
2014-05-02 07:40:46 +02:00
if ( FluidContainerRegistry.isContainer( trigger ) )
return TunnelType.FLUID;
for (ItemStack is : Tunnels.keySet())
{
if ( is.getItem() == trigger.getItem() && is.getItemDamage() == OreDictionary.WILDCARD_VALUE )
return Tunnels.get( is );
2014-05-02 07:40:46 +02:00
if ( Platform.isSameItem( is, trigger ) )
return Tunnels.get( is );
}
}
return null;
}
}