fix channel display

This commit is contained in:
PrototypeTrousers
2023-07-31 02:58:34 -03:00
parent 59c7dd1285
commit e16d90333b
6 changed files with 23 additions and 27 deletions
+2 -3
View File
@@ -143,8 +143,8 @@ public final class AEConfig extends Configuration implements IConfigurableObject
CondenserOutput.SINGULARITY.requiredPower = this.get("Condenser", "Singularity", 256000).getInt(256000);
this.removeCrashingItemsOnLoad = this.get("general", "removeCrashingItemsOnLoad", false, "Will auto-remove items that crash when being loaded from storage. This will destroy those items instead of crashing the game!").getBoolean();
this.normalChannelCapacity = this.get("general", "normalChannelCapacity", this.normalChannelCapacity).getInt(this.normalChannelCapacity);
this.denseChannelCapacity = this.get("general", "denseChannelCapacity", this.denseChannelCapacity).getInt(this.denseChannelCapacity);
this.normalChannelCapacity = Math.min(this.get("general", "normalChannelCapacity", this.normalChannelCapacity, "Max channel number may not exceed 256").getInt(this.normalChannelCapacity), 256);
this.denseChannelCapacity = Math.min(this.get("general", "denseChannelCapacity", this.denseChannelCapacity, "Max channel number may not exceed 256").getInt(this.denseChannelCapacity), 256);
this.setCategoryComment("BlockingMode", "Map of items to not block when blockingmode is enabled.\n[modid]\nmodid:item:metadata(optional,default:0)\nSupports more than one modid, so you can block different things between, for example, gregtech or enderio");
this.nonBlockingItems = this.get("BlockingMode", "nonBlockingItems", nonBlockingItems, "NonBlockingItems").getStringList();
@@ -196,7 +196,6 @@ public final class AEConfig extends Configuration implements IConfigurableObject
this.maxControllerSizeZ = Math.min(Math.max(this.get("ControllerSize", "maxControllerSizeZ", this.maxControllerSizeZ).getInt(this.maxControllerSizeZ), 1), 63);
this.clientSync();
this.addCustomCategoryComment("features", "Warning: Disabling a feature may disable other features depending on it.");
@@ -48,7 +48,7 @@ public class ChannelInfoProvider implements IPartProbInfoProvider {
if (part.getGridNode().isActive()) {
final NBTTagCompound tmp = new NBTTagCompound();
part.writeToNBT(tmp);
usedChannels = tmp.getByte("usedChannels");
usedChannels = tmp.getInteger("usedChannels");
} else {
usedChannels = 0;
}
@@ -26,7 +26,8 @@ import appeng.core.localization.WailaText;
import appeng.parts.networking.PartCableSmart;
import appeng.parts.networking.PartDenseCableSmart;
import it.unimi.dsi.fastutil.objects.Object2ByteMap;
import it.unimi.dsi.fastutil.objects.Object2ByteOpenHashMap;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import net.minecraft.entity.player.EntityPlayerMP;
@@ -59,7 +60,7 @@ public final class ChannelWailaDataProvider extends BasePartWailaDataProvider {
* <p/>
* The cache will be updated from the server.
*/
private final Object2ByteMap<IPart> cache = new Object2ByteOpenHashMap<>();
private final Object2IntMap<IPart> cache = new Object2IntOpenHashMap<>();
/**
* Adds the used and max channel to the tool tip
@@ -78,10 +79,10 @@ public final class ChannelWailaDataProvider extends BasePartWailaDataProvider {
if (part instanceof PartCableSmart || part instanceof PartDenseCableSmart) {
final NBTTagCompound tag = accessor.getNBTData();
final byte usedChannels = this.getUsedChannels(part, tag, this.cache);
final int usedChannels = this.getUsedChannels(part, tag, this.cache);
if (usedChannels >= 0) {
final byte maxChannels = (byte) ((part instanceof PartDenseCableSmart) ? AEConfig.instance().getDenseChannelCapacity() : AEConfig.instance().getNormalChannelCapacity());
final int maxChannels = ((part instanceof PartDenseCableSmart) ? AEConfig.instance().getDenseChannelCapacity() : AEConfig.instance().getNormalChannelCapacity());
final String formattedToolTip = String.format(WailaText.Channels.getLocal(), usedChannels, maxChannels);
currentToolTip.add(formattedToolTip);
@@ -102,11 +103,11 @@ public final class ChannelWailaDataProvider extends BasePartWailaDataProvider {
* @param cache cache with previous knowledge
* @return used channels on the cable
*/
private byte getUsedChannels(final IPart part, final NBTTagCompound tag, final Object2ByteMap<IPart> cache) {
final byte usedChannels;
private int getUsedChannels(final IPart part, final NBTTagCompound tag, final Object2IntMap<IPart> cache) {
final int usedChannels;
if (tag.hasKey(ID_USED_CHANNELS)) {
usedChannels = tag.getByte(ID_USED_CHANNELS);
usedChannels = tag.getInteger(ID_USED_CHANNELS);
this.cache.put(part, usedChannels);
} else if (this.cache.containsKey(part)) {
usedChannels = this.cache.get(part);
@@ -139,9 +140,9 @@ public final class ChannelWailaDataProvider extends BasePartWailaDataProvider {
part.writeToNBT(tempTag);
if (tempTag.hasKey(ID_USED_CHANNELS)) {
final byte usedChannels = tempTag.getByte(ID_USED_CHANNELS);
final int usedChannels = tempTag.getInteger(ID_USED_CHANNELS);
tag.setByte(ID_USED_CHANNELS, usedChannels);
tag.setInteger(ID_USED_CHANNELS, usedChannels);
}
}
+7 -7
View File
@@ -47,7 +47,8 @@ public class GridConnection implements IGridConnection, IPathItem {
private static final String EXISTING_CONNECTION_MESSAGE = "Connection between node [machine=%s, %s] and [machine=%s, %s] on [%s] already exists.";
private static final MENetworkChannelsChanged EVENT = new MENetworkChannelsChanged();
private int channelData = 0;
private int usedChannels = 0;
private int lastUsedChannels = 0;
private Object visitorIterationNumber = null;
private GridNode sideA;
private AEPartLocation fromAtoB;
@@ -118,7 +119,7 @@ public class GridConnection implements IGridConnection, IPathItem {
@Override
public int getUsedChannels() {
return (this.channelData >> 8) & 0xff;
return usedChannels;
}
@Override
@@ -132,7 +133,7 @@ public class GridConnection implements IGridConnection, IPathItem {
@Override
public void setControllerRoute(final IPathItem fast, final boolean zeroOut) {
if (zeroOut) {
this.channelData &= ~0xff;
this.lastUsedChannels = 0;
}
if (this.sideB == fast) {
@@ -155,7 +156,7 @@ public class GridConnection implements IGridConnection, IPathItem {
@Override
public void incrementChannelCount(final int usedChannels) {
this.channelData += usedChannels;
this.lastUsedChannels += usedChannels;
}
@Override
@@ -166,8 +167,7 @@ public class GridConnection implements IGridConnection, IPathItem {
@Override
public void finalizeChannels() {
if (this.getUsedChannels() != this.getLastUsedChannels()) {
this.channelData &= 0xff;
this.channelData |= this.channelData << 8;
this.usedChannels = this.lastUsedChannels;
if (this.sideA.getInternalGrid() != null) {
this.sideA.getInternalGrid().postEventTo(this.sideA, EVENT);
@@ -180,7 +180,7 @@ public class GridConnection implements IGridConnection, IPathItem {
}
private int getLastUsedChannels() {
return this.channelData & 0xff;
return lastUsedChannels;
}
Object getVisitorIterationNumber() {
+2 -6
View File
@@ -77,7 +77,7 @@ public class GridNode implements IGridNode, IPathItem {
}
public int usedChannels() {
return this.lastUsedChannels;
return this.usedChannels;
}
Class<? extends IGridHost> getMachineClass() {
@@ -545,7 +545,7 @@ public class GridNode implements IGridNode, IPathItem {
return;
}
if (this.getLastUsedChannels() != this.getUsedChannels()) {
if (this.lastUsedChannels != this.usedChannels) {
this.lastUsedChannels = this.usedChannels;
if (this.getInternalGrid() != null) {
@@ -554,10 +554,6 @@ public class GridNode implements IGridNode, IPathItem {
}
}
private int getLastUsedChannels() {
return this.lastUsedChannels;
}
public long getLastSecurityKey() {
return this.lastSecurityKey;
}
@@ -234,7 +234,7 @@ public class PartCable extends AEBasePart implements IPartCable {
howMany = Math.max(gc.getUsedChannels(), howMany);
}
data.setByte("usedChannels", (byte) howMany);
data.setInteger("usedChannels", howMany);
}
}
}