blocking mode changes again
misc cleaning
This commit is contained in:
@@ -87,6 +87,7 @@ public final class AEConfig extends Configuration implements IConfigurableObject
|
|||||||
"gregtech:shape.extruder.ingot", "gregtech:shape.extruder.wire",
|
"gregtech:shape.extruder.ingot", "gregtech:shape.extruder.wire",
|
||||||
"gregtech:shape.extruder.pipe.tiny",
|
"gregtech:shape.extruder.pipe.tiny",
|
||||||
"gregtech:shape.extruder.pipe.small",
|
"gregtech:shape.extruder.pipe.small",
|
||||||
|
"gregtech:shape.extruder.pipe.medium",
|
||||||
"gregtech:shape.extruder.pipe.normal",
|
"gregtech:shape.extruder.pipe.normal",
|
||||||
"gregtech:shape.extruder.pipe.large",
|
"gregtech:shape.extruder.pipe.large",
|
||||||
"gregtech:shape.extruder.pipe.huge",
|
"gregtech:shape.extruder.pipe.huge",
|
||||||
|
|||||||
@@ -1329,7 +1329,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !ad.simulateAdd( is.copy() ).isEmpty() )
|
if( !ad.simulateAdd( is ).isEmpty() )
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,44 +1,47 @@
|
|||||||
package appeng.helpers;
|
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.AEConfig;
|
||||||
import appeng.core.AELog;
|
import appeng.core.AELog;
|
||||||
import appeng.util.item.AEItemStack;
|
|
||||||
import gregtech.api.items.metaitem.MetaItem;
|
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.minecraft.item.ItemStack;
|
||||||
import net.minecraftforge.fml.common.Loader;
|
import net.minecraftforge.fml.common.Loader;
|
||||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||||
|
import net.minecraftforge.oredict.OreDictionary;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
|
||||||
public class NonBlockingItems
|
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();
|
public static NonBlockingItems INSTANCE = new NonBlockingItems();
|
||||||
|
|
||||||
private NonBlockingItems()
|
private NonBlockingItems()
|
||||||
{
|
{
|
||||||
String[] strings = AEConfig.instance().getNonBlockingItems();
|
String[] strings = AEConfig.instance().getNonBlockingItems();
|
||||||
String modid = "";
|
String[] modids = new String[0];
|
||||||
if( strings.length > 0 )
|
if( strings.length > 0 )
|
||||||
{
|
{
|
||||||
for( String s : strings )
|
for( String s : strings )
|
||||||
{
|
{
|
||||||
if( s.startsWith( "[" ) && s.endsWith( "]" ) )
|
if( s.startsWith( "[" ) && s.endsWith( "]" ) )
|
||||||
{
|
{
|
||||||
modid = s.substring( 1, s.length() - 1 );
|
modids = s.substring( 1, s.length() - 1 ).split( "\\|" );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
for( String modid : modids )
|
||||||
{
|
{
|
||||||
if( !Loader.isModLoaded( modid ) )
|
if( !Loader.isModLoaded( modid ) )
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
NON_BLOCKING_MAP.putIfAbsent( modid, AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList() );
|
NON_BLOCKING_MAP.putIfAbsent( modid, new Object2ObjectOpenHashMap<>() );
|
||||||
|
|
||||||
String[] ModItemMeta = s.split( ":" );
|
String[] ModItemMeta = s.split( ":" );
|
||||||
|
|
||||||
if( ModItemMeta.length < 2 || ModItemMeta.length > 3 )
|
if( ModItemMeta.length < 2 || ModItemMeta.length > 3 )
|
||||||
@@ -54,14 +57,23 @@ public class NonBlockingItems
|
|||||||
MetaItem<?>.MetaValueItem metaItem2 = metaItem.getItem( ModItemMeta[1] );
|
MetaItem<?>.MetaValueItem metaItem2 = metaItem.getItem( ModItemMeta[1] );
|
||||||
if( metaItem.getItem( ModItemMeta[1] ) != null )
|
if( metaItem.getItem( ModItemMeta[1] ) != null )
|
||||||
{
|
{
|
||||||
NON_BLOCKING_MAP.get( modid ).add( AEItemStack.fromItemStack( metaItem2.getStackForm() ) );
|
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
|
else
|
||||||
{
|
{
|
||||||
ItemStack itemStack = GameRegistry.makeItemStack( ModItemMeta[0] + ":" + ModItemMeta[1], ModItemMeta.length == 3 ? Integer.parseInt( ModItemMeta[2] ) : 0, 1, null );
|
ItemStack itemStack = GameRegistry.makeItemStack( ModItemMeta[0] + ":" + ModItemMeta[1], ModItemMeta.length == 3 ? Integer.parseInt( ModItemMeta[2] ) : 0, 1, null );
|
||||||
if( !itemStack.isEmpty() )
|
if( !itemStack.isEmpty() )
|
||||||
{
|
{
|
||||||
NON_BLOCKING_MAP.get( modid ).add( AEItemStack.fromItemStack( 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
|
else
|
||||||
{
|
{
|
||||||
@@ -71,12 +83,26 @@ public class NonBlockingItems
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if( ModItemMeta[0].equals( "ore" ) )
|
||||||
|
{
|
||||||
|
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
|
else
|
||||||
{
|
{
|
||||||
ItemStack itemStack = GameRegistry.makeItemStack( ModItemMeta[0] + ":" + ModItemMeta[1], ModItemMeta.length == 3 ? Integer.parseInt( ModItemMeta[2] ) : 0, 1, null );
|
ItemStack itemStack = GameRegistry.makeItemStack( ModItemMeta[0] + ":" + ModItemMeta[1], ModItemMeta.length == 3 ? Integer.parseInt( ModItemMeta[2] ) : 0, 1, null );
|
||||||
if( !itemStack.isEmpty() )
|
if( !itemStack.isEmpty() )
|
||||||
{
|
{
|
||||||
NON_BLOCKING_MAP.get( modid ).add( AEItemStack.fromItemStack( 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
|
else
|
||||||
{
|
{
|
||||||
@@ -87,8 +113,9 @@ public class NonBlockingItems
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Map<String, IItemList<IAEItemStack>> getMap()
|
public Map<String, Object2ObjectOpenHashMap<Item, IntSet>> getMap()
|
||||||
{
|
{
|
||||||
return NON_BLOCKING_MAP;
|
return NON_BLOCKING_MAP;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -300,24 +300,17 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest
|
|||||||
if( mode == Actionable.SIMULATE )
|
if( mode == Actionable.SIMULATE )
|
||||||
{
|
{
|
||||||
remaining = d.simulateAdd( inputStack );
|
remaining = d.simulateAdd( inputStack );
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
remaining = d.addItems( inputStack );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Store the stack in the cache for next time.
|
|
||||||
if( mode == Actionable.SIMULATE )
|
|
||||||
{
|
|
||||||
items.setCachedItemStack( inputStack );
|
items.setCachedItemStack( inputStack );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
remaining = d.addItems( inputStack );
|
||||||
if( !remaining.isEmpty() )
|
if( !remaining.isEmpty() )
|
||||||
{
|
{
|
||||||
items.setCachedItemStack( remaining );
|
items.setCachedItemStack( remaining );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( remaining == inputStack )
|
if( remaining == inputStack )
|
||||||
{
|
{
|
||||||
return items;
|
return items;
|
||||||
|
|||||||
@@ -7,6 +7,10 @@ import appeng.helpers.NonBlockingItems;
|
|||||||
import appeng.util.Platform;
|
import appeng.util.Platform;
|
||||||
import appeng.util.item.AEItemStack;
|
import appeng.util.item.AEItemStack;
|
||||||
import gregtech.common.items.MetaTool;
|
import gregtech.common.items.MetaTool;
|
||||||
|
import it.unimi.dsi.fastutil.ints.IntSet;
|
||||||
|
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||||
|
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
|
|
||||||
@@ -27,17 +31,12 @@ public class BlockingItemHandler extends BlockingInventoryAdaptor
|
|||||||
|
|
||||||
boolean isBlockableItem( ItemStack stack )
|
boolean isBlockableItem( ItemStack stack )
|
||||||
{
|
{
|
||||||
IItemList<IAEItemStack> itemList = NonBlockingItems.INSTANCE.getMap().get( domain );
|
Object2ObjectOpenHashMap<Item, IntSet> map = NonBlockingItems.INSTANCE.getMap().get( domain );
|
||||||
if( stack.getItem().isDamageable() || ( Platform.isModLoaded( "gregtech" ) && stack.getItem() instanceof MetaTool ) )
|
if( map.get( stack.getItem() ) != null )
|
||||||
{
|
{
|
||||||
Collection<IAEItemStack> item = itemList.findFuzzy( AEItemStack.fromItemStack( stack ), FuzzyMode.IGNORE_ALL );
|
return !map.get( stack.getItem() ).contains( stack.getItemDamage() );
|
||||||
return item.isEmpty();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
IAEItemStack item = itemList.findPrecise( AEItemStack.fromItemStack( stack ) );
|
|
||||||
return item == null;
|
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user