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;
|
package appeng.client.gui;
|
||||||
|
|
||||||
import appeng.api.storage.data.IAEItemStack;
|
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.interfaces.IJEIGhostIngredients;
|
||||||
import appeng.container.slot.SlotFake;
|
import appeng.container.slot.IJEITargetSlot;
|
||||||
import appeng.fluids.client.gui.widgets.GuiFluidSlot;
|
|
||||||
import mezz.jei.api.gui.IAdvancedGuiHandler;
|
import mezz.jei.api.gui.IAdvancedGuiHandler;
|
||||||
import mezz.jei.api.gui.IGhostIngredientHandler;
|
import mezz.jei.api.gui.IGhostIngredientHandler;
|
||||||
import net.minecraft.client.gui.GuiScreen;
|
import net.minecraft.client.gui.GuiScreen;
|
||||||
@@ -78,12 +82,12 @@ public class AEGuiHandler implements IAdvancedGuiHandler<AEBaseGui>, IGhostIngre
|
|||||||
return (guiSloty * 3) + guiSlotx + (currentScroll * 3);
|
return (guiSloty * 3) + guiSlotx + (currentScroll * 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public <I> List<Target<I>> getTargets(@Nonnull AEBaseGui gui, @Nonnull I ingredient, boolean doStart) {
|
public <I> List<Target<I>> getTargets(@Nonnull AEBaseGui gui, @Nonnull I ingredient, boolean doStart) {
|
||||||
ArrayList<Target<I>> targets = new ArrayList<>();
|
ArrayList<Target<I>> targets = new ArrayList<>();
|
||||||
if (gui instanceof IJEIGhostIngredients) {
|
if (gui instanceof IJEIGhostIngredients g) {
|
||||||
IJEIGhostIngredients g = (IJEIGhostIngredients) gui;
|
|
||||||
List<Target<?>> phantomTargets = g.getPhantomTargets(ingredient);
|
List<Target<?>> phantomTargets = g.getPhantomTargets(ingredient);
|
||||||
targets.addAll((List<Target<I>>) (Object) phantomTargets);
|
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) {
|
if (gui instanceof GuiUpgradeable || gui instanceof GuiPatternTerm || gui instanceof GuiExpandedProcessingPatternTerm) {
|
||||||
IJEIGhostIngredients ghostGui = ((IJEIGhostIngredients) gui);
|
IJEIGhostIngredients ghostGui = ((IJEIGhostIngredients) gui);
|
||||||
for (Target<I> target : targets) {
|
for (Target<I> target : targets) {
|
||||||
if (ghostGui.getFakeSlotTargetMap().get(target) instanceof SlotFake) {
|
if (ghostGui.getFakeSlotTargetMap().get(target) instanceof IJEITargetSlot jeiSlot) {
|
||||||
if (((SlotFake) ghostGui.getFakeSlotTargetMap().get(target)).getStack().isEmpty()) {
|
if (jeiSlot.needAccept()) {
|
||||||
target.accept(ingredient);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else if (ghostGui.getFakeSlotTargetMap().get(target) instanceof GuiFluidSlot) {
|
|
||||||
if (((GuiFluidSlot) ghostGui.getFakeSlotTargetMap().get(target)).getFluidStack() == null) {
|
|
||||||
target.accept(ingredient);
|
target.accept(ingredient);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ import net.minecraftforge.fluids.FluidStack;
|
|||||||
import net.minecraftforge.fluids.FluidUtil;
|
import net.minecraftforge.fluids.FluidUtil;
|
||||||
import org.lwjgl.input.Mouse;
|
import org.lwjgl.input.Mouse;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -54,7 +55,7 @@ import java.util.*;
|
|||||||
|
|
||||||
|
|
||||||
public class GuiUpgradeable extends AEBaseGui implements IJEIGhostIngredients {
|
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 ContainerUpgradeable cvb;
|
||||||
protected final IUpgradeableHost bc;
|
protected final IUpgradeableHost bc;
|
||||||
|
|
||||||
@@ -218,24 +219,25 @@ public class GuiUpgradeable extends AEBaseGui implements IJEIGhostIngredients {
|
|||||||
List<Target<?>> targets = new ArrayList<>();
|
List<Target<?>> targets = new ArrayList<>();
|
||||||
|
|
||||||
List<IJEITargetSlot> slots = new ArrayList<>();
|
List<IJEITargetSlot> slots = new ArrayList<>();
|
||||||
if (this.inventorySlots.inventorySlots.size() > 0) {
|
if (!this.inventorySlots.inventorySlots.isEmpty()) {
|
||||||
for (Slot slot : this.inventorySlots.inventorySlots) {
|
for (Slot slot : this.inventorySlots.inventorySlots) {
|
||||||
if (slot instanceof SlotFake && (!itemStack.isEmpty() || this instanceof GuiCellWorkbench && fluidStack != null)) {
|
if (slot instanceof SlotFake && (!itemStack.isEmpty() || this instanceof GuiCellWorkbench && fluidStack != null)) {
|
||||||
slots.add((IJEITargetSlot) slot);
|
slots.add((IJEITargetSlot) slot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.getGuiSlots().size() > 0) {
|
if (!this.getGuiSlots().isEmpty()) {
|
||||||
for (GuiCustomSlot slot : this.getGuiSlots()) {
|
for (GuiCustomSlot slot : this.getGuiSlots()) {
|
||||||
if (slot instanceof GuiFluidSlot && fluidStack != null) {
|
if (slot instanceof GuiFluidSlot && fluidStack != null) {
|
||||||
slots.add((IJEITargetSlot) slot);
|
slots.add((IJEITargetSlot) slot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (Object slot : slots) {
|
for (IJEITargetSlot slot : slots) {
|
||||||
ItemStack finalItemStack = itemStack;
|
ItemStack finalItemStack = itemStack;
|
||||||
FluidStack finalFluidStack = fluidStack;
|
FluidStack finalFluidStack = fluidStack;
|
||||||
Target<Object> targetItem = new Target<Object>() {
|
Target<Object> targetItem = new Target<>() {
|
||||||
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public Rectangle getArea() {
|
public Rectangle getArea() {
|
||||||
if (slot instanceof SlotFake && ((SlotFake) slot).isSlotEnabled()) {
|
if (slot instanceof SlotFake && ((SlotFake) slot).isSlotEnabled()) {
|
||||||
@@ -247,20 +249,20 @@ public class GuiUpgradeable extends AEBaseGui implements IJEIGhostIngredients {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void accept(Object ingredient) {
|
public void accept(@Nonnull Object ingredient) {
|
||||||
PacketInventoryAction p = null;
|
PacketInventoryAction p = null;
|
||||||
try {
|
try {
|
||||||
if (slot instanceof SlotFake && ((SlotFake) slot).isSlotEnabled()) {
|
if (slot instanceof SlotFake && ((SlotFake) slot).isSlotEnabled()) {
|
||||||
if (finalItemStack.isEmpty() && finalFluidStack != null) {
|
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()) {
|
} 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 {
|
} else {
|
||||||
if (finalFluidStack == null) {
|
if (finalFluidStack == null) {
|
||||||
return;
|
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);
|
NetworkHandler.instance().sendToServer(p);
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,9 @@
|
|||||||
package appeng.container.slot;
|
package appeng.container.slot;
|
||||||
|
|
||||||
public interface IJEITargetSlot {
|
public interface IJEITargetSlot {
|
||||||
|
|
||||||
|
default boolean needAccept() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,6 @@ public class SlotFake extends AppEngSlot implements IJEITargetSlot {
|
|||||||
if (!is.isEmpty()) {
|
if (!is.isEmpty()) {
|
||||||
is = is.copy();
|
is = is.copy();
|
||||||
}
|
}
|
||||||
|
|
||||||
super.putStack(is);
|
super.putStack(is);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,4 +57,10 @@ public class SlotFake extends AppEngSlot implements IJEITargetSlot {
|
|||||||
public boolean canTakeStack(final EntityPlayer par1EntityPlayer) {
|
public boolean canTakeStack(final EntityPlayer par1EntityPlayer) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean needAccept() {
|
||||||
|
return this.getStack().isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -93,4 +93,10 @@ public class GuiFluidSlot extends GuiCustomSlot implements IJEITargetSlot {
|
|||||||
this.fluids.setFluidInSlot(this.slot, stack);
|
this.fluids.setFluidInSlot(this.slot, stack);
|
||||||
NetworkHandler.instance().sendToServer(new PacketFluidSlot(Collections.singletonMap(this.getId(), this.getFluidStack())));
|
NetworkHandler.instance().sendToServer(new PacketFluidSlot(Collections.singletonMap(this.getId(), this.getFluidStack())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean needAccept() {
|
||||||
|
return this.getFluidStack() == null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ package appeng.fluids.items;
|
|||||||
import appeng.bootstrap.IItemRendering;
|
import appeng.bootstrap.IItemRendering;
|
||||||
import appeng.bootstrap.ItemRenderingCustomizer;
|
import appeng.bootstrap.ItemRenderingCustomizer;
|
||||||
import appeng.client.render.DummyFluidItemModel;
|
import appeng.client.render.DummyFluidItemModel;
|
||||||
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -33,5 +34,9 @@ public class FluidDummyItemRendering extends ItemRenderingCustomizer {
|
|||||||
@Override
|
@Override
|
||||||
public void customize(IItemRendering rendering) {
|
public void customize(IItemRendering rendering) {
|
||||||
rendering.builtInModel("models/item/dummy_fluid_item", new DummyFluidItemModel());
|
rendering.builtInModel("models/item/dummy_fluid_item", new DummyFluidItemModel());
|
||||||
|
rendering.color(((s, i) -> {
|
||||||
|
FluidStack fluid = ((FluidDummyItem) s.getItem()).getFluidStack(s);
|
||||||
|
return fluid != null ? fluid.getFluid().getColor() : 0xFFFFFFFF;
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user