made jei recipe transfer more strict when keeping items on the table

few cleanup
This commit is contained in:
Salomão
2021-04-14 21:37:06 -03:00
parent 10761a1e9d
commit 399d67b42c
6 changed files with 47 additions and 62 deletions
+27 -7
View File
@@ -19,6 +19,7 @@
package appeng.client.gui;
import java.awt.*;
import java.io.IOException;
import java.text.DecimalFormat;
import java.text.ParseException;
@@ -31,15 +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.JEIPlugin;
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;
@@ -94,6 +93,7 @@ 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;
@@ -110,7 +110,6 @@ 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()
{
@@ -199,14 +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) {
aeGuiHandler.getTargets( this,o,true );
List<IGhostIngredientHandler.Target<Object>> 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 )
@@ -8,13 +8,9 @@ import appeng.container.slot.SlotFake;
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.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;
@@ -40,7 +36,7 @@ public class AEGuiHandler implements IAdvancedGuiHandler<AEBaseGui>, IGhostIngre
public Object getIngredientUnderMouse( AEBaseGui guiContainer, int mouseX, int mouseY )
{
List<IAEItemStack> visual;
int guiSlotIdx = 0;
int guiSlotIdx;
Object result = null;
if( guiContainer instanceof GuiCraftConfirm )
{
@@ -105,48 +101,27 @@ public class AEGuiHandler implements IAdvancedGuiHandler<AEBaseGui>, IGhostIngre
List<Target<?>> phantomTargets = g.getPhantomTargets( ingredient );
targets.addAll( (List<Target<I>>) (Object) phantomTargets );
}
if( doStart )
if( doStart && GuiScreen.isShiftKeyDown() )
{
if( GuiScreen.isShiftKeyDown() && Mouse.isButtonDown( 0 ) )
if( gui instanceof GuiUpgradeable || gui instanceof GuiPatternTerm )
{
if( gui instanceof GuiUpgradeable || gui instanceof GuiPatternTerm )
IJEIGhostIngredients ghostGui = ( (IJEIGhostIngredients) gui );
for( Target<I> target : targets )
{
IJEIGhostIngredients ghostGui = ( (IJEIGhostIngredients) gui );
for( Target<I> target : targets )
if( ghostGui.getFakeSlotTargetMap().get( target ) instanceof SlotFake )
{
if( ghostGui.getFakeSlotTargetMap().get( target ) instanceof SlotFake )
if( ( (SlotFake) ghostGui.getFakeSlotTargetMap().get( target ) ).getStack().isEmpty() )
{
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;
}
target.accept( ingredient );
break;
}
else if( ghostGui.getFakeSlotTargetMap().get( target ) instanceof GuiFluidSlot )
}
else if( ghostGui.getFakeSlotTargetMap().get( target ) instanceof GuiFluidSlot )
{
if( ( (GuiFluidSlot) ghostGui.getFakeSlotTargetMap().get( target ) ).getFluidStack() == null )
{
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;
}
target.accept( ingredient );
break;
}
}
}
@@ -246,7 +246,7 @@ public class GuiUpgradeable extends AEBaseGui implements IJEIGhostIngredients
{
for( Slot slot : this.inventorySlots.inventorySlots )
{
if( slot instanceof SlotFake && ( !itemStack.isEmpty() || this instanceof GuiCellWorkbench && fluidStack != null && !( (AppEngSlot) slot ).isItemValid( itemStack ) ) )
if( slot instanceof SlotFake && ( !itemStack.isEmpty() || this instanceof GuiCellWorkbench && fluidStack != null ) )
{
slots.add( (IJEITargetSlot) slot );
}
@@ -112,10 +112,6 @@ public class PacketInventoryAction extends AppEngPacket
public PacketInventoryAction(final InventoryAction action, final IJEITargetSlot slot, final IAEItemStack slotItem ) throws IOException
{
if( action != InventoryAction.PLACE_JEI_GHOST_ITEM )
{
throw new IllegalStateException( "invalid packet, client cannot post inv actions with stacks." );
}
this.action = action;
if (slot instanceof SlotFake)
@@ -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;
}
@@ -54,9 +54,10 @@ import appeng.items.parts.ItemFacade;
@mezz.jei.api.JEIPlugin
public class JEIPlugin implements IModPlugin, IBookmarkOverlay
public class JEIPlugin implements IModPlugin
{
public static IJeiRuntime runtime;
public static AEGuiHandler aeGuiHandler;
@Override
public void registerItemSubtypes( ISubtypeRegistry subtypeRegistry )
@@ -96,7 +97,7 @@ public class JEIPlugin implements IModPlugin, IBookmarkOverlay
.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);
}
@@ -223,11 +224,4 @@ public class JEIPlugin implements IModPlugin, IBookmarkOverlay
jeiModule.setJei( new JeiRuntimeAdapter( jeiRuntime ) );
runtime = jeiRuntime;
}
@Nullable
@Override
public Object getIngredientUnderMouse()
{
return runtime.getBookmarkOverlay().getIngredientUnderMouse();
}
}