More damaged item search work. GT tools are so special
This commit is contained in:
+1
-1
@@ -4,7 +4,7 @@ aebuild=7
|
||||
aegroup=appeng
|
||||
aebasename=appliedenergistics2
|
||||
extended=extended_life
|
||||
extendedversion=v0.54.6
|
||||
extendedversion=v0.54.7
|
||||
#########################################################
|
||||
# Versions #
|
||||
#########################################################
|
||||
|
||||
@@ -197,9 +197,12 @@ public class PacketJEIRecipe extends AppEngPacket {
|
||||
if (request.getItem().isDamageable() || Platform.isGTDamageableItem(request.getItem())) {
|
||||
Collection<IAEItemStack> outList = inv.getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)).getStorageList().findFuzzy(request, FuzzyMode.IGNORE_ALL);
|
||||
for (IAEItemStack is : outList) {
|
||||
if (is.getDefinition().getMetadata() == request.getDefinition().getMetadata()) {
|
||||
out = Platform.poweredExtraction(energy, storage, is.copy().setStackSize(1), cct.getActionSource());
|
||||
if (Platform.isGTDamageableItem(request.getItem())) {
|
||||
if (!(is.getDefinition().getMetadata() == request.getDefinition().getMetadata())) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
out = Platform.poweredExtraction(energy, storage, is.copy().setStackSize(1), cct.getActionSource());
|
||||
if (out != null) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1,19 +1,27 @@
|
||||
package appeng.integration.modules.jei;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.storage.channels.IItemStorageChannel;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.implementations.ContainerCraftingTerm;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketInventoryAction;
|
||||
import appeng.helpers.InventoryAction;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import com.google.common.base.Stopwatch;
|
||||
import mezz.jei.api.gui.ITooltipCallback;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.wrapper.PlayerMainInvWrapper;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@@ -32,26 +40,81 @@ public class CraftableCallBack implements ITooltipCallback<ItemStack> {
|
||||
public void onTooltip(int slotIndex, boolean input, ItemStack ingredient, List<String> tooltip) {
|
||||
if (!input) return;
|
||||
if (list != null) {
|
||||
IAEItemStack found = list.findPrecise(AEItemStack.fromItemStack(ingredient));
|
||||
if (found != null) {
|
||||
if (found.getStackSize() == 0) {
|
||||
|
||||
IItemList<IAEItemStack> available = mergeInventories(list, (ContainerCraftingTerm) container);
|
||||
|
||||
IAEItemStack search = AEItemStack.fromItemStack(ingredient);
|
||||
if (ingredient.getItem().isDamageable() || Platform.isGTDamageableItem(ingredient.getItem())) {
|
||||
Collection<IAEItemStack> fuzzy = available.findFuzzy(search, FuzzyMode.IGNORE_ALL);
|
||||
if (fuzzy.size() > 0) {
|
||||
for (IAEItemStack itemStack : fuzzy) {
|
||||
if (itemStack.getStackSize() > 0) {
|
||||
if (Platform.isGTDamageableItem(ingredient.getItem())) {
|
||||
if (!(ingredient.getMetadata() == itemStack.getDefinition().getMetadata())) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
} else {
|
||||
String line = "§c[" + I18n.translateToLocalFormatted("gui.appliedenergistics2.Missing") + "]";
|
||||
tooltip.add(line);
|
||||
if (itemStack.isCraftable()) {
|
||||
line = "§1[" + I18n.translateToLocalFormatted("gui.tooltips.appliedenergistics2.Craftable") + "]";
|
||||
tooltip.add(line);
|
||||
if (Mouse.isButtonDown(2) && this.lastClicked.elapsed(TimeUnit.MILLISECONDS) > 200) {
|
||||
this.lastClicked.reset().start();
|
||||
((AEBaseContainer) container).setTargetStack(itemStack);
|
||||
final PacketInventoryAction p = new PacketInventoryAction(InventoryAction.AUTO_CRAFT, container.getInventory().size(), 0);
|
||||
NetworkHandler.instance().sendToServer(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
String line = "§c[" + I18n.translateToLocalFormatted("gui.appliedenergistics2.Missing") + "]";
|
||||
tooltip.add(line);
|
||||
}
|
||||
if (found.isCraftable()) {
|
||||
String line = "§1[" + I18n.translateToLocalFormatted("gui.tooltips.appliedenergistics2.Craftable") + "]";
|
||||
tooltip.add(line);
|
||||
if (Mouse.isButtonDown(2) && this.lastClicked.elapsed(TimeUnit.MILLISECONDS) > 200) {
|
||||
this.lastClicked.reset().start();
|
||||
((AEBaseContainer) container).setTargetStack(found);
|
||||
final PacketInventoryAction p = new PacketInventoryAction(InventoryAction.AUTO_CRAFT, container.getInventory().size(), 0);
|
||||
NetworkHandler.instance().sendToServer(p);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
String line = "§c[" + I18n.translateToLocalFormatted("gui.appliedenergistics2.Missing") + "]";
|
||||
tooltip.add(line);
|
||||
IAEItemStack found = available.findPrecise(search);
|
||||
if (found != null) {
|
||||
if (found.getStackSize() == 0) {
|
||||
String line = "§c[" + I18n.translateToLocalFormatted("gui.appliedenergistics2.Missing") + "]";
|
||||
tooltip.add(line);
|
||||
}
|
||||
if (found.isCraftable()) {
|
||||
String line = "§1[" + I18n.translateToLocalFormatted("gui.tooltips.appliedenergistics2.Craftable") + "]";
|
||||
tooltip.add(line);
|
||||
if (Mouse.isButtonDown(2) && this.lastClicked.elapsed(TimeUnit.MILLISECONDS) > 200) {
|
||||
this.lastClicked.reset().start();
|
||||
((AEBaseContainer) container).setTargetStack(found);
|
||||
final PacketInventoryAction p = new PacketInventoryAction(InventoryAction.AUTO_CRAFT, container.getInventory().size(), 0);
|
||||
NetworkHandler.instance().sendToServer(p);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
String line = "§c[" + I18n.translateToLocalFormatted("gui.appliedenergistics2.Missing") + "]";
|
||||
tooltip.add(line);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IItemList<IAEItemStack> mergeInventories(IItemList<IAEItemStack> repo, ContainerCraftingTerm containerCraftingTerm) {
|
||||
IItemList<IAEItemStack> itemList = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
|
||||
for (IAEItemStack i : repo) {
|
||||
itemList.addStorage(i);
|
||||
}
|
||||
|
||||
PlayerMainInvWrapper invWrapper = new PlayerMainInvWrapper(containerCraftingTerm.getPlayerInv());
|
||||
for (int i = 0; i < invWrapper.getSlots(); i++) {
|
||||
itemList.addStorage(AEItemStack.fromItemStack(invWrapper.getStackInSlot(i)));
|
||||
}
|
||||
|
||||
IItemHandler itemHandler = containerCraftingTerm.getInventoryByName("crafting");
|
||||
for (int i = 0; i < itemHandler.getSlots(); i++) {
|
||||
itemList.addStorage(AEItemStack.fromItemStack(itemHandler.getStackInSlot(i)));
|
||||
}
|
||||
return itemList;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,20 +60,24 @@ public class JEIMissingItem implements IRecipeTransferError {
|
||||
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<IAEItemStack> fuzzy = available.findFuzzy(AEItemStack.fromItemStack(stack), FuzzyMode.IGNORE_ALL);
|
||||
Collection<IAEItemStack> 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;
|
||||
break;
|
||||
if (Platform.isGTDamageableItem(stack.getItem())) {
|
||||
if (!(stack.getMetadata() == itemStack.getDefinition().getMetadata())) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} 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 || ext.getStackSize() > usedStack.getStackSize())) {
|
||||
@@ -153,6 +157,11 @@ public class JEIMissingItem implements IRecipeTransferError {
|
||||
if (fuzzy.size() > 0) {
|
||||
for (IAEItemStack itemStack : fuzzy) {
|
||||
if (itemStack.getStackSize() > 0) {
|
||||
if (Platform.isGTDamageableItem(stack.getItem())) {
|
||||
if (!(stack.getMetadata() == itemStack.getDefinition().getMetadata())) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
found = true;
|
||||
used.add(itemStack.copy().setStackSize(1));
|
||||
valid.add(itemStack.copy().setStackSize(1).createItemStack());
|
||||
|
||||
Reference in New Issue
Block a user