mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-27 23:32:57 +00:00
fix: uses IInterfaceTerminalSupport for interface terminal
fix custom target not registered in ae2fc wireless interface terminal
This commit is contained in:
1 parent
1ed32d46dc
commit
b019050f32
2 files changed
+75
-100
No files matched your search
@@ -520,8 +520,9 @@ public class GuiInterfaceTerminalWireless extends FCBaseMEGui implements IDropTo
|
|||||||
try {
|
try {
|
||||||
final long id = Long.parseLong(key.substring(1), Character.MAX_RADIX);
|
final long id = Long.parseLong(key.substring(1), Character.MAX_RADIX);
|
||||||
final NBTTagCompound invData = in.getCompoundTag(key);
|
final NBTTagCompound invData = in.getCompoundTag(key);
|
||||||
|
int size = invData.getInteger("size");
|
||||||
final ClientDCInternalInv current = this
|
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 X = invData.getInteger("x");
|
||||||
int Y = invData.getInteger("y");
|
int Y = invData.getInteger("y");
|
||||||
int Z = invData.getInteger("z");
|
int Z = invData.getInteger("z");
|
||||||
@@ -724,11 +725,12 @@ public class GuiInterfaceTerminalWireless extends FCBaseMEGui implements IDropTo
|
|||||||
: Integer.MAX_VALUE;
|
: 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);
|
ClientDCInternalInv o = this.byId.get(id);
|
||||||
|
|
||||||
if (o == null) {
|
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;
|
this.refreshList = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+70
-97
@@ -11,27 +11,20 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
import com.glodblock.github.client.gui.container.base.FCBaseContainer;
|
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.glodblock.github.inventory.item.IWirelessTerminal;
|
||||||
import com.google.common.collect.HashMultimap;
|
import com.google.common.collect.HashMultimap;
|
||||||
import com.google.common.collect.Multimap;
|
import com.google.common.collect.Multimap;
|
||||||
|
|
||||||
import appeng.api.config.*;
|
|
||||||
import appeng.api.networking.IGrid;
|
import appeng.api.networking.IGrid;
|
||||||
import appeng.api.networking.IGridNode;
|
import appeng.api.networking.IGridNode;
|
||||||
import appeng.api.networking.security.IActionHost;
|
import appeng.api.networking.security.IActionHost;
|
||||||
|
import appeng.api.util.DimensionalCoord;
|
||||||
import appeng.core.sync.network.NetworkHandler;
|
import appeng.core.sync.network.NetworkHandler;
|
||||||
import appeng.core.sync.packets.PacketCompressedNBT;
|
import appeng.core.sync.packets.PacketCompressedNBT;
|
||||||
import appeng.helpers.DualityInterface;
|
import appeng.helpers.*;
|
||||||
import appeng.helpers.IInterfaceHost;
|
|
||||||
import appeng.helpers.InventoryAction;
|
|
||||||
import appeng.items.misc.ItemEncodedPattern;
|
import appeng.items.misc.ItemEncodedPattern;
|
||||||
import appeng.parts.AEBasePart;
|
import appeng.parts.AEBasePart;
|
||||||
import appeng.parts.misc.PartInterface;
|
|
||||||
import appeng.parts.p2p.PartP2PInterface;
|
|
||||||
import appeng.tile.inventory.AppEngInternalInventory;
|
import appeng.tile.inventory.AppEngInternalInventory;
|
||||||
import appeng.tile.misc.TileInterface;
|
|
||||||
import appeng.util.InventoryAdaptor;
|
import appeng.util.InventoryAdaptor;
|
||||||
import appeng.util.Platform;
|
import appeng.util.Platform;
|
||||||
import appeng.util.inv.AdaptorIInventory;
|
import appeng.util.inv.AdaptorIInventory;
|
||||||
@@ -46,7 +39,8 @@ public class ContainerInterfaceWireless extends FCBaseContainer {
|
|||||||
*/
|
*/
|
||||||
private static long autoBase = Long.MIN_VALUE;
|
private static long autoBase = Long.MIN_VALUE;
|
||||||
|
|
||||||
private final Multimap<IInterfaceHost, ContainerInterfaceWireless.InvTracker> diList = HashMultimap.create();
|
private final Multimap<IInterfaceTerminalSupport, ContainerInterfaceWireless.InvTracker> supportedInterfaces = HashMultimap
|
||||||
|
.create();
|
||||||
private final Map<Long, ContainerInterfaceWireless.InvTracker> byId = new HashMap<>();
|
private final Map<Long, ContainerInterfaceWireless.InvTracker> byId = new HashMap<>();
|
||||||
private IGrid grid;
|
private IGrid grid;
|
||||||
private NBTTagCompound data = new NBTTagCompound();
|
private NBTTagCompound data = new NBTTagCompound();
|
||||||
@@ -60,16 +54,6 @@ public class ContainerInterfaceWireless extends FCBaseContainer {
|
|||||||
this.bindPlayerInventory(ip, 14, 0);
|
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
|
@Override
|
||||||
public void detectAndSendChanges() {
|
public void detectAndSendChanges() {
|
||||||
if (Platform.isClient()) {
|
if (Platform.isClient()) {
|
||||||
@@ -88,19 +72,28 @@ public class ContainerInterfaceWireless extends FCBaseContainer {
|
|||||||
if (host != null) {
|
if (host != null) {
|
||||||
final IGridNode agn = host.getActionableNode();
|
final IGridNode agn = host.getActionableNode();
|
||||||
if (agn != null && agn.isActive()) {
|
if (agn != null && agn.isActive()) {
|
||||||
for (final IGridNode gn : this.getMachineNodes()) {
|
for (var clz : InterfaceTerminalSupportedClassProvider.getSupportedClasses()) {
|
||||||
ContainerInterfaceWireless.InterfaceCheck interfaceCheck = new ContainerInterfaceWireless.InterfaceCheck()
|
for (final IGridNode gn : this.grid.getMachines(clz)) {
|
||||||
.invoke(gn);
|
final IInterfaceTerminalSupport interfaceTerminalSupport = (IInterfaceTerminalSupport) gn
|
||||||
total += interfaceCheck.getTotal();
|
.getMachine();
|
||||||
missing |= interfaceCheck.isMissing();
|
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);
|
this.regenList(this.data);
|
||||||
} else {
|
} else {
|
||||||
for (final ContainerInterfaceWireless.InvTracker inv : diList.values()) {
|
for (final ContainerInterfaceWireless.InvTracker inv : supportedInterfaces.values()) {
|
||||||
for (int x = 0; x < inv.client.getSizeInventory(); x++) {
|
for (int x = 0; x < inv.client.getSizeInventory(); x++) {
|
||||||
if (this.isDifferent(inv.server.getStackInSlot(inv.offset + x), inv.client.getStackInSlot(x))) {
|
if (this.isDifferent(inv.server.getStackInSlot(inv.offset + x), inv.client.getStackInSlot(x))) {
|
||||||
this.addItems(this.data, inv, x, 1);
|
this.addItems(this.data, inv, x, 1);
|
||||||
@@ -244,25 +237,23 @@ public class ContainerInterfaceWireless extends FCBaseContainer {
|
|||||||
|
|
||||||
private void regenList(final NBTTagCompound data) {
|
private void regenList(final NBTTagCompound data) {
|
||||||
this.byId.clear();
|
this.byId.clear();
|
||||||
this.diList.clear();
|
this.supportedInterfaces.clear();
|
||||||
|
|
||||||
final IActionHost host = this.getActionHost();
|
final IActionHost host = this.getActionHost();
|
||||||
if (host != null) {
|
if (host != null) {
|
||||||
final IGridNode agn = host.getActionableNode();
|
final IGridNode agn = host.getActionableNode();
|
||||||
if (agn != null && agn.isActive()) {
|
if (agn != null && agn.isActive()) {
|
||||||
for (final IGridNode gn : this.getMachineNodes()) {
|
for (var clz : InterfaceTerminalSupportedClassProvider.getSupportedClasses()) {
|
||||||
final IInterfaceHost ih = (IInterfaceHost) gn.getMachine();
|
for (final IGridNode gn : this.grid.getMachines(clz)) {
|
||||||
final DualityInterface dual = ih.getInterfaceDuality();
|
final IInterfaceTerminalSupport terminalSupport = (IInterfaceTerminalSupport) gn.getMachine();
|
||||||
if (gn.isActive() && dual.getConfigManager().getSetting(Settings.INTERFACE_TERMINAL) == YesNo.YES) {
|
if (!gn.isActive() || !terminalSupport.shouldDisplay()) continue;
|
||||||
for (int i = 0; i <= dual.getInstalledUpgrades(Upgrades.PATTERN_CAPACITY); ++i) {
|
|
||||||
this.diList.put(
|
final var configurations = terminalSupport.getPatternsConfigurations();
|
||||||
ih,
|
|
||||||
new ContainerInterfaceWireless.InvTracker(
|
for (int i = 0; i < configurations.length; ++i) {
|
||||||
dual,
|
this.supportedInterfaces.put(
|
||||||
dual.getPatterns(),
|
terminalSupport,
|
||||||
dual.getTermName(),
|
new ContainerInterfaceWireless.InvTracker(terminalSupport, configurations[i], i));
|
||||||
i * 9,
|
|
||||||
9));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -271,7 +262,7 @@ public class ContainerInterfaceWireless extends FCBaseContainer {
|
|||||||
|
|
||||||
data.setBoolean("clear", true);
|
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.byId.put(inv.which, inv);
|
||||||
this.addItems(data, inv, 0, inv.client.getSizeInventory());
|
this.addItems(data, inv, 0, inv.client.getSizeInventory());
|
||||||
}
|
}
|
||||||
@@ -307,6 +298,7 @@ public class ContainerInterfaceWireless extends FCBaseContainer {
|
|||||||
tag.setInteger("z", inv.Z);
|
tag.setInteger("z", inv.Z);
|
||||||
tag.setInteger("dim", inv.dim);
|
tag.setInteger("dim", inv.dim);
|
||||||
tag.setInteger("side", inv.side.ordinal());
|
tag.setInteger("side", inv.side.ordinal());
|
||||||
|
tag.setInteger("size", inv.client.getSizeInventory());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int x = 0; x < length; x++) {
|
for (int x = 0; x < length; x++) {
|
||||||
@@ -341,22 +333,46 @@ public class ContainerInterfaceWireless extends FCBaseContainer {
|
|||||||
private final int dim;
|
private final int dim;
|
||||||
private final ForgeDirection side;
|
private final ForgeDirection side;
|
||||||
|
|
||||||
public InvTracker(final DualityInterface dual, final IInventory patterns, final String unlocalizedName,
|
public InvTracker(final DimensionalCoord coord, long sortValue, final IInventory patterns,
|
||||||
int offset, int size) {
|
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.server = patterns;
|
||||||
this.client = new AppEngInternalInventory(null, size);
|
this.client = new AppEngInternalInventory(null, size);
|
||||||
this.unlocalizedName = unlocalizedName;
|
this.unlocalizedName = unlocalizedName;
|
||||||
this.sortBy = dual.getSortValue() + offset << 16;
|
this.sortBy = sortValue + offset << 16;
|
||||||
this.offset = offset;
|
this.offset = offset;
|
||||||
X = dual.getLocation().x;
|
this.X = x;
|
||||||
Y = dual.getLocation().y;
|
this.Y = y;
|
||||||
Z = dual.getLocation().z;
|
this.Z = z;
|
||||||
dim = dual.getLocation().getDimension();
|
this.dim = dim;
|
||||||
if (dual.getHost() instanceof AEBasePart) {
|
this.side = side;
|
||||||
side = ((AEBasePart) dual.getHost()).getSide();
|
}
|
||||||
} else {
|
|
||||||
side = ForgeDirection.UNKNOWN;
|
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 +387,4 @@ public class ContainerInterfaceWireless extends FCBaseContainer {
|
|||||||
return itemstack != null && itemstack.getItem() instanceof ItemEncodedPattern;
|
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user