Skip to content

Commit

Permalink
More JEI integration
Browse files Browse the repository at this point in the history
  • Loading branch information
PrototypeTrousers committed Feb 22, 2021
1 parent 7796c6d commit ea54ccb
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/main/java/appeng/core/sync/packets/PacketJEIRecipe.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.Collection;
import java.util.Iterator;

import appeng.api.config.FuzzyMode;
import appeng.api.storage.data.IItemList;
import appeng.container.implementations.ContainerPatternTerm;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
Expand Down Expand Up @@ -208,7 +210,7 @@ public void serverPacketData( final INetworkInfo manager, final AppEngPacket pac
IAEItemStack mostDamaged = null;
for( IAEItemStack is : outList )
{
if (!is.isCraftable())
if( !is.isCraftable() )
{
if( mostDamaged == null || mostDamaged.getItemDamage() < is.getItemDamage() )
{
Expand All @@ -235,6 +237,22 @@ public void serverPacketData( final INetworkInfo manager, final AppEngPacket pac
// Fall back using an existing item
out = storage.extractItems( request, Actionable.SIMULATE, cct.getActionSource() );
}

if( out == null )
{
IItemList<IAEItemStack> items = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList();
Iterator<IAEItemStack> iterator = inv.getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ).getAvailableItems( items ).iterator();
while ( iterator.hasNext() )
{
final IAEItemStack o = iterator.next();
if( o.getDefinition().isItemEqual( request.getDefinition() ) && o.isCraftable() )
{
out = o;
break;
}
iterator.remove();
}
}
}

if( out != null )
Expand Down

0 comments on commit ea54ccb

Please sign in to comment.