blocking mode changes again
misc cleaning
This commit is contained in:
@@ -1,86 +1,113 @@
|
||||
package appeng.helpers;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.storage.channels.IItemStorageChannel;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AELog;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import gregtech.api.items.metaitem.MetaItem;
|
||||
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
|
||||
import it.unimi.dsi.fastutil.ints.IntSet;
|
||||
import it.unimi.dsi.fastutil.objects.*;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
||||
public class NonBlockingItems
|
||||
{
|
||||
public static Map<String, IItemList<IAEItemStack>> NON_BLOCKING_MAP = new HashMap<>();
|
||||
public static Map<String, Object2ObjectOpenHashMap<Item, IntSet>> NON_BLOCKING_MAP = new HashMap<>();
|
||||
public static NonBlockingItems INSTANCE = new NonBlockingItems();
|
||||
|
||||
private NonBlockingItems()
|
||||
{
|
||||
String[] strings = AEConfig.instance().getNonBlockingItems();
|
||||
String modid = "";
|
||||
String[] modids = new String[0];
|
||||
if( strings.length > 0 )
|
||||
{
|
||||
for( String s : strings )
|
||||
{
|
||||
if( s.startsWith( "[" ) && s.endsWith( "]" ) )
|
||||
{
|
||||
modid = s.substring( 1, s.length() - 1 );
|
||||
modids = s.substring( 1, s.length() - 1 ).split( "\\|" );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( !Loader.isModLoaded( modid ) )
|
||||
for( String modid : modids )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
NON_BLOCKING_MAP.putIfAbsent( modid, AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList() );
|
||||
String[] ModItemMeta = s.split( ":" );
|
||||
|
||||
if( ModItemMeta.length < 2 || ModItemMeta.length > 3 )
|
||||
{
|
||||
AELog.error( "Invalid non blocking item entry: " + s );
|
||||
continue;
|
||||
}
|
||||
|
||||
if( ModItemMeta[0].equals( "gregtech" ) )
|
||||
{
|
||||
for( MetaItem<?> metaItem : MetaItem.getMetaItems() )
|
||||
if( !Loader.isModLoaded( modid ) )
|
||||
{
|
||||
MetaItem<?>.MetaValueItem metaItem2 = metaItem.getItem( ModItemMeta[1] );
|
||||
if( metaItem.getItem( ModItemMeta[1] ) != null )
|
||||
continue;
|
||||
}
|
||||
NON_BLOCKING_MAP.putIfAbsent( modid, new Object2ObjectOpenHashMap<>() );
|
||||
|
||||
String[] ModItemMeta = s.split( ":" );
|
||||
|
||||
if( ModItemMeta.length < 2 || ModItemMeta.length > 3 )
|
||||
{
|
||||
AELog.error( "Invalid non blocking item entry: " + s );
|
||||
continue;
|
||||
}
|
||||
|
||||
if( ModItemMeta[0].equals( "gregtech" ) )
|
||||
{
|
||||
for( MetaItem<?> metaItem : MetaItem.getMetaItems() )
|
||||
{
|
||||
NON_BLOCKING_MAP.get( modid ).add( AEItemStack.fromItemStack( metaItem2.getStackForm() ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemStack itemStack = GameRegistry.makeItemStack( ModItemMeta[0] + ":" + ModItemMeta[1], ModItemMeta.length == 3 ? Integer.parseInt( ModItemMeta[2] ) : 0, 1, null );
|
||||
if( !itemStack.isEmpty() )
|
||||
MetaItem<?>.MetaValueItem metaItem2 = metaItem.getItem( ModItemMeta[1] );
|
||||
if( metaItem.getItem( ModItemMeta[1] ) != null )
|
||||
{
|
||||
NON_BLOCKING_MAP.get( modid ).add( AEItemStack.fromItemStack( itemStack ) );
|
||||
ItemStack itemStack = metaItem2.getStackForm();
|
||||
NON_BLOCKING_MAP.get( modid ).putIfAbsent( itemStack.getItem(), new IntOpenHashSet() );
|
||||
NON_BLOCKING_MAP.get( modid ).computeIfPresent( itemStack.getItem(), ( item, intSet ) -> {
|
||||
intSet.add( itemStack.getItemDamage() );
|
||||
return intSet;
|
||||
} );
|
||||
}
|
||||
else
|
||||
{
|
||||
AELog.error( "Item not found on nonBlocking config: " + s );
|
||||
ItemStack itemStack = GameRegistry.makeItemStack( ModItemMeta[0] + ":" + ModItemMeta[1], ModItemMeta.length == 3 ? Integer.parseInt( ModItemMeta[2] ) : 0, 1, null );
|
||||
if( !itemStack.isEmpty() )
|
||||
{
|
||||
NON_BLOCKING_MAP.get( modid ).putIfAbsent( itemStack.getItem(), new IntOpenHashSet() );
|
||||
NON_BLOCKING_MAP.get( modid ).computeIfPresent( itemStack.getItem(), ( item, intSet ) -> {
|
||||
intSet.add( itemStack.getItemDamage() );
|
||||
return intSet;
|
||||
} );
|
||||
}
|
||||
else
|
||||
{
|
||||
AELog.error( "Item not found on nonBlocking config: " + s );
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemStack itemStack = GameRegistry.makeItemStack( ModItemMeta[0] + ":" + ModItemMeta[1], ModItemMeta.length == 3 ? Integer.parseInt( ModItemMeta[2] ) : 0, 1, null );
|
||||
if( !itemStack.isEmpty() )
|
||||
else if( ModItemMeta[0].equals( "ore" ) )
|
||||
{
|
||||
NON_BLOCKING_MAP.get( modid ).add( AEItemStack.fromItemStack( itemStack ) );
|
||||
OreDictionary.getOres( ModItemMeta[1] ).forEach( itemStack -> {
|
||||
NON_BLOCKING_MAP.get( modid ).putIfAbsent( itemStack.getItem(), new IntOpenHashSet() );
|
||||
NON_BLOCKING_MAP.get( modid ).computeIfPresent( itemStack.getItem(), ( item, intSet ) -> {
|
||||
intSet.add( itemStack.getItemDamage() );
|
||||
return intSet;
|
||||
} );
|
||||
} );
|
||||
}
|
||||
else
|
||||
{
|
||||
AELog.error( "Item not found on nonBlocking config: " + s );
|
||||
ItemStack itemStack = GameRegistry.makeItemStack( ModItemMeta[0] + ":" + ModItemMeta[1], ModItemMeta.length == 3 ? Integer.parseInt( ModItemMeta[2] ) : 0, 1, null );
|
||||
if( !itemStack.isEmpty() )
|
||||
{
|
||||
NON_BLOCKING_MAP.get( modid ).putIfAbsent( itemStack.getItem(), new IntOpenHashSet() );
|
||||
NON_BLOCKING_MAP.get( modid ).computeIfPresent( itemStack.getItem(), ( item, intSet ) -> {
|
||||
intSet.add( itemStack.getItemDamage() );
|
||||
return intSet;
|
||||
} );
|
||||
}
|
||||
else
|
||||
{
|
||||
AELog.error( "Item not found on nonBlocking config: " + s );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -88,7 +115,7 @@ public class NonBlockingItems
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, IItemList<IAEItemStack>> getMap()
|
||||
public Map<String, Object2ObjectOpenHashMap<Item, IntSet>> getMap()
|
||||
{
|
||||
return NON_BLOCKING_MAP;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user