@Override public Collection<IAEItemStack> findFuzzy( final IAEItemStack filter, final FuzzyMode fuzzy ) { if( filter == null ) { return Collections.emptyList(); } final AEItemStack ais = (AEItemStack) filter; return ais.getOre().map( or -> { if( or.getAEEquivalents().size() == 1 ) { final IAEItemStack is = or.getAEEquivalents().get( 0 ); return this.findFuzzyDamage( is, fuzzy, is.getItemDamage() == OreDictionary.WILDCARD_VALUE ); } else { final Collection<IAEItemStack> output = new ArrayList<>(); for( final IAEItemStack is : or.getAEEquivalents() ) { output.addAll( this.findFuzzyDamage( is, fuzzy, is.getItemDamage() == OreDictionary.WILDCARD_VALUE ) ); } return output; } } ).orElse( this.findFuzzyDamage( ais, fuzzy, false ) ); }
@Override public ImmutableCollection<ICraftingPatternDetails> getCraftingFor( final IAEItemStack whatToCraft, final ICraftingPatternDetails details, final int slotIndex, final World world ) { final ImmutableList<ICraftingPatternDetails> res = this.craftableItems.get( whatToCraft ); if( res == null ) { if( details != null && details.isCraftable() ) { for( final IAEItemStack ais : this.craftableItems.keySet() ) { if( ais.getItem() == whatToCraft.getItem() && ( !ais.getItem().getHasSubtypes() || ais.getItemDamage() == whatToCraft.getItemDamage() ) ) { // TODO: check if OK // TODO: this is slightly hacky, but fine as long as we only deal with itemstacks if( details.isValidItemForSlot( slotIndex, ais.asItemStackRepresentation(), world ) ) { return this.craftableItems.get( ais ); } } } } return ImmutableSet.of(); } return res; }
@Override public boolean isBlackListed( final ItemStack cellItem, final IAEItemStack requestedAddition ) { if( requestedAddition != null ) { final int[] id = OreDictionary.getOreIDs( requestedAddition.getDefinition() ); for( final int x : id ) { if( ORE_TO_COLOR.containsKey( x ) ) { return false; } } if( requestedAddition.getItem() instanceof ItemSnowball ) { return false; } return !( requestedAddition.getItem() instanceof ItemPaintBall && requestedAddition.getItemDamage() < 20 ); } return true; }
Collections.sort( list, ( a, b ) -> Integer.compare( a.getItemDamage(), b.getItemDamage() ) );
IAEItemStack getAmountCrafted( IAEItemStack what2 ) { for( final IAEItemStack is : this.details.getCondensedOutputs() ) { if( is.equals( what2 ) ) { what2 = what2.copy(); what2.setStackSize( is.getStackSize() ); return what2; } } // more fuzzy! for( final IAEItemStack is : this.details.getCondensedOutputs() ) { if( is.getItem() == what2.getItem() && ( is.getItem().isDamageable() || is.getItemDamage() == what2.getItemDamage() ) ) { what2 = is.copy(); what2.setStackSize( is.getStackSize() ); return what2; } } throw new IllegalStateException( "Crafting Tree construction failed." ); }