mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-12 00:07:29 +00:00
Fix Crafting Input Bus Compatibility & fix general bugs (#154)
* fix: uses IInterfaceTerminalSupport for interface terminal
fix custom target not registered in ae2fc wireless interface terminal
* fix: empty string caused channel crash && check if custom name exist before getting
* fix: Fluid interface not registered
* Revert "fix: Fluid interface not registered"
This reverts commit bc21ee2673.
* fix: remove ASM in favor of the new API
* fix: remove zero size character bypass as checking hasCustomName is enough
This commit is contained in:
1 parent
98ff754306
commit
bcdd765870
6 files changed
+85
-162
No files matched your search
@@ -520,8 +520,9 @@ public class GuiInterfaceTerminalWireless extends FCBaseMEGui implements IDropTo
|
||||
try {
|
||||
final long id = Long.parseLong(key.substring(1), Character.MAX_RADIX);
|
||||
final NBTTagCompound invData = in.getCompoundTag(key);
|
||||
int size = invData.getInteger("size");
|
||||
final ClientDCInternalInv current = this
|
||||
.getById(id, invData.getLong("sortBy"), invData.getString("un"));
|
||||
.getById(id, invData.getLong("sortBy"), invData.getString("un"), size);
|
||||
int X = invData.getInteger("x");
|
||||
int Y = invData.getInteger("y");
|
||||
int Z = invData.getInteger("z");
|
||||
@@ -724,11 +725,12 @@ public class GuiInterfaceTerminalWireless extends FCBaseMEGui implements IDropTo
|
||||
: Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
private ClientDCInternalInv getById(final long id, final long sortBy, final String unlocalizedName) {
|
||||
private ClientDCInternalInv getById(final long id, final long sortBy, final String unlocalizedName,
|
||||
final int sizeInit) {
|
||||
ClientDCInternalInv o = this.byId.get(id);
|
||||
|
||||
if (o == null) {
|
||||
this.byId.put(id, o = new ClientDCInternalInv(9, id, sortBy, unlocalizedName));
|
||||
this.byId.put(id, o = new ClientDCInternalInv(sizeInit, id, sortBy, unlocalizedName));
|
||||
this.refreshList = true;
|
||||
}
|
||||
|
||||
|
||||
+70
-96
@@ -11,27 +11,22 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import com.glodblock.github.client.gui.container.base.FCBaseContainer;
|
||||
import com.glodblock.github.common.parts.PartFluidInterface;
|
||||
import com.glodblock.github.common.tile.TileFluidInterface;
|
||||
import com.glodblock.github.inventory.item.IWirelessTerminal;
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
import appeng.api.config.*;
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.security.IActionHost;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketCompressedNBT;
|
||||
import appeng.helpers.DualityInterface;
|
||||
import appeng.helpers.IInterfaceHost;
|
||||
import appeng.helpers.IInterfaceTerminalSupport;
|
||||
import appeng.helpers.InterfaceTerminalSupportedClassProvider;
|
||||
import appeng.helpers.InventoryAction;
|
||||
import appeng.items.misc.ItemEncodedPattern;
|
||||
import appeng.parts.AEBasePart;
|
||||
import appeng.parts.misc.PartInterface;
|
||||
import appeng.parts.p2p.PartP2PInterface;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.tile.misc.TileInterface;
|
||||
import appeng.util.InventoryAdaptor;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.inv.AdaptorIInventory;
|
||||
@@ -46,7 +41,7 @@ public class ContainerInterfaceWireless extends FCBaseContainer {
|
||||
*/
|
||||
private static long autoBase = Long.MIN_VALUE;
|
||||
|
||||
private final Multimap<IInterfaceHost, ContainerInterfaceWireless.InvTracker> diList = HashMultimap.create();
|
||||
private final Multimap<IInterfaceTerminalSupport, InvTracker> supportedInterfaces = HashMultimap.create();
|
||||
private final Map<Long, ContainerInterfaceWireless.InvTracker> byId = new HashMap<>();
|
||||
private IGrid grid;
|
||||
private NBTTagCompound data = new NBTTagCompound();
|
||||
@@ -60,16 +55,6 @@ public class ContainerInterfaceWireless extends FCBaseContainer {
|
||||
this.bindPlayerInventory(ip, 14, 0);
|
||||
}
|
||||
|
||||
private Set<IGridNode> getMachineNodes() {
|
||||
Set<IGridNode> union = new HashSet<>();
|
||||
this.grid.getMachines(TileFluidInterface.class).forEach(union::add);
|
||||
this.grid.getMachines(TileInterface.class).forEach(union::add);
|
||||
this.grid.getMachines(PartFluidInterface.class).forEach(union::add);
|
||||
this.grid.getMachines(PartInterface.class).forEach(union::add);
|
||||
this.grid.getMachines(PartP2PInterface.class).forEach(union::add);
|
||||
return union;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
if (Platform.isClient()) {
|
||||
@@ -88,19 +73,28 @@ public class ContainerInterfaceWireless extends FCBaseContainer {
|
||||
if (host != null) {
|
||||
final IGridNode agn = host.getActionableNode();
|
||||
if (agn != null && agn.isActive()) {
|
||||
for (final IGridNode gn : this.getMachineNodes()) {
|
||||
ContainerInterfaceWireless.InterfaceCheck interfaceCheck = new ContainerInterfaceWireless.InterfaceCheck()
|
||||
.invoke(gn);
|
||||
total += interfaceCheck.getTotal();
|
||||
missing |= interfaceCheck.isMissing();
|
||||
for (var clz : InterfaceTerminalSupportedClassProvider.getSupportedClasses()) {
|
||||
for (final IGridNode gn : this.grid.getMachines(clz)) {
|
||||
final IInterfaceTerminalSupport interfaceTerminalSupport = (IInterfaceTerminalSupport) gn
|
||||
.getMachine();
|
||||
if (!gn.isActive() || !interfaceTerminalSupport.shouldDisplay()) continue;
|
||||
|
||||
final Collection<InvTracker> t = supportedInterfaces.get(interfaceTerminalSupport);
|
||||
final String name = interfaceTerminalSupport.getName();
|
||||
missing = t.isEmpty() || t.stream().anyMatch(it -> !it.unlocalizedName.equals(name));
|
||||
total += interfaceTerminalSupport.getPatternsConfigurations().length;
|
||||
if (missing) break;
|
||||
}
|
||||
// we can stop if any is missing. The value of `total` is not important if `missing == true`
|
||||
if (missing) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (total != this.diList.size() || missing) {
|
||||
if (total != this.supportedInterfaces.size() || missing) {
|
||||
this.regenList(this.data);
|
||||
} else {
|
||||
for (final ContainerInterfaceWireless.InvTracker inv : diList.values()) {
|
||||
for (final ContainerInterfaceWireless.InvTracker inv : supportedInterfaces.values()) {
|
||||
for (int x = 0; x < inv.client.getSizeInventory(); x++) {
|
||||
if (this.isDifferent(inv.server.getStackInSlot(inv.offset + x), inv.client.getStackInSlot(x))) {
|
||||
this.addItems(this.data, inv, x, 1);
|
||||
@@ -244,25 +238,23 @@ public class ContainerInterfaceWireless extends FCBaseContainer {
|
||||
|
||||
private void regenList(final NBTTagCompound data) {
|
||||
this.byId.clear();
|
||||
this.diList.clear();
|
||||
this.supportedInterfaces.clear();
|
||||
|
||||
final IActionHost host = this.getActionHost();
|
||||
if (host != null) {
|
||||
final IGridNode agn = host.getActionableNode();
|
||||
if (agn != null && agn.isActive()) {
|
||||
for (final IGridNode gn : this.getMachineNodes()) {
|
||||
final IInterfaceHost ih = (IInterfaceHost) gn.getMachine();
|
||||
final DualityInterface dual = ih.getInterfaceDuality();
|
||||
if (gn.isActive() && dual.getConfigManager().getSetting(Settings.INTERFACE_TERMINAL) == YesNo.YES) {
|
||||
for (int i = 0; i <= dual.getInstalledUpgrades(Upgrades.PATTERN_CAPACITY); ++i) {
|
||||
this.diList.put(
|
||||
ih,
|
||||
new ContainerInterfaceWireless.InvTracker(
|
||||
dual,
|
||||
dual.getPatterns(),
|
||||
dual.getTermName(),
|
||||
i * 9,
|
||||
9));
|
||||
for (var clz : InterfaceTerminalSupportedClassProvider.getSupportedClasses()) {
|
||||
for (final IGridNode gn : this.grid.getMachines(clz)) {
|
||||
final IInterfaceTerminalSupport terminalSupport = (IInterfaceTerminalSupport) gn.getMachine();
|
||||
if (!gn.isActive() || !terminalSupport.shouldDisplay()) continue;
|
||||
|
||||
final var configurations = terminalSupport.getPatternsConfigurations();
|
||||
|
||||
for (int i = 0; i < configurations.length; ++i) {
|
||||
this.supportedInterfaces.put(
|
||||
terminalSupport,
|
||||
new ContainerInterfaceWireless.InvTracker(terminalSupport, configurations[i], i));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -271,7 +263,7 @@ public class ContainerInterfaceWireless extends FCBaseContainer {
|
||||
|
||||
data.setBoolean("clear", true);
|
||||
|
||||
for (final ContainerInterfaceWireless.InvTracker inv : this.diList.values()) {
|
||||
for (final ContainerInterfaceWireless.InvTracker inv : this.supportedInterfaces.values()) {
|
||||
this.byId.put(inv.which, inv);
|
||||
this.addItems(data, inv, 0, inv.client.getSizeInventory());
|
||||
}
|
||||
@@ -307,6 +299,7 @@ public class ContainerInterfaceWireless extends FCBaseContainer {
|
||||
tag.setInteger("z", inv.Z);
|
||||
tag.setInteger("dim", inv.dim);
|
||||
tag.setInteger("side", inv.side.ordinal());
|
||||
tag.setInteger("size", inv.client.getSizeInventory());
|
||||
}
|
||||
|
||||
for (int x = 0; x < length; x++) {
|
||||
@@ -341,22 +334,46 @@ public class ContainerInterfaceWireless extends FCBaseContainer {
|
||||
private final int dim;
|
||||
private final ForgeDirection side;
|
||||
|
||||
public InvTracker(final DualityInterface dual, final IInventory patterns, final String unlocalizedName,
|
||||
int offset, int size) {
|
||||
public InvTracker(final DimensionalCoord coord, long sortValue, final IInventory patterns,
|
||||
final String unlocalizedName, int offset, int size, ForgeDirection side) {
|
||||
this(
|
||||
coord.x,
|
||||
coord.y,
|
||||
coord.z,
|
||||
coord.getDimension(),
|
||||
sortValue,
|
||||
patterns,
|
||||
unlocalizedName,
|
||||
offset,
|
||||
size,
|
||||
side);
|
||||
}
|
||||
|
||||
public InvTracker(int x, int y, int z, int dim, long sortValue, final IInventory patterns,
|
||||
final String unlocalizedName, int offset, int size, ForgeDirection side) {
|
||||
this.server = patterns;
|
||||
this.client = new AppEngInternalInventory(null, size);
|
||||
this.unlocalizedName = unlocalizedName;
|
||||
this.sortBy = dual.getSortValue() + offset << 16;
|
||||
this.sortBy = sortValue + offset << 16;
|
||||
this.offset = offset;
|
||||
X = dual.getLocation().x;
|
||||
Y = dual.getLocation().y;
|
||||
Z = dual.getLocation().z;
|
||||
dim = dual.getLocation().getDimension();
|
||||
if (dual.getHost() instanceof AEBasePart) {
|
||||
side = ((AEBasePart) dual.getHost()).getSide();
|
||||
} else {
|
||||
side = ForgeDirection.UNKNOWN;
|
||||
}
|
||||
this.X = x;
|
||||
this.Y = y;
|
||||
this.Z = z;
|
||||
this.dim = dim;
|
||||
this.side = side;
|
||||
}
|
||||
|
||||
public InvTracker(IInterfaceTerminalSupport terminalSupport,
|
||||
IInterfaceTerminalSupport.PatternsConfiguration configuration, int index) {
|
||||
this(
|
||||
terminalSupport.getLocation(),
|
||||
terminalSupport.getSortValue(),
|
||||
terminalSupport.getPatterns(index),
|
||||
terminalSupport.getName(),
|
||||
configuration.offset,
|
||||
configuration.size,
|
||||
terminalSupport instanceof AEBasePart ? ((AEBasePart) terminalSupport).getSide()
|
||||
: ForgeDirection.UNKNOWN);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -371,47 +388,4 @@ public class ContainerInterfaceWireless extends FCBaseContainer {
|
||||
return itemstack != null && itemstack.getItem() instanceof ItemEncodedPattern;
|
||||
}
|
||||
}
|
||||
|
||||
private class InterfaceCheck {
|
||||
|
||||
int total = 0;
|
||||
boolean missing = false;
|
||||
|
||||
public InterfaceCheck() {}
|
||||
|
||||
public int getTotal() {
|
||||
return total;
|
||||
}
|
||||
|
||||
public boolean isMissing() {
|
||||
return missing;
|
||||
}
|
||||
|
||||
public ContainerInterfaceWireless.InterfaceCheck invoke(IGridNode gn) {
|
||||
if (gn.isActive()) {
|
||||
final IInterfaceHost ih = (IInterfaceHost) gn.getMachine();
|
||||
if (ih.getInterfaceDuality().getConfigManager().getSetting(Settings.INTERFACE_TERMINAL) == YesNo.NO
|
||||
|| ih instanceof PartP2PInterface && ((PartP2PInterface) ih).isOutput()) {
|
||||
return this;
|
||||
}
|
||||
|
||||
final Collection<ContainerInterfaceWireless.InvTracker> t = ContainerInterfaceWireless.this.diList
|
||||
.get(ih);
|
||||
|
||||
if (t.isEmpty()) {
|
||||
missing = true;
|
||||
} else {
|
||||
final DualityInterface dual = ih.getInterfaceDuality();
|
||||
for (ContainerInterfaceWireless.InvTracker it : t) {
|
||||
if (!it.unlocalizedName.equals(dual.getTermName())) {
|
||||
missing = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
total += (ih.getInterfaceDuality().getInstalledUpgrades(Upgrades.PATTERN_CAPACITY) + 1);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,6 @@ public class FCClassTransformer implements IClassTransformer {
|
||||
case "appeng.crafting.CraftingTreeNode" -> tform = CraftingTreeNodeTransformer.INSTANCE;
|
||||
case "appeng.me.cluster.implementations.CraftingCPUCluster" -> tform = CraftingCpuTransformer.INSTANCE;
|
||||
case "appeng.helpers.DualityInterface" -> tform = DualityInterfaceTransformer.INSTANCE;
|
||||
case "appeng.container.implementations.ContainerInterfaceTerminal" -> tform = ContainerInterfaceTerminalTransformer.INSTANCE;
|
||||
case "appeng.client.gui.implementations.GuiCraftingCPU", "appeng.client.gui.implementations.GuiCraftConfirm", "net.p455w0rd.wirelesscraftingterminal.client.gui.GuiCraftConfirm", "appeng.client.gui.widgets.GuiCraftingTree" -> tform = GuiCraftingTransformer.INSTANCE;
|
||||
case "appeng.integration.modules.NEI" -> tform = NEITransfermer.INSTANCE;
|
||||
case "appeng.core.features.registries.ExternalStorageRegistry" -> tform = ExternalStorageRegistryTransformer.INSTANCE;
|
||||
|
||||
-60
@@ -1,60 +0,0 @@
|
||||
package com.glodblock.github.coremod.transform;
|
||||
|
||||
import org.objectweb.asm.ClassVisitor;
|
||||
import org.objectweb.asm.MethodVisitor;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
|
||||
import com.glodblock.github.coremod.FCClassTransformer;
|
||||
|
||||
public class ContainerInterfaceTerminalTransformer extends FCClassTransformer.ClassMapper {
|
||||
|
||||
public static final ContainerInterfaceTerminalTransformer INSTANCE = new ContainerInterfaceTerminalTransformer();
|
||||
|
||||
private ContainerInterfaceTerminalTransformer() {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ClassVisitor getClassMapper(ClassVisitor downstream) {
|
||||
return new TransformContainerInterfaceTerminal(Opcodes.ASM5, downstream);
|
||||
}
|
||||
|
||||
private static class TransformContainerInterfaceTerminal extends ClassVisitor {
|
||||
|
||||
TransformContainerInterfaceTerminal(int api, ClassVisitor cv) {
|
||||
super(api, cv);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
|
||||
if (name.equals("detectAndSendChanges") || name.equals("func_75142_b") || name.equals("regenList")) {
|
||||
return new TransformDetectAndSendChanges(
|
||||
api,
|
||||
super.visitMethod(access, name, desc, signature, exceptions));
|
||||
}
|
||||
return super.visitMethod(access, name, desc, signature, exceptions);
|
||||
}
|
||||
}
|
||||
|
||||
private static class TransformDetectAndSendChanges extends MethodVisitor {
|
||||
|
||||
TransformDetectAndSendChanges(int api, MethodVisitor mv) {
|
||||
super(api, mv);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) {
|
||||
if (opcode == Opcodes.INVOKEINTERFACE && owner.equals("appeng/api/networking/IGrid")
|
||||
&& name.equals("getMachines")) {
|
||||
super.visitMethodInsn(
|
||||
Opcodes.INVOKESTATIC,
|
||||
"com/glodblock/github/coremod/hooker/CoreModHooks",
|
||||
"getMachines",
|
||||
"(Lappeng/api/networking/IGrid;Ljava/lang/Class;)Lappeng/api/networking/IMachineSet;",
|
||||
false);
|
||||
} else {
|
||||
super.visitMethodInsn(opcode, owner, name, desc, itf);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -97,11 +97,15 @@ public class CPacketRenamer implements IMessage {
|
||||
|
||||
public static class Handler implements IMessageHandler<CPacketRenamer, IMessage> {
|
||||
|
||||
private String getName(ICustomNameObject obj) {
|
||||
return obj.hasCustomName() ? obj.getCustomName() : "";
|
||||
}
|
||||
|
||||
private String getName(TileEntity tile, ForgeDirection side) {
|
||||
if (tile instanceof TileCableBus) {
|
||||
return ((ICustomNameObject) ((TileCableBus) tile).getPart(side)).getCustomName();
|
||||
return getName((ICustomNameObject) ((TileCableBus) tile).getPart(side));
|
||||
} else {
|
||||
return ((ICustomNameObject) tile).getCustomName();
|
||||
return getName((ICustomNameObject) tile);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,9 @@ import net.minecraft.item.ItemStack;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.common.Config;
|
||||
import com.glodblock.github.common.parts.PartFluidInterface;
|
||||
import com.glodblock.github.common.parts.PartFluidP2PInterface;
|
||||
import com.glodblock.github.common.tile.TileFluidInterface;
|
||||
import com.glodblock.github.common.tile.TileWalrus;
|
||||
import com.glodblock.github.crossmod.extracells.EC2Replacer;
|
||||
import com.glodblock.github.crossmod.thaumcraft.AspectUtil;
|
||||
@@ -66,6 +68,8 @@ public class CommonProxy {
|
||||
}
|
||||
AEApi.instance().registries().externalStorage().addExternalStorageInterface(new AEFluidInterfaceHandler());
|
||||
InterfaceTerminalSupportedClassProvider.register(PartFluidP2PInterface.class);
|
||||
InterfaceTerminalSupportedClassProvider.register(PartFluidInterface.class);
|
||||
InterfaceTerminalSupportedClassProvider.register(TileFluidInterface.class);
|
||||
}
|
||||
|
||||
public void registerRenderers() {}
|
||||
|
||||
Reference in new issue
Block a user