fix JEI integration
This commit is contained in:
@@ -82,8 +82,4 @@ public class GuiCraftingTerm extends GuiMEMonitorable {
|
||||
protected String getBackground() {
|
||||
return "guis/crafting.png";
|
||||
}
|
||||
|
||||
public ItemRepo getRepo() {
|
||||
return this.repo;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,8 +90,4 @@ public class GuiWirelessCraftingTerminal extends GuiMEMonitorable {
|
||||
protected String getBackground() {
|
||||
return "guis/crafting.png";
|
||||
}
|
||||
|
||||
public ItemRepo getRepo() {
|
||||
return this.repo;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa
|
||||
|
||||
if (monitorable instanceof IPortableCell) {
|
||||
this.setPowerSource((IEnergySource) monitorable);
|
||||
if ( monitorable instanceof WirelessTerminalGuiObject) {
|
||||
if (monitorable instanceof WirelessTerminalGuiObject) {
|
||||
this.networkNode = ((WirelessTerminalGuiObject) monitorable).getActionableNode();
|
||||
}
|
||||
} else if (monitorable instanceof IMEChest) {
|
||||
@@ -381,6 +381,9 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa
|
||||
}
|
||||
|
||||
public void postUpdate(final List<IAEItemStack> list) {
|
||||
for (final IAEItemStack is : list) {
|
||||
this.items.add(is);
|
||||
}
|
||||
((GuiMEMonitorable) this.gui).postUpdate(list);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,8 +7,10 @@ import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.implementations.ContainerCraftingTerm;
|
||||
import appeng.container.implementations.ContainerMEMonitorable;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketInventoryAction;
|
||||
import appeng.helpers.IContainerCraftingPacket;
|
||||
import appeng.helpers.InventoryAction;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEItemStack;
|
||||
@@ -41,7 +43,7 @@ public class CraftableCallBack implements ITooltipCallback<ItemStack> {
|
||||
if (!input) return;
|
||||
if (list != null) {
|
||||
|
||||
IItemList<IAEItemStack> available = mergeInventories(list, (ContainerCraftingTerm) container);
|
||||
IItemList<IAEItemStack> available = mergeInventories(list, (ContainerMEMonitorable) container);
|
||||
|
||||
IAEItemStack search = AEItemStack.fromItemStack(ingredient);
|
||||
if (ingredient.getItem().isDamageable() || Platform.isGTDamageableItem(ingredient.getItem())) {
|
||||
@@ -100,7 +102,7 @@ public class CraftableCallBack implements ITooltipCallback<ItemStack> {
|
||||
}
|
||||
}
|
||||
|
||||
IItemList<IAEItemStack> mergeInventories(IItemList<IAEItemStack> repo, ContainerCraftingTerm containerCraftingTerm) {
|
||||
IItemList<IAEItemStack> mergeInventories(IItemList<IAEItemStack> repo, ContainerMEMonitorable containerCraftingTerm) {
|
||||
IItemList<IAEItemStack> itemList = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
|
||||
for (IAEItemStack i : repo) {
|
||||
itemList.addStorage(i);
|
||||
@@ -111,9 +113,11 @@ public class CraftableCallBack implements ITooltipCallback<ItemStack> {
|
||||
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)));
|
||||
if (containerCraftingTerm instanceof IContainerCraftingPacket) {
|
||||
IItemHandler itemHandler = ((IContainerCraftingPacket) containerCraftingTerm).getInventoryByName("crafting");
|
||||
for (int i = 0; i < itemHandler.getSlots(); i++) {
|
||||
itemList.addStorage(AEItemStack.fromItemStack(itemHandler.getStackInSlot(i)));
|
||||
}
|
||||
}
|
||||
return itemList;
|
||||
}
|
||||
|
||||
@@ -2,11 +2,17 @@ package appeng.integration.modules.jei;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.implementations.tiles.ISegmentedInventory;
|
||||
import appeng.api.storage.channels.IItemStorageChannel;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.client.gui.implementations.GuiCraftingTerm;
|
||||
import appeng.client.gui.implementations.GuiWirelessCraftingTerminal;
|
||||
import appeng.container.implementations.ContainerCraftingTerm;
|
||||
import appeng.container.implementations.ContainerMEMonitorable;
|
||||
import appeng.container.implementations.ContainerWirelessCraftingTerminal;
|
||||
import appeng.helpers.IContainerCraftingPacket;
|
||||
import appeng.util.IConfigManagerHost;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import mezz.jei.api.gui.IGuiIngredient;
|
||||
@@ -39,13 +45,10 @@ public class JEIMissingItem implements IRecipeTransferError {
|
||||
IItemList<IAEItemStack> used = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
|
||||
|
||||
JEIMissingItem(Container container, @Nonnull IRecipeLayout recipeLayout) {
|
||||
if (container instanceof ContainerCraftingTerm) {
|
||||
ContainerCraftingTerm craftingTerm = (ContainerCraftingTerm) container;
|
||||
GuiCraftingTerm g = (GuiCraftingTerm) craftingTerm.getGui();
|
||||
|
||||
IItemList<IAEItemStack> ir = g.getRepo().getList();
|
||||
|
||||
IItemList<IAEItemStack> available = mergeInventories(ir, (ContainerCraftingTerm) container);
|
||||
if (container instanceof ContainerMEMonitorable) {
|
||||
IItemList<IAEItemStack> ir = ((ContainerMEMonitorable) container).items;
|
||||
|
||||
IItemList<IAEItemStack> available = mergeInventories(ir, (ContainerMEMonitorable) container);
|
||||
|
||||
boolean found;
|
||||
this.errored = false;
|
||||
@@ -109,11 +112,9 @@ public class JEIMissingItem implements IRecipeTransferError {
|
||||
@Override
|
||||
public void showError(Minecraft minecraft, int mouseX, int mouseY, @Nonnull IRecipeLayout recipeLayout, int recipeX, int recipeY) {
|
||||
Container c = minecraft.player.openContainer;
|
||||
if (c instanceof ContainerCraftingTerm) {
|
||||
ContainerCraftingTerm craftingTerm = (ContainerCraftingTerm) c;
|
||||
|
||||
GuiCraftingTerm g = (GuiCraftingTerm) craftingTerm.getGui();
|
||||
IItemList<IAEItemStack> ir = g.getRepo().getList();
|
||||
if (c instanceof ContainerMEMonitorable) {
|
||||
ContainerMEMonitorable container = (ContainerMEMonitorable) c;
|
||||
IItemList<IAEItemStack> ir = ((ContainerMEMonitorable) c).items;
|
||||
boolean found;
|
||||
boolean craftable;
|
||||
int currentSlot = 0;
|
||||
@@ -121,7 +122,7 @@ public class JEIMissingItem implements IRecipeTransferError {
|
||||
|
||||
if (System.currentTimeMillis() - lastUpdate > 1000) {
|
||||
lastUpdate = System.currentTimeMillis();
|
||||
available = mergeInventories(ir, (ContainerCraftingTerm) minecraft.player.openContainer);
|
||||
available = mergeInventories(ir, container);
|
||||
this.foundSlots.clear();
|
||||
this.craftableSlots.clear();
|
||||
} else {
|
||||
@@ -219,7 +220,7 @@ public class JEIMissingItem implements IRecipeTransferError {
|
||||
}
|
||||
}
|
||||
|
||||
IItemList<IAEItemStack> mergeInventories(IItemList<IAEItemStack> repo, ContainerCraftingTerm containerCraftingTerm) {
|
||||
IItemList<IAEItemStack> mergeInventories(IItemList<IAEItemStack> repo, ContainerMEMonitorable containerCraftingTerm) {
|
||||
IItemList<IAEItemStack> itemList = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
|
||||
for (IAEItemStack i : repo) {
|
||||
itemList.addStorage(i);
|
||||
@@ -230,9 +231,11 @@ public class JEIMissingItem implements IRecipeTransferError {
|
||||
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)));
|
||||
if (containerCraftingTerm instanceof IContainerCraftingPacket) {
|
||||
IItemHandler itemHandler = ((IContainerCraftingPacket) containerCraftingTerm).getInventoryByName("crafting");
|
||||
for (int i = 0; i < itemHandler.getSlots(); i++) {
|
||||
itemList.addStorage(AEItemStack.fromItemStack(itemHandler.getStackInSlot(i)));
|
||||
}
|
||||
}
|
||||
return itemList;
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ package appeng.integration.modules.jei;
|
||||
import appeng.container.implementations.ContainerCraftingTerm;
|
||||
import appeng.container.implementations.ContainerPatternEncoder;
|
||||
import appeng.container.implementations.ContainerPatternTerm;
|
||||
import appeng.container.implementations.ContainerWirelessCraftingTerminal;
|
||||
import appeng.container.slot.SlotCraftingMatrix;
|
||||
import appeng.container.slot.SlotFakeCraftingMatrix;
|
||||
import appeng.core.AELog;
|
||||
@@ -75,7 +76,7 @@ class RecipeTransferHandler<T extends Container> implements IRecipeTransferHandl
|
||||
}
|
||||
|
||||
if (!doTransfer) {
|
||||
if (container instanceof ContainerCraftingTerm && recipeType.equals(VanillaRecipeCategoryUid.CRAFTING)) {
|
||||
if (recipeType.equals(VanillaRecipeCategoryUid.CRAFTING) && (container instanceof ContainerCraftingTerm || container instanceof ContainerWirelessCraftingTerminal)) {
|
||||
JEIMissingItem error = new JEIMissingItem(container, recipeLayout);
|
||||
if (error.errored())
|
||||
return error;
|
||||
|
||||
Reference in New Issue
Block a user