missing click cancel
This commit is contained in:
@@ -36,6 +36,8 @@ import com.google.common.base.Joiner;
|
||||
import com.google.common.base.Stopwatch;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import mezz.jei.api.JEIPlugin;
|
||||
import mezz.jei.api.gui.IGhostIngredientHandler;
|
||||
import net.minecraftforge.fml.common.Optional;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
@@ -92,6 +94,8 @@ import appeng.fluids.container.slots.IMEFluidSlot;
|
||||
import appeng.helpers.InventoryAction;
|
||||
import yalter.mousetweaks.api.IMTModGuiContainer2;
|
||||
|
||||
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,7 @@ public abstract class AEBaseGui extends GuiContainer implements IMTModGuiContain
|
||||
private Stopwatch dbl_clickTimer = Stopwatch.createStarted();
|
||||
private ItemStack dbl_whichItem = ItemStack.EMPTY;
|
||||
private Slot bl_clicked;
|
||||
private final AEGuiHandler aeGuiHandler = new AEGuiHandler();
|
||||
|
||||
public List<GuiCustomSlot> getGuiSlots()
|
||||
{
|
||||
@@ -194,6 +199,14 @@ 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) {
|
||||
aeGuiHandler.getTargets( this,o,true );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void drawGuiSlot( GuiCustomSlot slot, int mouseX, int mouseY, float partialTicks )
|
||||
|
||||
@@ -5,14 +5,16 @@ import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.client.gui.implementations.*;
|
||||
import appeng.container.interfaces.IJEIGhostIngredients;
|
||||
import appeng.container.slot.SlotFake;
|
||||
import appeng.fluids.client.gui.*;
|
||||
import appeng.fluids.client.gui.widgets.GuiFluidSlot;
|
||||
import mezz.jei.api.gui.IAdvancedGuiHandler;
|
||||
import mezz.jei.api.gui.IGhostIngredientHandler;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -20,7 +22,6 @@ import java.util.List;
|
||||
|
||||
public class AEGuiHandler implements IAdvancedGuiHandler<AEBaseGui>, IGhostIngredientHandler<AEBaseGui>
|
||||
{
|
||||
|
||||
@Override
|
||||
public Class<AEBaseGui> getGuiContainerClass()
|
||||
{
|
||||
@@ -106,7 +107,7 @@ public class AEGuiHandler implements IAdvancedGuiHandler<AEBaseGui>, IGhostIngre
|
||||
}
|
||||
if( doStart )
|
||||
{
|
||||
if( GuiScreen.isShiftKeyDown() )
|
||||
if( GuiScreen.isShiftKeyDown() && Mouse.isButtonDown( 0 ) )
|
||||
{
|
||||
if( gui instanceof GuiUpgradeable || gui instanceof GuiPatternTerm )
|
||||
{
|
||||
@@ -117,7 +118,16 @@ public class AEGuiHandler implements IAdvancedGuiHandler<AEBaseGui>, IGhostIngre
|
||||
{
|
||||
if( ( (SlotFake) ghostGui.getFakeSlotTargetMap().get( target ) ).getStack().isEmpty() )
|
||||
{
|
||||
Minecraft.getMinecraft().player.inventory.setItemStack( ItemStack.EMPTY );
|
||||
target.accept( ingredient );
|
||||
try
|
||||
{
|
||||
gui.handleMouseInput();
|
||||
}
|
||||
catch( IOException e )
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -125,7 +135,16 @@ public class AEGuiHandler implements IAdvancedGuiHandler<AEBaseGui>, IGhostIngre
|
||||
{
|
||||
if( ( (GuiFluidSlot) ghostGui.getFakeSlotTargetMap().get( target ) ).getFluidStack() == null )
|
||||
{
|
||||
Minecraft.getMinecraft().player.inventory.setItemStack( ItemStack.EMPTY );
|
||||
target.accept( ingredient );
|
||||
try
|
||||
{
|
||||
gui.handleMouseInput();
|
||||
}
|
||||
catch( IOException e )
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ 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;
|
||||
@@ -34,12 +35,9 @@ import appeng.fluids.util.AEFluidStack;
|
||||
import appeng.helpers.InventoryAction;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import mezz.jei.api.gui.IGhostIngredientHandler.Target;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fluids.*;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
@@ -231,97 +229,90 @@ public class GuiUpgradeable extends AEBaseGui implements IJEIGhostIngredients
|
||||
if( ingredient instanceof ItemStack )
|
||||
{
|
||||
itemStack = (ItemStack) ingredient;
|
||||
|
||||
if( itemStack.hasCapability( CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null ) )
|
||||
{
|
||||
fluidStack = ( itemStack.getCapability( CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null ).drain( Integer.MAX_VALUE, false ) );
|
||||
}
|
||||
if( fluidStack == null )
|
||||
{
|
||||
NBTTagCompound tagCompound = itemStack.getTagCompound();
|
||||
if( tagCompound != null && tagCompound.hasKey( "Fluid" ) )
|
||||
{
|
||||
Fluid fluid = FluidRegistry.getFluid( tagCompound.getString( "Fluid" ) );
|
||||
fluidStack = new FluidStack( fluid, 1000 );
|
||||
}
|
||||
}
|
||||
if( fluidStack == null )
|
||||
{
|
||||
Block maybeFluidBlock = Block.getBlockFromItem( itemStack.getItem() );
|
||||
if( Block.getBlockFromItem( itemStack.getItem() ) instanceof BlockFluidBase )
|
||||
{
|
||||
Fluid fluid = ( (BlockFluidBase) maybeFluidBlock ).getFluid();
|
||||
fluidStack = new FluidStack( fluid, 1000 );
|
||||
}
|
||||
}
|
||||
fluidStack = FluidUtil.getFluidContained( itemStack );
|
||||
}
|
||||
else if( ingredient instanceof FluidStack )
|
||||
{
|
||||
fluidStack = (FluidStack) ingredient;
|
||||
}
|
||||
|
||||
if( !( ingredient instanceof ItemStack ) && !( ingredient instanceof FluidStack ) )
|
||||
return Collections.emptyList();
|
||||
|
||||
List<Target<?>> targets = new ArrayList<>();
|
||||
|
||||
List<IJEITargetSlot> slots = new ArrayList<>();
|
||||
if (this.inventorySlots.inventorySlots.size() > 0) {
|
||||
for (Slot slot : this.inventorySlots.inventorySlots) {
|
||||
if (slot instanceof SlotFake) {
|
||||
slots.add((IJEITargetSlot) slot);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(this.getGuiSlots().size() > 0) {
|
||||
for (GuiCustomSlot slot : this.getGuiSlots()) {
|
||||
if (slot instanceof GuiFluidSlot) {
|
||||
slots.add((IJEITargetSlot) slot);
|
||||
}
|
||||
}
|
||||
}
|
||||
for( Object slot : slots )
|
||||
if( this.inventorySlots.inventorySlots.size() > 0 )
|
||||
{
|
||||
for( Slot slot : this.inventorySlots.inventorySlots )
|
||||
{
|
||||
ItemStack finalItemStack = itemStack;
|
||||
FluidStack finalFluidStack = fluidStack;
|
||||
Target<Object> targetItem = new Target<Object>()
|
||||
{
|
||||
@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 {
|
||||
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 );
|
||||
if( slot instanceof SlotFake && ( !itemStack.isEmpty() || this instanceof GuiCellWorkbench && fluidStack != null && !( (AppEngSlot) slot ).isItemValid( itemStack ) ) )
|
||||
{
|
||||
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<Object> targetItem = new Target<Object>()
|
||||
{
|
||||
@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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user