diff --git a/src/main/java/appeng/client/gui/AEBaseGui.java b/src/main/java/appeng/client/gui/AEBaseGui.java index de1448f0a..213c08166 100644 --- a/src/main/java/appeng/client/gui/AEBaseGui.java +++ b/src/main/java/appeng/client/gui/AEBaseGui.java @@ -19,6 +19,7 @@ package appeng.client.gui; +import java.awt.*; import java.io.IOException; import java.text.DecimalFormat; import java.text.ParseException; @@ -31,13 +32,13 @@ import java.util.List; import java.util.Set; import java.util.concurrent.TimeUnit; -import appeng.tile.inventory.AppEngInternalInventory; import com.google.common.base.Joiner; import com.google.common.base.Stopwatch; import com.google.common.collect.Lists; +import mezz.jei.api.gui.IGhostIngredientHandler; +import net.minecraft.client.gui.Gui; import net.minecraftforge.fml.common.Optional; -import net.minecraftforge.items.IItemHandler; import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; @@ -92,6 +93,9 @@ import appeng.fluids.container.slots.IMEFluidSlot; import appeng.helpers.InventoryAction; import yalter.mousetweaks.api.IMTModGuiContainer2; +import static appeng.integration.modules.jei.JEIPlugin.aeGuiHandler; +import static appeng.integration.modules.jei.JEIPlugin.runtime; + @Optional.Interface( iface = "yalter.mousetweaks.api.IMTModGuiContainer2", modid = "mousetweaks" ) public abstract class AEBaseGui extends GuiContainer implements IMTModGuiContainer2 @@ -106,6 +110,12 @@ public abstract class AEBaseGui extends GuiContainer implements IMTModGuiContain private Stopwatch dbl_clickTimer = Stopwatch.createStarted(); private ItemStack dbl_whichItem = ItemStack.EMPTY; private Slot bl_clicked; + + public List getGuiSlots() + { + return guiSlots; + } + protected final List guiSlots = new ArrayList<>(); public AEBaseGui( final Container container ) @@ -188,6 +198,35 @@ public abstract class AEBaseGui extends GuiContainer implements IMTModGuiContain this.drawTooltip( (ITooltip) c, mouseX, mouseY ); } } + /* + if ( isPointInRegion( -guiLeft,-guiTop, mc.displayWidth, mc.displayHeight, mouseX,mouseY)){ + Object o = runtime.getBookmarkOverlay().getIngredientUnderMouse(); + if (o != null) { + List> hoveredIngredientTargets = aeGuiHandler.getTargets( this, o, false ); + if (hoveredIngredientTargets.size() > 0 ) + { + GlStateManager.disableLighting(); + GlStateManager.disableDepth(); + for( IGhostIngredientHandler.Target target : hoveredIngredientTargets ) + { + Rectangle area = target.getArea(); + Color color; + if( area.contains( mouseX, mouseY ) ) + { + color = new Color( 76, 201, 25, 128 ); + } + else + { + color = new Color( 19, 201, 10, 64 ); + } + Gui.drawRect( area.x, area.y, area.x + area.width, area.y + area.height, color.getRGB() ); + } + GlStateManager.color( 1f, 1f, 1f, 1f ); + aeGuiHandler.getTargets( this, o, true ); + } + } + } + */ } protected void drawGuiSlot( GuiCustomSlot slot, int mouseX, int mouseY, float partialTicks ) diff --git a/src/main/java/appeng/client/gui/AEGuiHandler.java b/src/main/java/appeng/client/gui/AEGuiHandler.java index 749ae4a85..431211abb 100644 --- a/src/main/java/appeng/client/gui/AEGuiHandler.java +++ b/src/main/java/appeng/client/gui/AEGuiHandler.java @@ -2,26 +2,22 @@ package appeng.client.gui; import javax.annotation.Nullable; import appeng.api.storage.data.IAEItemStack; -import appeng.client.gui.implementations.GuiCraftAmount; -import appeng.client.gui.implementations.GuiCraftConfirm; -import appeng.client.gui.implementations.GuiCraftingCPU; -import appeng.client.gui.widgets.GuiCustomSlot; -import appeng.container.implementations.ContainerCraftAmount; +import appeng.client.gui.implementations.*; +import appeng.container.interfaces.IJEIGhostIngredients; +import appeng.container.slot.SlotFake; +import appeng.fluids.client.gui.widgets.GuiFluidSlot; import mezz.jei.api.gui.IAdvancedGuiHandler; -import net.minecraft.client.renderer.RenderItem; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; +import mezz.jei.api.gui.IGhostIngredientHandler; +import net.minecraft.client.gui.GuiScreen; import java.awt.*; import java.util.ArrayList; -import java.util.Collection; import java.util.Collections; import java.util.List; -public class AEGuiHandler implements IAdvancedGuiHandler +public class AEGuiHandler implements IAdvancedGuiHandler, IGhostIngredientHandler { - @Override public Class getGuiContainerClass() { @@ -39,8 +35,8 @@ public class AEGuiHandler implements IAdvancedGuiHandler @Override public Object getIngredientUnderMouse( AEBaseGui guiContainer, int mouseX, int mouseY ) { - List visual = new ArrayList<>(); - int guiSlotIdx = 0; + List visual; + int guiSlotIdx; Object result = null; if( guiContainer instanceof GuiCraftConfirm ) { @@ -94,4 +90,54 @@ public class AEGuiHandler implements IAdvancedGuiHandler if( guiSloty > ( rows - 1 ) || mouseY < guitop + yo ) return -1; return ( guiSloty * 3 ) + guiSlotx + ( currentScroll * 3 ); } + + @Override + public List> getTargets( AEBaseGui gui, I ingredient, boolean doStart ) + { + ArrayList> targets = new ArrayList<>(); + if( gui instanceof IJEIGhostIngredients ) + { + IJEIGhostIngredients g = (IJEIGhostIngredients) gui; + List> phantomTargets = g.getPhantomTargets( ingredient ); + targets.addAll( (List>) (Object) phantomTargets ); + } + if( doStart && GuiScreen.isShiftKeyDown() ) + { + if( gui instanceof GuiUpgradeable || gui instanceof GuiPatternTerm ) + { + IJEIGhostIngredients ghostGui = ( (IJEIGhostIngredients) gui ); + for( Target target : targets ) + { + if( ghostGui.getFakeSlotTargetMap().get( target ) instanceof SlotFake ) + { + if( ( (SlotFake) ghostGui.getFakeSlotTargetMap().get( target ) ).getStack().isEmpty() ) + { + target.accept( ingredient ); + break; + } + } + else if( ghostGui.getFakeSlotTargetMap().get( target ) instanceof GuiFluidSlot ) + { + if( ( (GuiFluidSlot) ghostGui.getFakeSlotTargetMap().get( target ) ).getFluidStack() == null ) + { + target.accept( ingredient ); + break; + } + } + } + } + } + return targets; + } + + @Override + public void onComplete(){ + } + + @Override + public boolean shouldHighlightTargets() + { + return true; + } + } diff --git a/src/main/java/appeng/client/gui/implementations/GuiPatternTerm.java b/src/main/java/appeng/client/gui/implementations/GuiPatternTerm.java index ffaa435b3..b61cee120 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiPatternTerm.java +++ b/src/main/java/appeng/client/gui/implementations/GuiPatternTerm.java @@ -19,11 +19,21 @@ package appeng.client.gui.implementations; +import java.awt.*; import java.io.IOException; +import java.util.*; +import java.util.List; +import appeng.container.interfaces.IJEIGhostIngredients; +import appeng.container.slot.SlotFake; +import appeng.core.sync.packets.PacketInventoryAction; +import appeng.helpers.InventoryAction; +import appeng.util.item.AEItemStack; +import mezz.jei.api.gui.IGhostIngredientHandler.Target; import net.minecraft.client.gui.GuiButton; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.init.Blocks; +import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import appeng.api.config.ActionItems; @@ -40,7 +50,7 @@ import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.packets.PacketValueConfig; -public class GuiPatternTerm extends GuiMEMonitorable +public class GuiPatternTerm extends GuiMEMonitorable implements IJEIGhostIngredients { private static final String BACKGROUND_CRAFTING_MODE = "guis/pattern.png"; @@ -67,6 +77,7 @@ public class GuiPatternTerm extends GuiMEMonitorable private GuiImgButton divThreeBtn; private GuiImgButton minusOneBtn; private GuiImgButton maxCountBtn; + public Map,Object> mapTargetSlot = new HashMap<>(); public GuiPatternTerm( final InventoryPlayer inventoryPlayer, final ITerminalHost te ) { @@ -274,4 +285,52 @@ public class GuiPatternTerm extends GuiMEMonitorable s.yPos = s.getY() + this.ySize - 78 - offsetPlayerSide; } + + @Override + public List> getPhantomTargets(Object ingredient) { + if (!(ingredient instanceof ItemStack )) { + return Collections.emptyList(); + } + List> targets = new ArrayList<>(); + for( Slot slot : this.inventorySlots.inventorySlots ) + { + if( slot instanceof SlotFake ) + { + ItemStack itemStack = (ItemStack) ingredient; + Target target = new Target() + { + @Override + public Rectangle getArea() + { + return new Rectangle( getGuiLeft() + slot.xPos, getGuiTop() + slot.yPos, 16, 16 ); + } + + @Override + public void accept( Object ingredient ) + { + final PacketInventoryAction p; + try + { + p = new PacketInventoryAction( InventoryAction.PLACE_JEI_GHOST_ITEM, (SlotFake) slot, AEItemStack.fromItemStack( itemStack ) ); + NetworkHandler.instance().sendToServer( p ); + + } + catch( IOException e ) + { + e.printStackTrace(); + } + } + }; + targets.add( target ); + mapTargetSlot.putIfAbsent( target, slot ); + } + } + return targets; + } + + @Override + public Map, Object> getFakeSlotTargetMap() + { + return mapTargetSlot; + } } diff --git a/src/main/java/appeng/client/gui/implementations/GuiUpgradeable.java b/src/main/java/appeng/client/gui/implementations/GuiUpgradeable.java index c2cff22d3..f371d896a 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiUpgradeable.java +++ b/src/main/java/appeng/client/gui/implementations/GuiUpgradeable.java @@ -19,8 +19,25 @@ package appeng.client.gui.implementations; +import java.awt.*; import java.io.IOException; +import java.util.*; +import java.util.List; +import appeng.client.gui.widgets.GuiCustomSlot; +import appeng.container.interfaces.IJEIGhostIngredients; +import appeng.container.slot.AppEngSlot; +import appeng.container.slot.IJEITargetSlot; +import appeng.container.slot.SlotFake; +import appeng.core.sync.packets.PacketInventoryAction; +import appeng.fluids.client.gui.widgets.GuiFluidSlot; +import appeng.fluids.util.AEFluidStack; +import appeng.helpers.InventoryAction; +import appeng.util.item.AEItemStack; +import mezz.jei.api.gui.IGhostIngredientHandler.Target; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.*; import org.lwjgl.input.Mouse; import net.minecraft.client.gui.GuiButton; @@ -43,9 +60,9 @@ import appeng.parts.automation.PartExportBus; import appeng.parts.automation.PartImportBus; -public class GuiUpgradeable extends AEBaseGui +public class GuiUpgradeable extends AEBaseGui implements IJEIGhostIngredients { - + private final Map,Object> mapTargetSlot = new HashMap<>(); protected final ContainerUpgradeable cvb; protected final IUpgradeableHost bc; @@ -200,4 +217,108 @@ public class GuiUpgradeable extends AEBaseGui NetworkHandler.instance().sendToServer( new PacketConfigButton( this.schedulingMode.getSetting(), backwards ) ); } } + + @Override + public List> getPhantomTargets(Object ingredient) + { + mapTargetSlot.clear(); + + FluidStack fluidStack = null; + ItemStack itemStack = ItemStack.EMPTY; + + if( ingredient instanceof ItemStack ) + { + itemStack = (ItemStack) ingredient; + fluidStack = FluidUtil.getFluidContained( itemStack ); + } + else if( ingredient instanceof FluidStack ) + { + fluidStack = (FluidStack) ingredient; + } + + if( !( ingredient instanceof ItemStack ) && !( ingredient instanceof FluidStack ) ) + return Collections.emptyList(); + + List> targets = new ArrayList<>(); + + List slots = new ArrayList<>(); + if( this.inventorySlots.inventorySlots.size() > 0 ) + { + for( Slot slot : this.inventorySlots.inventorySlots ) + { + if( slot instanceof SlotFake && ( !itemStack.isEmpty() || this instanceof GuiCellWorkbench && fluidStack != null ) ) + { + slots.add( (IJEITargetSlot) slot ); + } + } + } + if( this.getGuiSlots().size() > 0 ) + { + for( GuiCustomSlot slot : this.getGuiSlots() ) + { + if( slot instanceof GuiFluidSlot && fluidStack != null ) + { + slots.add( (IJEITargetSlot) slot ); + } + } + } + for( Object slot : slots ) + { + ItemStack finalItemStack = itemStack; + FluidStack finalFluidStack = fluidStack; + Target targetItem = new Target() + { + @Override + public Rectangle getArea() + { + if( slot instanceof SlotFake ) + return new Rectangle( getGuiLeft() + ( (SlotFake) slot ).xPos, getGuiTop() + ( (SlotFake) slot ).yPos, 16, 16 ); + else + { + return new Rectangle( getGuiLeft() + ( (GuiFluidSlot) slot ).xPos(), getGuiTop() + ( (GuiFluidSlot) slot ).yPos(), 16, 16 ); + } + } + + @Override + public void accept( Object ingredient ) + { + PacketInventoryAction p = null; + try + { + if( slot instanceof SlotFake ) + { + if( finalItemStack.isEmpty() && finalFluidStack != null ) + { + p = new PacketInventoryAction( InventoryAction.PLACE_JEI_GHOST_ITEM, (IJEITargetSlot) slot, AEItemStack.fromItemStack( FluidUtil.getFilledBucket( finalFluidStack ) ) ); + } + else if( !finalItemStack.isEmpty() ) + { + p = new PacketInventoryAction( InventoryAction.PLACE_JEI_GHOST_ITEM, (IJEITargetSlot) slot, AEItemStack.fromItemStack( finalItemStack ) ); + } + } + else + { + if( finalFluidStack == null ) return; + p = new PacketInventoryAction( InventoryAction.PLACE_JEI_GHOST_ITEM, (IJEITargetSlot) slot, AEItemStack.fromItemStack( AEFluidStack.fromFluidStack( finalFluidStack ).asItemStackRepresentation() ) ); + } + NetworkHandler.instance().sendToServer( p ); + + } + catch( IOException e ) + { + e.printStackTrace(); + } + } + }; + targets.add( targetItem ); + mapTargetSlot.putIfAbsent( targetItem, slot ); + } + return targets; + } + + @Override + public Map, Object> getFakeSlotTargetMap() + { + return mapTargetSlot; + } } diff --git a/src/main/java/appeng/container/interfaces/IJEIGhostIngredients.java b/src/main/java/appeng/container/interfaces/IJEIGhostIngredients.java new file mode 100644 index 000000000..f70eb0630 --- /dev/null +++ b/src/main/java/appeng/container/interfaces/IJEIGhostIngredients.java @@ -0,0 +1,18 @@ +package appeng.container.interfaces; + +import mezz.jei.api.gui.IGhostIngredientHandler.Target; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + + +public interface IJEIGhostIngredients +{ + List> getPhantomTargets( Object ingredient ); + + default Map, Object> getFakeSlotTargetMap(){ + return new HashMap<>(); + } + +} \ No newline at end of file diff --git a/src/main/java/appeng/container/slot/IJEITargetSlot.java b/src/main/java/appeng/container/slot/IJEITargetSlot.java new file mode 100644 index 000000000..c6d0f0429 --- /dev/null +++ b/src/main/java/appeng/container/slot/IJEITargetSlot.java @@ -0,0 +1,4 @@ +package appeng.container.slot; + +public interface IJEITargetSlot { +} diff --git a/src/main/java/appeng/container/slot/SlotFake.java b/src/main/java/appeng/container/slot/SlotFake.java index 8abe0d2e9..96b0a2212 100644 --- a/src/main/java/appeng/container/slot/SlotFake.java +++ b/src/main/java/appeng/container/slot/SlotFake.java @@ -24,7 +24,7 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.items.IItemHandler; -public class SlotFake extends AppEngSlot +public class SlotFake extends AppEngSlot implements IJEITargetSlot { public SlotFake( final IItemHandler inv, final int idx, final int x, final int y ) diff --git a/src/main/java/appeng/core/sync/packets/PacketInventoryAction.java b/src/main/java/appeng/core/sync/packets/PacketInventoryAction.java index 0bb0dc71f..4c9a73dd5 100644 --- a/src/main/java/appeng/core/sync/packets/PacketInventoryAction.java +++ b/src/main/java/appeng/core/sync/packets/PacketInventoryAction.java @@ -21,9 +21,17 @@ package appeng.core.sync.packets; import java.io.IOException; +import appeng.api.storage.data.IAEFluidStack; +import appeng.client.gui.implementations.GuiUpgradeable; +import appeng.client.gui.widgets.GuiCustomSlot; +import appeng.container.slot.IJEITargetSlot; +import appeng.container.slot.SlotFake; +import appeng.fluids.client.gui.widgets.GuiFluidSlot; +import appeng.fluids.util.AEFluidStack; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; +import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; @@ -40,6 +48,7 @@ import appeng.core.sync.network.INetworkInfo; import appeng.helpers.InventoryAction; import appeng.util.Platform; import appeng.util.item.AEItemStack; +import net.minecraftforge.fluids.FluidStack; public class PacketInventoryAction extends AppEngPacket @@ -57,6 +66,7 @@ public class PacketInventoryAction extends AppEngPacket this.slot = stream.readInt(); this.id = stream.readLong(); final boolean hasItem = stream.readBoolean(); + if( hasItem ) { this.slotItem = AEItemStack.fromPacket( stream ); @@ -70,7 +80,6 @@ public class PacketInventoryAction extends AppEngPacket // api public PacketInventoryAction( final InventoryAction action, final int slot, final IAEItemStack slotItem ) throws IOException { - if( Platform.isClient() ) { throw new IllegalStateException( "invalid packet, client cannot post inv actions with stacks." ); @@ -101,6 +110,36 @@ public class PacketInventoryAction extends AppEngPacket this.configureWrite( data ); } + public PacketInventoryAction(final InventoryAction action, final IJEITargetSlot slot, final IAEItemStack slotItem ) throws IOException + { + + this.action = action; + if (slot instanceof SlotFake) + this.slot = ((SlotFake) slot).slotNumber; + else this.slot = ((GuiFluidSlot) slot).getId(); + this.id = 0; + this.slotItem = slotItem; + + final ByteBuf data = Unpooled.buffer(); + + data.writeInt( this.getPacketID() ); + data.writeInt( action.ordinal() ); + data.writeInt( this.slot ); + data.writeLong( this.id ); + + if( slotItem == null ) + { + data.writeBoolean( false ); + } + else + { + data.writeBoolean( true ); + slotItem.writeToPacket( data ); + } + + this.configureWrite( data ); + } + // api public PacketInventoryAction( final InventoryAction action, final int slot, final long id ) { @@ -150,6 +189,46 @@ public class PacketInventoryAction extends AppEngPacket } } } + else if( this.action == InventoryAction.PLACE_JEI_GHOST_ITEM ) + { + if( sender.openContainer.inventorySlots.get( this.slot ) instanceof SlotFake ) + { + if( this.slotItem != null ) { + sender.openContainer.inventorySlots.get( this.slot ).putStack( this.slotItem.asItemStackRepresentation() ); + if (sender.openContainer.inventorySlots.get( this.slot ).getStack().isEmpty()){ + IAEFluidStack aefs = AEFluidStack.fromNBT( this.slotItem.getDefinition().getTagCompound() ); + if( aefs != null ) + { + FluidStack fluid = aefs.getFluidStack(); + sender.openContainer.inventorySlots.get( this.slot ).putStack( AEFluidStack.fromFluidStack( fluid ).asItemStackRepresentation() ); + } + } + } + else sender.openContainer.inventorySlots.get( this.slot ).putStack( ItemStack.EMPTY ); + } + if( Minecraft.getMinecraft().currentScreen instanceof GuiUpgradeable ) + { + GuiUpgradeable cs = ( (GuiUpgradeable) Minecraft.getMinecraft().currentScreen ); + if( cs.getGuiSlots().size() > 0 ) + { + GuiCustomSlot ct = cs.getGuiSlots().get( this.slot ); + GuiFluidSlot gfs = (GuiFluidSlot) ct; + if( this.slotItem != null ) + { + IAEFluidStack aefs = AEFluidStack.fromNBT( this.slotItem.getDefinition().getTagCompound() ); + if( aefs != null ) + { + FluidStack fluid = aefs.getFluidStack(); + gfs.setFluidStack( AEFluidStack.fromFluidStack( fluid ) ); + } + } + else + { + gfs.setFluidStack( null ); + } + } + } + } else { baseContainer.doAction( sender, this.action, this.slot, this.id ); diff --git a/src/main/java/appeng/core/sync/packets/PacketJEIRecipe.java b/src/main/java/appeng/core/sync/packets/PacketJEIRecipe.java index f21b1a443..3c0f97c3c 100644 --- a/src/main/java/appeng/core/sync/packets/PacketJEIRecipe.java +++ b/src/main/java/appeng/core/sync/packets/PacketJEIRecipe.java @@ -303,7 +303,7 @@ public class PacketJEIRecipe extends AppEngPacket { for( ItemStack option : this.recipe[slot] ) { - if( is.isItemEqual( option ) ) + if( ItemStack.areItemStacksEqual( is, option ) ) { return is; } diff --git a/src/main/java/appeng/fluids/client/gui/widgets/GuiFluidSlot.java b/src/main/java/appeng/fluids/client/gui/widgets/GuiFluidSlot.java index 7b1f7c1d5..d0e432a08 100644 --- a/src/main/java/appeng/fluids/client/gui/widgets/GuiFluidSlot.java +++ b/src/main/java/appeng/fluids/client/gui/widgets/GuiFluidSlot.java @@ -4,6 +4,7 @@ package appeng.fluids.client.gui.widgets; import java.util.Collections; +import appeng.container.slot.IJEITargetSlot; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.texture.TextureAtlasSprite; @@ -23,7 +24,7 @@ import appeng.fluids.util.AEFluidStack; import appeng.fluids.util.IAEFluidTank; -public class GuiFluidSlot extends GuiCustomSlot +public class GuiFluidSlot extends GuiCustomSlot implements IJEITargetSlot { private final IAEFluidTank fluids; private final int slot; diff --git a/src/main/java/appeng/helpers/InventoryAction.java b/src/main/java/appeng/helpers/InventoryAction.java index 697ea0b08..6c545e8c8 100644 --- a/src/main/java/appeng/helpers/InventoryAction.java +++ b/src/main/java/appeng/helpers/InventoryAction.java @@ -43,5 +43,6 @@ public enum InventoryAction ROLL_UP, ROLL_DOWN, AUTO_CRAFT, - PLACE_SINGLE + PLACE_SINGLE, + PLACE_JEI_GHOST_ITEM } diff --git a/src/main/java/appeng/integration/modules/jei/JEIPlugin.java b/src/main/java/appeng/integration/modules/jei/JEIPlugin.java index 50e048d50..9a65009d4 100644 --- a/src/main/java/appeng/integration/modules/jei/JEIPlugin.java +++ b/src/main/java/appeng/integration/modules/jei/JEIPlugin.java @@ -19,6 +19,8 @@ package appeng.integration.modules.jei; +import javax.annotation.Nullable; + import java.util.ArrayList; import java.util.List; import java.util.Optional; @@ -27,14 +29,11 @@ import appeng.client.gui.AEGuiHandler; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; +import mezz.jei.api.*; import mezz.jei.config.Constants; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import mezz.jei.api.IJeiRuntime; -import mezz.jei.api.IModPlugin; -import mezz.jei.api.IModRegistry; -import mezz.jei.api.ISubtypeRegistry; import mezz.jei.api.recipe.IRecipeCategoryRegistration; import mezz.jei.api.recipe.VanillaRecipeCategoryUid; @@ -57,6 +56,9 @@ import appeng.items.parts.ItemFacade; @mezz.jei.api.JEIPlugin public class JEIPlugin implements IModPlugin { + public static IJeiRuntime runtime; + public static AEGuiHandler aeGuiHandler; + @Override public void registerItemSubtypes( ISubtypeRegistry subtypeRegistry ) { @@ -95,8 +97,9 @@ public class JEIPlugin implements IModPlugin .addRecipeTransferHandler( new RecipeTransferHandler<>( ContainerPatternTerm.class ), Constants.UNIVERSAL_RECIPE_TRANSFER_UID ); - AEGuiHandler aeGuiHandler = new AEGuiHandler(); + aeGuiHandler = new AEGuiHandler(); registry.addAdvancedGuiHandlers(aeGuiHandler); + registry.addGhostIngredientHandler( aeGuiHandler.getGuiContainerClass(), aeGuiHandler); } private void registerDescriptions( IDefinitions definitions, IModRegistry registry ) @@ -219,5 +222,6 @@ public class JEIPlugin implements IModPlugin { JEIModule jeiModule = (JEIModule) Integrations.jei(); jeiModule.setJei( new JeiRuntimeAdapter( jeiRuntime ) ); + runtime = jeiRuntime; } }