From c43cbbef434fcb5bfcb695d959c2a91f354378fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Salom=C3=A3o?= Date: Sun, 14 Feb 2021 02:14:15 -0300 Subject: [PATCH] Switched JEI search to crafting terminal to fuzzy mode --- .../core/sync/packets/PacketJEIRecipe.java | 34 +++++++++++++++---- 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/src/main/java/appeng/core/sync/packets/PacketJEIRecipe.java b/src/main/java/appeng/core/sync/packets/PacketJEIRecipe.java index e2367012f..caccabae8 100644 --- a/src/main/java/appeng/core/sync/packets/PacketJEIRecipe.java +++ b/src/main/java/appeng/core/sync/packets/PacketJEIRecipe.java @@ -23,7 +23,9 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; import java.io.IOException; +import java.util.Collection; +import appeng.api.config.FuzzyMode; import appeng.container.implementations.ContainerPatternTerm; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; @@ -200,6 +202,26 @@ public class PacketJEIRecipe extends AppEngPacket if( cct.useRealItems() ) { out = Platform.poweredExtraction( energy, storage, request, cct.getActionSource() ); + if( out == null ) + { + Collection outList = inv.getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ).getStorageList().findFuzzy( request, FuzzyMode.IGNORE_ALL ); + IAEItemStack mostDamaged = null; + for( IAEItemStack is : outList ) + { + if (!is.isCraftable()) + { + if( mostDamaged == null || mostDamaged.getItemDamage() < is.getItemDamage() ) + { + mostDamaged = is; + } + } + } + if( mostDamaged != null ) + { + mostDamaged.setStackSize( 1 ); + out = Platform.poweredExtraction( energy, storage, mostDamaged, cct.getActionSource() ); + } + } } else { @@ -228,17 +250,17 @@ public class PacketJEIRecipe extends AppEngPacket if( cct.useRealItems() ) { - currentItem = ad.removeItems( 1, this.recipe[x][y], null ); + currentItem = ad.removeSimilarItems(1, this.recipe[x][y],FuzzyMode.IGNORE_ALL, null ); } else { - currentItem = ad.simulateRemove( 1, this.recipe[x][y], null ); + currentItem = ad.simulateSimilarRemove(1, this.recipe[x][y],FuzzyMode.IGNORE_ALL, null ); + if( currentItem.isEmpty() ) + { + currentItem = this.recipe[x][y]; + } } } - if( currentItem.isEmpty() && con instanceof ContainerPatternTerm ) - { - currentItem = this.recipe[x][y].copy(); - } } } }