diff --git a/gradle.properties b/gradle.properties index 2570f9543..2eee3232f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,7 +4,7 @@ aebuild=7 aegroup=appeng aebasename=appliedenergistics2 extended=extended_life -extendedversion=v0.54.4 +extendedversion=v0.54.6 ######################################################### # Versions # ######################################################### diff --git a/src/main/java/appeng/fluids/helper/DualityFluidInterface.java b/src/main/java/appeng/fluids/helper/DualityFluidInterface.java index 0871c792f..b4e4c98d5 100644 --- a/src/main/java/appeng/fluids/helper/DualityFluidInterface.java +++ b/src/main/java/appeng/fluids/helper/DualityFluidInterface.java @@ -266,7 +266,7 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable final Block directedBlock = directedBlockState.getBlock(); ItemStack what = new ItemStack(directedBlock, 1, directedBlock.getMetaFromState(directedBlockState)); - if (Loader.isModLoaded("gregtech") && directedBlock instanceof BlockMachine) { + if (Platform.GTLoaded && directedBlock instanceof BlockMachine) { MetaTileEntity metaTileEntity = Platform.getMetaTileEntity(directedTile.getWorld(), directedTile.getPos()); if (metaTileEntity != null) { return metaTileEntity.getMetaFullName(); diff --git a/src/main/java/appeng/helpers/DualityInterface.java b/src/main/java/appeng/helpers/DualityInterface.java index 5c5938fad..4fef63bf4 100644 --- a/src/main/java/appeng/helpers/DualityInterface.java +++ b/src/main/java/appeng/helpers/DualityInterface.java @@ -1105,7 +1105,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn final InventoryAdaptor ad = InventoryAdaptor.getAdaptor(te, s.getOpposite()); if (ad != null) { - if (Loader.isModLoaded("actuallyadditions") && Loader.isModLoaded("gregtech") && te instanceof IPhantomTile) { + if (Loader.isModLoaded("actuallyadditions") && Platform.GTLoaded && te instanceof IPhantomTile) { IPhantomTile phantomTE = ((IPhantomTile) te); if (phantomTE.hasBoundPosition()) { TileEntity phantom = w.getTileEntity(phantomTE.getBoundPosition()); @@ -1287,7 +1287,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn final Block directedBlock = directedBlockState.getBlock(); ItemStack what = new ItemStack(directedBlock, 1, directedBlock.getMetaFromState(directedBlockState)); - if (Loader.isModLoaded("gregtech") && directedBlock instanceof BlockMachine) { + if (Platform.GTLoaded && directedBlock instanceof BlockMachine) { MetaTileEntity metaTileEntity = Platform.getMetaTileEntity(directedTile.getWorld(), directedTile.getPos()); if (metaTileEntity != null) { return metaTileEntity.getMetaFullName(); diff --git a/src/main/java/appeng/helpers/NonBlockingItems.java b/src/main/java/appeng/helpers/NonBlockingItems.java index dfa4bd6bc..f5fabef76 100644 --- a/src/main/java/appeng/helpers/NonBlockingItems.java +++ b/src/main/java/appeng/helpers/NonBlockingItems.java @@ -42,7 +42,7 @@ public class NonBlockingItems { continue; } - if (ModItemMeta[0].equals("gregtech") && Platform.isModLoaded("gregtech")) { + if (ModItemMeta[0].equals("gregtech") && Platform.GTLoaded) { boolean found = false; for (MetaItem metaItem : MetaItem.getMetaItems()) { MetaItem.MetaValueItem metaItem2 = metaItem.getItem(ModItemMeta[1]); diff --git a/src/main/java/appeng/integration/modules/jei/JEIMissingItem.java b/src/main/java/appeng/integration/modules/jei/JEIMissingItem.java index d143d497c..0968f1041 100644 --- a/src/main/java/appeng/integration/modules/jei/JEIMissingItem.java +++ b/src/main/java/appeng/integration/modules/jei/JEIMissingItem.java @@ -14,7 +14,6 @@ import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.recipe.transfer.IRecipeTransferError; import mezz.jei.gui.recipes.RecipeLayout; import net.minecraft.client.Minecraft; -import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.item.ItemStack; import net.minecraftforge.items.IItemHandler; @@ -25,13 +24,19 @@ import java.awt.*; import java.util.ArrayList; import java.util.Collection; import java.util.List; -import java.util.stream.Collectors; import static mezz.jei.api.recipe.transfer.IRecipeTransferError.Type.USER_FACING; public class JEIMissingItem implements IRecipeTransferError { private boolean errored; + public long lastUpdate; + private final List craftableSlots = new ArrayList<>(); + private final List foundSlots = new ArrayList<>(); + + IItemList available = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList(); + + IItemList used = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList(); JEIMissingItem(Container container, @Nonnull IRecipeLayout recipeLayout) { if (container instanceof ContainerCraftingTerm) { @@ -110,31 +115,47 @@ public class JEIMissingItem implements IRecipeTransferError { int currentSlot = 0; this.errored = false; - IItemList available = mergeInventories(ir, (ContainerCraftingTerm) minecraft.player.openContainer); - - IItemList used = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList(); + if (System.currentTimeMillis() - lastUpdate > 1000) { + lastUpdate = System.currentTimeMillis(); + available = mergeInventories(ir, (ContainerCraftingTerm) minecraft.player.openContainer); + this.foundSlots.clear(); + this.craftableSlots.clear(); + } else { + for (IGuiIngredient i : recipeLayout.getItemStacks().getGuiIngredients().values()) { + if (i.isInput()) { + if (!foundSlots.contains(currentSlot)) { + if (craftableSlots.contains(currentSlot)) { + i.drawHighlight(minecraft, new Color(0.0f, 0.0f, 1.0f, 0.4f), recipeX, recipeY); + } else { + i.drawHighlight(minecraft, new Color(1.0f, 0.0f, 0.0f, 0.4f), recipeX, recipeY); + } + } + } + currentSlot++; + } + return; + } + this.used.resetStatus(); for (IGuiIngredient i : recipeLayout.getItemStacks().getGuiIngredients().values()) { found = false; craftable = false; - List valid = new ArrayList<>(); - if (i.isInput() && i.getAllIngredients().size() > 0) { + ArrayList valid = new ArrayList<>(); + if (i.isInput()) { List allIngredients = i.getAllIngredients(); for (Object allIngredient : allIngredients) { if (allIngredient instanceof ItemStack) { ItemStack stack = (ItemStack) allIngredient; if (!stack.isEmpty()) { + IAEItemStack search = AEItemStack.fromItemStack(stack); if (stack.getItem().isDamageable() || Platform.isGTDamageableItem(stack.getItem())) { - Collection fuzzy = available.findFuzzy(AEItemStack.fromItemStack(stack), FuzzyMode.IGNORE_ALL); + Collection fuzzy = available.findFuzzy(search, FuzzyMode.IGNORE_ALL); if (fuzzy.size() > 0) { for (IAEItemStack itemStack : fuzzy) { if (itemStack.getStackSize() > 0) { - if (itemStack.fuzzyComparison(AEItemStack.fromItemStack(stack), FuzzyMode.IGNORE_ALL)) { - found = true; - used.add(itemStack.copy().setStackSize(1)); - valid.addAll(fuzzy.stream().map(IAEItemStack::createItemStack).collect(Collectors.toList())); - break; - } + found = true; + used.add(itemStack.copy().setStackSize(1)); + valid.add(itemStack.copy().setStackSize(1).createItemStack()); } else { if (itemStack.isCraftable()) { craftable = true; @@ -143,7 +164,7 @@ public class JEIMissingItem implements IRecipeTransferError { } } } else { - IAEItemStack ext = available.findPrecise(AEItemStack.fromItemStack(stack)); + IAEItemStack ext = available.findPrecise(search); if (ext != null) { IAEItemStack usedStack = used.findPrecise(ext); if (ext.getStackSize() > 0 && (usedStack == null || usedStack.getStackSize() < ext.getStackSize())) { @@ -159,20 +180,26 @@ public class JEIMissingItem implements IRecipeTransferError { } } } + } else { + found = true; } } } + if (i.getAllIngredients().size() == 0) { + found = true; + } if (!found) { if (craftable) { i.drawHighlight(minecraft, new Color(0.0f, 0.0f, 1.0f, 0.4f), recipeX, recipeY); + this.craftableSlots.add(currentSlot); recipeLayout.getItemStacks().set(currentSlot, valid); } else { i.drawHighlight(minecraft, new Color(1.0f, 0.0f, 0.0f, 0.4f), recipeX, recipeY); } this.errored = true; } else { + this.foundSlots.add(currentSlot); recipeLayout.getItemStacks().set(currentSlot, valid); - this.errored = false; } } currentSlot++; @@ -183,10 +210,6 @@ public class JEIMissingItem implements IRecipeTransferError { } } - public boolean errored() { - return this.errored; - } - IItemList mergeInventories(IItemList repo, ContainerCraftingTerm containerCraftingTerm) { IItemList itemList = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList(); for (IAEItemStack i : repo) { @@ -204,4 +227,8 @@ public class JEIMissingItem implements IRecipeTransferError { } return itemList; } + + public boolean errored() { + return errored; + } } diff --git a/src/main/java/appeng/util/Platform.java b/src/main/java/appeng/util/Platform.java index 439244797..53654b058 100644 --- a/src/main/java/appeng/util/Platform.java +++ b/src/main/java/appeng/util/Platform.java @@ -146,6 +146,7 @@ public class Platform { private static final ItemComparisonHelper ITEM_COMPARISON_HELPER = new ItemComparisonHelper(); private static final P2PHelper P2P_HELPER = new P2PHelper(); private static Method reflectGTgetMTE; + public static final boolean GTLoaded = isModLoaded("gregtech"); public static ItemComparisonHelper itemComparisons() { return ITEM_COMPARISON_HELPER; @@ -1416,7 +1417,7 @@ public class Platform { //consider methods below moving to a compability class public static boolean isGTDamageableItem(Item item) { - return (isModLoaded("gregtech") && item instanceof IToolItem); + return ((GTLoaded) && item instanceof IToolItem); } public static MetaTileEntity getMetaTileEntity(IBlockAccess world, BlockPos pos) {