Merge branch 'GTNewHorizons:master' into master

This commit is contained in:
asdflj authored and GitHub committed 2023-03-07 18:25:20 +08:00
commit 67ce947cbe
11 files changed
+138 -96

No files matched your search

+1 -1
View File
@@ -2,7 +2,7 @@
dependencies {
compile('com.github.GTNewHorizons:NotEnoughItems:2.3.32-GTNH:dev')
compile('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-160-GTNH:dev')
compile('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-171-GTNH:dev')
compile('curse.maven:cofh-core-69162:2388751')
compile('com.github.GTNewHorizons:waila:1.5.22:dev')
compileOnly('com.github.GTNewHorizons:ExtraCells2:2.5.32:dev') { transitive = false }
@@ -18,8 +18,6 @@ import org.apache.commons.lang3.tuple.MutablePair;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.implementations.guiobjects.IPortableCell;
import appeng.api.implementations.tiles.IMEChest;
import appeng.api.implementations.tiles.IViewCellStorage;
import appeng.api.networking.IGrid;
import appeng.api.networking.IGridHost;
@@ -28,6 +26,7 @@ import appeng.api.networking.energy.IEnergyGrid;
import appeng.api.networking.energy.IEnergySource;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.storage.IBaseMonitor;
import appeng.api.networking.storage.IStorageGrid;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IItemList;
@@ -42,7 +41,6 @@ import appeng.util.item.AEItemStack;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.base.FCContainerMonitor;
import com.glodblock.github.common.item.ItemFluidDrop;
import com.glodblock.github.inventory.item.IFluidPortableCell;
import com.glodblock.github.network.CPacketFluidUpdate;
import com.glodblock.github.network.SPacketFluidUpdate;
import com.glodblock.github.network.SPacketMEInventoryUpdate;
@@ -61,27 +59,28 @@ public class ContainerFluidMonitor extends FCContainerMonitor<IAEFluidStack> {
super(ip, monitorable, bindInventory);
if (Platform.isServer()) {
this.serverCM = monitorable.getConfigManager();
this.monitor = monitorable.getFluidInventory();
if (this.monitor != null) {
this.monitor.addListener(this, null);
if (monitorable instanceof IFluidPortableCell) {
this.setPowerSource((IEnergySource) monitorable);
} else if (monitorable instanceof IPortableCell) {
this.setPowerSource((IEnergySource) monitorable);
} else if (monitorable instanceof IMEChest) {
this.setPowerSource((IEnergySource) monitorable);
} else if (monitorable instanceof IGridHost) {
final IGridNode node = ((IGridHost) monitorable).getGridNode(ForgeDirection.UNKNOWN);
if (node != null) {
this.networkNode = node;
final IGrid g = node.getGrid();
if (g != null) {
this.setPowerSource(new ChannelPowerSrc(this.networkNode, g.getCache(IEnergyGrid.class)));
if (monitorable instanceof IGridHost) {
final IGridNode node = ((IGridHost) monitorable).getGridNode(ForgeDirection.UNKNOWN);
if (node != null) {
this.networkNode = node;
final IGrid g = node.getGrid();
if (g != null) {
this.setPowerSource(new ChannelPowerSrc(this.networkNode, g.getCache(IEnergyGrid.class)));
IStorageGrid storageGrid = g.getCache(IStorageGrid.class);
this.monitor = storageGrid.getFluidInventory();
if (this.monitor == null) {
this.setValidContainer(false);
} else {
this.monitor.addListener(this, null);
}
}
} else {
this.setValidContainer(false);
}
} else {
this.setValidContainer(false);
this.monitor = monitorable.getFluidInventory();
this.monitor.addListener(this, null);
this.setPowerSource((IEnergySource) monitorable);
}
} else {
this.monitor = null;
@@ -151,11 +150,6 @@ public class ContainerFluidMonitor extends FCContainerMonitor<IAEFluidStack> {
}
}
@Override
protected boolean isInvalid() {
return this.monitor != this.host.getFluidInventory();
}
@Override
protected void queueInventory(final ICrafting c) {
if (Platform.isServer() && c instanceof EntityPlayer && this.monitor != null) {
@@ -9,8 +9,6 @@ import net.minecraft.inventory.ICrafting;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.AEApi;
import appeng.api.implementations.guiobjects.IPortableCell;
import appeng.api.implementations.tiles.IMEChest;
import appeng.api.implementations.tiles.IViewCellStorage;
import appeng.api.networking.IGrid;
import appeng.api.networking.IGridHost;
@@ -19,6 +17,7 @@ import appeng.api.networking.energy.IEnergyGrid;
import appeng.api.networking.energy.IEnergySource;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.storage.IBaseMonitor;
import appeng.api.networking.storage.IStorageGrid;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
@@ -43,26 +42,30 @@ public class ContainerItemMonitor extends FCContainerMonitor<IAEItemStack> {
super(ip, monitorable, bindInventory);
if (Platform.isServer()) {
this.serverCM = monitorable.getConfigManager();
this.monitor = monitorable.getItemInventory();
if (this.monitor != null) {
this.monitor.addListener(this, null);
this.setCellInventory(this.monitor);
if (monitorable instanceof IPortableCell) {
this.setPowerSource((IEnergySource) monitorable);
} else if (monitorable instanceof IMEChest) {
this.setPowerSource((IEnergySource) monitorable);
} else if (monitorable instanceof IGridHost) {
final IGridNode node = ((IGridHost) monitorable).getGridNode(ForgeDirection.UNKNOWN);
if (node != null) {
this.networkNode = node;
final IGrid g = node.getGrid();
if (g != null) {
this.setPowerSource(new ChannelPowerSrc(this.networkNode, g.getCache(IEnergyGrid.class)));
if (monitorable instanceof IGridHost) {
final IGridNode node = ((IGridHost) monitorable).getGridNode(ForgeDirection.UNKNOWN);
if (node != null) {
this.networkNode = node;
final IGrid g = node.getGrid();
if (g != null) {
this.setPowerSource(new ChannelPowerSrc(this.networkNode, g.getCache(IEnergyGrid.class)));
IStorageGrid storageGrid = g.getCache(IStorageGrid.class);
this.monitor = storageGrid.getItemInventory();
if (this.monitor == null) {
this.setValidContainer(false);
} else {
this.monitor.addListener(this, null);
this.setCellInventory(this.monitor);
}
}
} else {
this.setValidContainer(false);
}
} else {
this.setValidContainer(false);
this.monitor = monitorable.getItemInventory();
this.monitor.addListener(this, null);
this.setCellInventory(this.monitor);
this.setPowerSource((IEnergySource) monitorable);
}
} else {
this.monitor = null;
@@ -64,6 +64,10 @@ public abstract class FCContainerMonitor<T extends IAEStack<T>> extends FCBaseCo
this.clientCM.registerSetting(Settings.TYPE_FILTER, TypeFilter.ALL);
}
public IMEMonitor<T> getMonitor() {
return this.monitor;
}
public IGridNode getNetworkNode() {
return this.networkNode;
}
@@ -113,7 +117,7 @@ public abstract class FCContainerMonitor<T extends IAEStack<T>> extends FCBaseCo
protected abstract void processItemList();
protected boolean isInvalid() {
return this.monitor != this.host.getItemInventory();
return this.monitor == null;
}
protected void updatePowerStatus() {
@@ -137,8 +137,9 @@ public class PartFluidExportBus extends FCSharedFluidBus implements ICraftingReq
this.source);
}
int space = fh.fill(this.getSide().getOpposite(), toExtract.getFluidStack(), false);
toExtract.setStackSize(space);
final IAEFluidStack real = inv.extractItems(toExtract, Actionable.MODULATE, this.source);
if (real != null && isAllowed) {
int realInserted = fh.fill(this.getSide().getOpposite(), real.getFluidStack(), true);
if (realInserted < real.getStackSize()) {
@@ -35,6 +35,7 @@ import appeng.client.texture.CableBusTextures;
import appeng.core.AELog;
import appeng.core.localization.PlayerMessages;
import appeng.helpers.Reflected;
import appeng.hooks.TickHandler;
import appeng.me.GridAccessException;
import appeng.parts.reporting.AbstractPartDisplay;
import appeng.parts.reporting.PartPanel;
@@ -199,7 +200,7 @@ public abstract class FCPartMonitor extends AbstractPartDisplay implements IPart
super.finalize();
if (this.dspList != null) {
GLAllocation.deleteDisplayLists(this.dspList);
TickHandler.INSTANCE.scheduleCallListDelete(this.dspList);
}
}
@@ -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:
@@ -1,9 +1,7 @@
package com.glodblock.github.nei.recipes;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
@@ -30,7 +28,8 @@ public final class FluidRecipe {
public static List<OrderStack<?>> getPackageInputs(IRecipeHandler recipe, int index, boolean priority) {
TemplateRecipeHandler tRecipe = (TemplateRecipeHandler) recipe;
if (tRecipe == null || !IdentifierMap.containsKey(tRecipe.getOverlayIdentifier())) return new ArrayList<>();
if (tRecipe == null) return new ArrayList<>();
if (!IdentifierMap.containsKey(tRecipe.getOverlayIdentifier())) return getDefaultPackageInputs(tRecipe, index);
if (tRecipe.getOverlayIdentifier() == null) return getPackageInputsLegacy(recipe, index);
IRecipeExtractor extractor = IdentifierMap.get(tRecipe.getOverlayIdentifier());
if (extractor == null) return new ArrayList<>();
@@ -54,9 +53,26 @@ public final class FluidRecipe {
return out;
}
private static List<OrderStack<?>> getDefaultPackageInputs(TemplateRecipeHandler tRecipe, int index) {
List<OrderStack<?>> tmp = new LinkedList<>();
AtomicInteger i = new AtomicInteger(0);
tRecipe.getIngredientStacks(index)
.forEach(ps -> tmp.add(new OrderStack<>(ps.item, i.getAndIncrement(), ps.items)));
return tmp;
}
private static List<OrderStack<?>> getDefaultPackageOutputs(TemplateRecipeHandler tRecipe, int index) {
List<OrderStack<?>> tmp = new LinkedList<>();
AtomicInteger i = new AtomicInteger(0);
tmp.add(new OrderStack<>(tRecipe.getResultStack(index).item, i.getAndIncrement()));
tRecipe.getOtherStacks(index).forEach(ps -> tmp.add(new OrderStack<>(ps.item, i.getAndIncrement())));
return tmp;
}
public static List<OrderStack<?>> getPackageOutputs(IRecipeHandler recipe, int index, boolean useOther) {
TemplateRecipeHandler tRecipe = (TemplateRecipeHandler) recipe;
if (tRecipe == null || !IdentifierMap.containsKey(tRecipe.getOverlayIdentifier())) return new ArrayList<>();
if (tRecipe == null) return new ArrayList<>();
if (!IdentifierMap.containsKey(tRecipe.getOverlayIdentifier())) return getDefaultPackageOutputs(tRecipe, index);
if (tRecipe.getOverlayIdentifier() == null) return getPackageOutputsLegacy(recipe, index, useOther);
IRecipeExtractor extractor = IdentifierMap.get(tRecipe.getOverlayIdentifier());
if (extractor == null) return new ArrayList<>();
@@ -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);
}
}
}