2014-11-14 12:02:52 +01:00
|
|
|
/*
|
|
|
|
* 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>.
|
|
|
|
*/
|
|
|
|
|
2014-09-24 02:26:27 +02:00
|
|
|
package appeng.core.features.registries;
|
|
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
|
|
|
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-12-29 21:59:05 +01:00
|
|
|
|
|
|
|
import cpw.mods.fml.common.registry.GameRegistry;
|
|
|
|
|
2014-09-24 02:26:27 +02:00
|
|
|
import appeng.api.AEApi;
|
|
|
|
import appeng.api.config.TunnelType;
|
|
|
|
import appeng.api.definitions.Parts;
|
|
|
|
import appeng.api.features.IP2PTunnelRegistry;
|
|
|
|
import appeng.api.util.AEColor;
|
|
|
|
import appeng.util.Platform;
|
|
|
|
|
|
|
|
public class P2PTunnelRegistry implements IP2PTunnelRegistry
|
|
|
|
{
|
|
|
|
|
2014-09-29 09:54:34 +02:00
|
|
|
final HashMap<ItemStack, TunnelType> Tunnels = new HashMap<ItemStack, TunnelType>();
|
2014-09-24 02:26:27 +02:00
|
|
|
|
|
|
|
public ItemStack getModItem(String modID, String Name, int meta)
|
|
|
|
{
|
|
|
|
ItemStack myItemStack = GameRegistry.findItemStack( modID, Name, 1 );
|
|
|
|
|
|
|
|
if ( myItemStack == null )
|
|
|
|
return null;
|
|
|
|
|
|
|
|
myItemStack.setItemDamage( meta );
|
|
|
|
return myItemStack;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void configure()
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* light!
|
|
|
|
*/
|
2014-12-29 15:13:47 +01:00
|
|
|
this.addNewAttunement( new ItemStack( Blocks.torch ), TunnelType.LIGHT );
|
|
|
|
this.addNewAttunement( new ItemStack( Blocks.glowstone ), TunnelType.LIGHT );
|
2014-09-24 02:26:27 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* attune based on most redstone base items.
|
|
|
|
*/
|
2014-12-29 15:13:47 +01:00
|
|
|
this.addNewAttunement( new ItemStack( Items.redstone ), TunnelType.REDSTONE );
|
|
|
|
this.addNewAttunement( new ItemStack( Items.repeater ), TunnelType.REDSTONE );
|
|
|
|
this.addNewAttunement( new ItemStack( Blocks.redstone_lamp ), TunnelType.REDSTONE );
|
|
|
|
this.addNewAttunement( new ItemStack( Blocks.unpowered_comparator ), TunnelType.REDSTONE );
|
|
|
|
this.addNewAttunement( new ItemStack( Blocks.powered_comparator ), TunnelType.REDSTONE );
|
|
|
|
this.addNewAttunement( new ItemStack( Blocks.powered_repeater ), TunnelType.REDSTONE );
|
|
|
|
this.addNewAttunement( new ItemStack( Blocks.unpowered_repeater ), TunnelType.REDSTONE );
|
|
|
|
this.addNewAttunement( new ItemStack( Blocks.daylight_detector ), TunnelType.REDSTONE );
|
|
|
|
this.addNewAttunement( new ItemStack( Blocks.redstone_wire ), TunnelType.REDSTONE );
|
|
|
|
this.addNewAttunement( new ItemStack( Blocks.redstone_block ), TunnelType.REDSTONE );
|
|
|
|
this.addNewAttunement( new ItemStack( Blocks.lever ), TunnelType.REDSTONE );
|
|
|
|
this.addNewAttunement( this.getModItem( "EnderIO", "itemRedstoneConduit", OreDictionary.WILDCARD_VALUE ), TunnelType.REDSTONE );
|
2014-09-24 02:26:27 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* attune based on lots of random item related stuff
|
|
|
|
*/
|
|
|
|
appeng.api.definitions.Blocks AEBlocks = AEApi.instance().blocks();
|
|
|
|
Parts Parts = AEApi.instance().parts();
|
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
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 );
|
|
|
|
this.addNewAttunement( this.getModItem( "ExtraUtilities", "extractor_base", 0 ), TunnelType.ITEM );
|
|
|
|
this.addNewAttunement( this.getModItem( "Mekanism", "PartTransmitter", 9 ), TunnelType.ITEM );
|
|
|
|
this.addNewAttunement( this.getModItem( "EnderIO", "itemItemConduit", OreDictionary.WILDCARD_VALUE ), TunnelType.ITEM );
|
2014-09-24 02:26:27 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* attune based on lots of random item related stuff
|
|
|
|
*/
|
2014-12-29 15:13:47 +01:00
|
|
|
this.addNewAttunement( new ItemStack( Items.bucket ), TunnelType.FLUID );
|
|
|
|
this.addNewAttunement( new ItemStack( Items.lava_bucket ), TunnelType.FLUID );
|
|
|
|
this.addNewAttunement( new ItemStack( Items.milk_bucket ), TunnelType.FLUID );
|
|
|
|
this.addNewAttunement( new ItemStack( Items.water_bucket ), TunnelType.FLUID );
|
|
|
|
this.addNewAttunement( this.getModItem( "Mekanism", "MachineBlock2", 11 ), TunnelType.FLUID );
|
|
|
|
this.addNewAttunement( this.getModItem( "Mekanism", "PartTransmitter", 4 ), TunnelType.FLUID );
|
|
|
|
this.addNewAttunement( this.getModItem( "ExtraUtilities", "extractor_base", 6 ), TunnelType.FLUID );
|
|
|
|
this.addNewAttunement( this.getModItem( "ExtraUtilities", "drum", OreDictionary.WILDCARD_VALUE ), TunnelType.FLUID );
|
|
|
|
this.addNewAttunement( this.getModItem( "EnderIO", "itemLiquidConduit", OreDictionary.WILDCARD_VALUE ), TunnelType.FLUID );
|
2014-09-24 02:26:27 +02:00
|
|
|
|
|
|
|
for (AEColor c : AEColor.values())
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
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 );
|
2014-09-24 02:26:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void addNewAttunement(ItemStack trigger, TunnelType type)
|
|
|
|
{
|
|
|
|
if ( type == null || trigger == null )
|
|
|
|
return;
|
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
this.Tunnels.put( trigger, type );
|
2014-09-24 02:26:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public TunnelType getTunnelTypeByItem(ItemStack trigger)
|
|
|
|
{
|
|
|
|
if ( trigger != null )
|
|
|
|
{
|
|
|
|
if ( FluidContainerRegistry.isContainer( trigger ) )
|
|
|
|
return TunnelType.FLUID;
|
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
for (ItemStack is : this.Tunnels.keySet())
|
2014-09-24 02:26:27 +02:00
|
|
|
{
|
|
|
|
if ( is.getItem() == trigger.getItem() && is.getItemDamage() == OreDictionary.WILDCARD_VALUE )
|
2014-12-29 15:13:47 +01:00
|
|
|
return this.Tunnels.get( is );
|
2014-09-24 02:26:27 +02:00
|
|
|
|
|
|
|
if ( Platform.isSameItem( is, trigger ) )
|
2014-12-29 15:13:47 +01:00
|
|
|
return this.Tunnels.get( is );
|
2014-09-24 02:26:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|