allow custom slot jei check and fix fluid color in cell workbanch (#401)
This commit is contained in:
@@ -1,10 +1,14 @@
|
||||
package appeng.client.gui;
|
||||
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.client.gui.implementations.*;
|
||||
import appeng.client.gui.implementations.GuiCraftAmount;
|
||||
import appeng.client.gui.implementations.GuiCraftConfirm;
|
||||
import appeng.client.gui.implementations.GuiCraftingCPU;
|
||||
import appeng.client.gui.implementations.GuiExpandedProcessingPatternTerm;
|
||||
import appeng.client.gui.implementations.GuiPatternTerm;
|
||||
import appeng.client.gui.implementations.GuiUpgradeable;
|
||||
import appeng.container.interfaces.IJEIGhostIngredients;
|
||||
import appeng.container.slot.SlotFake;
|
||||
import appeng.fluids.client.gui.widgets.GuiFluidSlot;
|
||||
import appeng.container.slot.IJEITargetSlot;
|
||||
import mezz.jei.api.gui.IAdvancedGuiHandler;
|
||||
import mezz.jei.api.gui.IGhostIngredientHandler;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
@@ -78,12 +82,12 @@ public class AEGuiHandler implements IAdvancedGuiHandler<AEBaseGui>, IGhostIngre
|
||||
return (guiSloty * 3) + guiSlotx + (currentScroll * 3);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
@Nonnull
|
||||
public <I> List<Target<I>> getTargets(@Nonnull AEBaseGui gui, @Nonnull I ingredient, boolean doStart) {
|
||||
ArrayList<Target<I>> targets = new ArrayList<>();
|
||||
if (gui instanceof IJEIGhostIngredients) {
|
||||
IJEIGhostIngredients g = (IJEIGhostIngredients) gui;
|
||||
if (gui instanceof IJEIGhostIngredients g) {
|
||||
List<Target<?>> phantomTargets = g.getPhantomTargets(ingredient);
|
||||
targets.addAll((List<Target<I>>) (Object) phantomTargets);
|
||||
}
|
||||
@@ -91,13 +95,8 @@ public class AEGuiHandler implements IAdvancedGuiHandler<AEBaseGui>, IGhostIngre
|
||||
if (gui instanceof GuiUpgradeable || gui instanceof GuiPatternTerm || gui instanceof GuiExpandedProcessingPatternTerm) {
|
||||
IJEIGhostIngredients ghostGui = ((IJEIGhostIngredients) gui);
|
||||
for (Target<I> 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) {
|
||||
if (ghostGui.getFakeSlotTargetMap().get(target) instanceof IJEITargetSlot jeiSlot) {
|
||||
if (jeiSlot.needAccept()) {
|
||||
target.accept(ingredient);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidUtil;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
@@ -54,7 +55,7 @@ import java.util.*;
|
||||
|
||||
|
||||
public class GuiUpgradeable extends AEBaseGui implements IJEIGhostIngredients {
|
||||
private final Map<Target<?>, Object> mapTargetSlot = new HashMap<>();
|
||||
protected final Map<Target<?>, Object> mapTargetSlot = new HashMap<>();
|
||||
protected final ContainerUpgradeable cvb;
|
||||
protected final IUpgradeableHost bc;
|
||||
|
||||
@@ -218,24 +219,25 @@ public class GuiUpgradeable extends AEBaseGui implements IJEIGhostIngredients {
|
||||
List<Target<?>> targets = new ArrayList<>();
|
||||
|
||||
List<IJEITargetSlot> slots = new ArrayList<>();
|
||||
if (this.inventorySlots.inventorySlots.size() > 0) {
|
||||
if (!this.inventorySlots.inventorySlots.isEmpty()) {
|
||||
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) {
|
||||
if (!this.getGuiSlots().isEmpty()) {
|
||||
for (GuiCustomSlot slot : this.getGuiSlots()) {
|
||||
if (slot instanceof GuiFluidSlot && fluidStack != null) {
|
||||
slots.add((IJEITargetSlot) slot);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Object slot : slots) {
|
||||
for (IJEITargetSlot slot : slots) {
|
||||
ItemStack finalItemStack = itemStack;
|
||||
FluidStack finalFluidStack = fluidStack;
|
||||
Target<Object> targetItem = new Target<Object>() {
|
||||
Target<Object> targetItem = new Target<>() {
|
||||
@Nonnull
|
||||
@Override
|
||||
public Rectangle getArea() {
|
||||
if (slot instanceof SlotFake && ((SlotFake) slot).isSlotEnabled()) {
|
||||
@@ -247,20 +249,20 @@ public class GuiUpgradeable extends AEBaseGui implements IJEIGhostIngredients {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(Object ingredient) {
|
||||
public void accept(@Nonnull Object ingredient) {
|
||||
PacketInventoryAction p = null;
|
||||
try {
|
||||
if (slot instanceof SlotFake && ((SlotFake) slot).isSlotEnabled()) {
|
||||
if (finalItemStack.isEmpty() && finalFluidStack != null) {
|
||||
p = new PacketInventoryAction(InventoryAction.PLACE_JEI_GHOST_ITEM, (IJEITargetSlot) slot, AEItemStack.fromItemStack(FluidUtil.getFilledBucket(finalFluidStack)));
|
||||
p = new PacketInventoryAction(InventoryAction.PLACE_JEI_GHOST_ITEM, slot, AEItemStack.fromItemStack(FluidUtil.getFilledBucket(finalFluidStack)));
|
||||
} else if (!finalItemStack.isEmpty()) {
|
||||
p = new PacketInventoryAction(InventoryAction.PLACE_JEI_GHOST_ITEM, (IJEITargetSlot) slot, AEItemStack.fromItemStack(finalItemStack));
|
||||
p = new PacketInventoryAction(InventoryAction.PLACE_JEI_GHOST_ITEM, 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()));
|
||||
p = new PacketInventoryAction(InventoryAction.PLACE_JEI_GHOST_ITEM, slot, AEItemStack.fromItemStack(AEFluidStack.fromFluidStack(finalFluidStack).asItemStackRepresentation()));
|
||||
}
|
||||
NetworkHandler.instance().sendToServer(p);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user