mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-11 15:57:55 +00:00
fix fc pattern terminal shift click will use not support item to fill slot
This commit is contained in:
1 parent
84e395e470
commit
d2c03bc903
5 files changed
+70
-43
No files matched your search
@@ -63,6 +63,10 @@ public abstract class FCContainerMonitor<T extends IAEStack<T>> extends FCBaseCo
|
||||
this.clientCM.registerSetting(Settings.SORT_DIRECTION, SortDir.ASCENDING);
|
||||
}
|
||||
|
||||
public IMEMonitor<T> getMonitor() {
|
||||
return this.monitor;
|
||||
}
|
||||
|
||||
public IGridNode getNetworkNode() {
|
||||
return this.networkNode;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
package com.glodblock.github.nei;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -43,24 +41,11 @@ public class NEIUtils {
|
||||
}
|
||||
|
||||
public static List<OrderStack<?>> clearNull(List<OrderStack<?>> list) {
|
||||
List<OrderStack<?>> cleared = new LinkedList<>();
|
||||
HashMap<Integer, Object> map = new HashMap<>();
|
||||
int upper = 0;
|
||||
for (OrderStack<?> orderStack : list) {
|
||||
if (orderStack != null && orderStack.getStack() != null) {
|
||||
if (orderStack.getStack() instanceof ItemStack && ((ItemStack) orderStack.getStack()).stackSize == 0)
|
||||
continue;
|
||||
map.put(orderStack.getIndex(), orderStack.getStack());
|
||||
upper = Math.max(upper, orderStack.getIndex());
|
||||
}
|
||||
}
|
||||
int id = 0;
|
||||
for (int i = 0; i <= upper; i++) {
|
||||
if (map.containsKey(i)) {
|
||||
cleared.add(new OrderStack<>(map.get(i), id));
|
||||
id++;
|
||||
}
|
||||
}
|
||||
return cleared;
|
||||
AtomicInteger i = new AtomicInteger(0);
|
||||
return list.stream().filter(Objects::nonNull)
|
||||
.filter(
|
||||
orderStack -> !(orderStack.getStack() != null && orderStack.getStack() instanceof ItemStack
|
||||
&& ((ItemStack) orderStack.getStack()).stackSize == 0))
|
||||
.peek(orderStack -> orderStack.setIndex(i.getAndIncrement())).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,14 @@
|
||||
package com.glodblock.github.nei.object;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
@@ -15,7 +19,8 @@ import com.glodblock.github.util.Util;
|
||||
public class OrderStack<T> {
|
||||
|
||||
private T RealStack;
|
||||
private final int index;
|
||||
private int index;
|
||||
private ItemStack[] items;
|
||||
|
||||
public static final int ITEM = 1;
|
||||
public static final int FLUID = 2;
|
||||
@@ -28,10 +33,29 @@ public class OrderStack<T> {
|
||||
this.index = order;
|
||||
}
|
||||
|
||||
public OrderStack(T stack, int order, ItemStack[] items) {
|
||||
this(stack, order);
|
||||
if (items.length > 1) {
|
||||
this.items = items;
|
||||
}
|
||||
}
|
||||
|
||||
public void putStack(T stack) {
|
||||
this.RealStack = stack;
|
||||
}
|
||||
|
||||
public void putItems(ItemStack[] items) {
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
public ItemStack[] getItems() {
|
||||
return this.items;
|
||||
}
|
||||
|
||||
public final void setIndex(int i) {
|
||||
this.index = i;
|
||||
}
|
||||
|
||||
public T getStack() {
|
||||
return RealStack;
|
||||
}
|
||||
@@ -71,6 +95,16 @@ public class OrderStack<T> {
|
||||
NBTTagCompound tmp = new NBTTagCompound();
|
||||
tmp.setByte("t", (byte) ITEM);
|
||||
((ItemStack) RealStack).writeToNBT(tmp);
|
||||
// replacement items
|
||||
if (items != null) {
|
||||
NBTTagList list = new NBTTagList();
|
||||
for (ItemStack is : this.items) {
|
||||
NBTTagCompound t = new NBTTagCompound();
|
||||
is.writeToNBT(t);
|
||||
list.appendTag(t);
|
||||
}
|
||||
tmp.setTag(index + ":", list);
|
||||
}
|
||||
buf.setTag(index + ":", tmp);
|
||||
} else if (RealStack instanceof FluidStack) {
|
||||
NBTTagCompound tmp = new NBTTagCompound();
|
||||
@@ -91,7 +125,15 @@ public class OrderStack<T> {
|
||||
byte id = info.getByte("t");
|
||||
switch (id) {
|
||||
case ITEM:
|
||||
return new OrderStack<>(ItemStack.loadItemStackFromNBT(info), index);
|
||||
List<ItemStack> list = new ArrayList<>();
|
||||
if (info.hasKey(index + ":")) {
|
||||
NBTTagList items = info.getTagList(index + ":", 10);
|
||||
for (int x = 0; x < items.tagCount(); x++) {
|
||||
final NBTTagCompound item = items.getCompoundTagAt(x);
|
||||
list.add(ItemStack.loadItemStackFromNBT(item));
|
||||
}
|
||||
}
|
||||
return new OrderStack<>(ItemStack.loadItemStackFromNBT(info), index, list.toArray(new ItemStack[0]));
|
||||
case FLUID:
|
||||
return new OrderStack<>(FluidStack.loadFluidStackFromNBT(info), index);
|
||||
case CUSTOM:
|
||||
|
||||
@@ -26,7 +26,7 @@ public final class ExtractorUtil {
|
||||
return items.stream().map(item -> {
|
||||
index.getAndIncrement();
|
||||
Object o = transformer.apply(item);
|
||||
return o != null ? new OrderStack<>(o, index.get()) : null;
|
||||
return o != null ? new OrderStack<>(o, index.get(), item.items) : null;
|
||||
}).filter(Objects::nonNull).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
@@ -12,8 +12,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
|
||||
@@ -97,12 +96,10 @@ public class CPacketTransferRecipe implements IMessage {
|
||||
public IMessage onMessage(CPacketTransferRecipe message, MessageContext ctx) {
|
||||
Container c = ctx.getServerHandler().playerEntity.openContainer;
|
||||
if (c instanceof ContainerItemMonitor) {
|
||||
ITerminalHost host = ((ContainerItemMonitor) c).getHost();
|
||||
IItemList<IAEItemStack> storageList;
|
||||
if (host != null) {
|
||||
storageList = host.getItemInventory().getStorageList();
|
||||
} else {
|
||||
storageList = AEApi.instance().storage().createItemList();
|
||||
IMEMonitor<IAEItemStack> monitor = ((ContainerItemMonitor) c).getMonitor();
|
||||
IItemList<IAEItemStack> storageList = AEApi.instance().storage().createItemList();
|
||||
if (monitor != null) {
|
||||
storageList = monitor.getStorageList();
|
||||
}
|
||||
if (c instanceof FCContainerEncodeTerminal) {
|
||||
// pattern terminal only
|
||||
@@ -130,16 +127,15 @@ public class CPacketTransferRecipe implements IMessage {
|
||||
// using exists item to fill slot
|
||||
if (message.shift && !storageList.isEmpty()) {
|
||||
for (OrderStack stack : message.inputs) {
|
||||
if (stack.getStack() instanceof FluidStack) continue;
|
||||
ItemStack is = (ItemStack) stack.getStack();
|
||||
IAEItemStack iaeItemStack = AEApi.instance().storage().createItemStack(is);
|
||||
if (stack.getStack() instanceof FluidStack || stack.getItems() == null) continue;
|
||||
IAEItemStack iaeItemStack = AEApi.instance().storage()
|
||||
.createItemStack((ItemStack) stack.getStack());
|
||||
if (storageList.findPrecise(iaeItemStack) == null) {
|
||||
for (IAEItemStack tmp : storageList.findFuzzy(iaeItemStack, FuzzyMode.IGNORE_ALL)) {
|
||||
if (iaeItemStack.sameOre(tmp)) {
|
||||
ItemStack substitute = tmp.getItemStack().copy();
|
||||
substitute.stackSize = is.stackSize;
|
||||
stack.putStack(substitute);
|
||||
break;
|
||||
// try to replace item
|
||||
for (ItemStack replaceItemStack : stack.getItems()) {
|
||||
if (storageList.findPrecise(
|
||||
AEApi.instance().storage().createItemStack(replaceItemStack)) != null) {
|
||||
stack.putStack(replaceItemStack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user