make it work
This commit is contained in:
@@ -25,7 +25,6 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import appeng.helpers.NonBlockingItems;
|
||||
import com.google.common.base.Stopwatch;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
|
||||
@@ -8,21 +8,20 @@ import appeng.core.AEConfig;
|
||||
import appeng.core.AELog;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import gregtech.api.items.metaitem.MetaItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
||||
public class NonBlockingItems
|
||||
{
|
||||
public static final NonBlockingItems INSTANCE = new NonBlockingItems();
|
||||
public static Map<String, IItemList<IAEItemStack>> NON_BLOCKING_MAP;
|
||||
public static Map<String, IItemList<IAEItemStack>> NON_BLOCKING_MAP = new HashMap<>();
|
||||
public static NonBlockingItems INSTANCE = new NonBlockingItems();
|
||||
|
||||
NonBlockingItems()
|
||||
private NonBlockingItems()
|
||||
{
|
||||
NON_BLOCKING_MAP = new HashMap<>();
|
||||
String[] strings = AEConfig.instance().getNonBlockingItems();
|
||||
String modid = "";
|
||||
if( strings.length > 0 )
|
||||
@@ -62,11 +61,9 @@ public class NonBlockingItems
|
||||
}
|
||||
else
|
||||
{
|
||||
Item item = Item.getByNameOrId( ModItemMeta[0] + ":" + ModItemMeta[1] );
|
||||
if( item != null )
|
||||
ItemStack itemStack = GameRegistry.makeItemStack( ModItemMeta[0] + ":" + ModItemMeta[1], ModItemMeta.length == 3 ? Integer.parseInt( ModItemMeta[2] ) : 0, 1, null );
|
||||
if( !itemStack.isEmpty() )
|
||||
{
|
||||
ItemStack itemStack;
|
||||
itemStack = new ItemStack( item, 1, ModItemMeta.length == 3 ? Integer.parseInt( ModItemMeta[2] ) : 0 );
|
||||
NON_BLOCKING_MAP.get( modid ).add( AEItemStack.fromItemStack( itemStack ) );
|
||||
}
|
||||
else
|
||||
|
||||
@@ -30,16 +30,8 @@ public class BlockingItemHandler extends BlockingInventoryAdaptor
|
||||
boolean isBlockableItem( ItemStack stack )
|
||||
{
|
||||
IItemList<IAEItemStack> itemList = NonBlockingItems.INSTANCE.getMap().get( domain );
|
||||
if( stack.getItem().isDamageable() )
|
||||
{
|
||||
Collection<IAEItemStack> item = itemList.findFuzzy( AEItemStack.fromItemStack( stack ), FuzzyMode.IGNORE_ALL );
|
||||
return item.isEmpty();
|
||||
}
|
||||
else
|
||||
{
|
||||
IAEItemStack item = itemList.findPrecise( AEItemStack.fromItemStack( stack ) );
|
||||
return item == null;
|
||||
}
|
||||
Collection<IAEItemStack> item = itemList.findFuzzy( AEItemStack.fromItemStack( stack ), FuzzyMode.IGNORE_ALL );
|
||||
return item.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -22,72 +22,78 @@ import java.util.Objects;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
final class AESharedItemStack {
|
||||
|
||||
private final ItemStack itemStack;
|
||||
private final int itemId;
|
||||
private final int itemDamage;
|
||||
private final int hashCode;
|
||||
final class AESharedItemStack
|
||||
{
|
||||
|
||||
public AESharedItemStack(final ItemStack itemStack) {
|
||||
this(itemStack, itemStack.getItemDamage());
|
||||
}
|
||||
private final ItemStack itemStack;
|
||||
private final int itemDamage;
|
||||
private final int hashCode;
|
||||
|
||||
/**
|
||||
* A constructor to explicitly set the damage value and not fetch it from the {@link ItemStack}
|
||||
*
|
||||
* @param itemStack The {@link ItemStack} to filter
|
||||
* @param damage The damage of the item
|
||||
*/
|
||||
private AESharedItemStack(ItemStack itemStack, int damage) {
|
||||
this.itemStack = itemStack;
|
||||
this.itemId = Item.getIdFromItem(itemStack.getItem());
|
||||
this.itemDamage = damage;
|
||||
public AESharedItemStack( final ItemStack itemStack )
|
||||
{
|
||||
this( itemStack, itemStack.getItemDamage() );
|
||||
}
|
||||
|
||||
// Ensure this is always called last.
|
||||
this.hashCode = this.makeHashCode();
|
||||
}
|
||||
/**
|
||||
* A constructor to explicitly set the damage value and not fetch it from the {@link ItemStack}
|
||||
*
|
||||
* @param itemStack The {@link ItemStack} to filter
|
||||
* @param damage The damage of the item
|
||||
*/
|
||||
private AESharedItemStack( ItemStack itemStack, int damage )
|
||||
{
|
||||
this.itemStack = itemStack;
|
||||
this.itemDamage = damage;
|
||||
|
||||
ItemStack getDefinition() {
|
||||
return this.itemStack;
|
||||
}
|
||||
// Ensure this is always called last.
|
||||
this.hashCode = this.makeHashCode();
|
||||
}
|
||||
|
||||
int getItemDamage() {
|
||||
return this.itemDamage;
|
||||
}
|
||||
ItemStack getDefinition()
|
||||
{
|
||||
return this.itemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.hashCode;
|
||||
}
|
||||
int getItemDamage()
|
||||
{
|
||||
return this.itemDamage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof AESharedItemStack)) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return this.hashCode;
|
||||
}
|
||||
|
||||
final AESharedItemStack other = (AESharedItemStack) obj;
|
||||
Preconditions.checkState(this.itemStack.getCount() == 1, "ItemStack#getCount() has to be 1");
|
||||
Preconditions.checkArgument(other.getDefinition().getCount() == 1, "ItemStack#getCount() has to be 1");
|
||||
@Override
|
||||
public boolean equals( final Object obj )
|
||||
{
|
||||
if( this == obj )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if( !( obj instanceof AESharedItemStack ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.itemStack == other.itemStack) {
|
||||
return true;
|
||||
}
|
||||
return ItemStack.areItemStacksEqual(this.itemStack, other.itemStack);
|
||||
}
|
||||
final AESharedItemStack other = (AESharedItemStack) obj;
|
||||
Preconditions.checkState( this.itemStack.getCount() == 1, "ItemStack#getCount() has to be 1" );
|
||||
Preconditions.checkArgument( other.getDefinition().getCount() == 1, "ItemStack#getCount() has to be 1" );
|
||||
|
||||
private int makeHashCode() {
|
||||
return Objects.hash(
|
||||
this.itemId,
|
||||
this.itemDamage,
|
||||
this.itemStack.hasTagCompound() ? this.itemStack.getTagCompound() : 0);
|
||||
}
|
||||
if( this.itemStack == other.itemStack )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return ItemStack.areItemStacksEqual( this.itemStack, other.itemStack );
|
||||
}
|
||||
|
||||
private int makeHashCode()
|
||||
{
|
||||
return Objects.hash( this.itemStack.getItem(), this.itemDamage, this.itemStack.hasTagCompound() ? this.itemStack.getTagCompound() : 0 );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user