diff --git a/src/main/java/appeng/core/AEConfig.java b/src/main/java/appeng/core/AEConfig.java index befc59c99..7909e3cf5 100644 --- a/src/main/java/appeng/core/AEConfig.java +++ b/src/main/java/appeng/core/AEConfig.java @@ -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."); diff --git a/src/main/java/appeng/integration/modules/theoneprobe/part/ChannelInfoProvider.java b/src/main/java/appeng/integration/modules/theoneprobe/part/ChannelInfoProvider.java index 0086d8630..a344e474f 100644 --- a/src/main/java/appeng/integration/modules/theoneprobe/part/ChannelInfoProvider.java +++ b/src/main/java/appeng/integration/modules/theoneprobe/part/ChannelInfoProvider.java @@ -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; } diff --git a/src/main/java/appeng/integration/modules/waila/part/ChannelWailaDataProvider.java b/src/main/java/appeng/integration/modules/waila/part/ChannelWailaDataProvider.java index 4dd8abd43..2767911e9 100644 --- a/src/main/java/appeng/integration/modules/waila/part/ChannelWailaDataProvider.java +++ b/src/main/java/appeng/integration/modules/waila/part/ChannelWailaDataProvider.java @@ -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 { *

* The cache will be updated from the server. */ - private final Object2ByteMap cache = new Object2ByteOpenHashMap<>(); + private final Object2IntMap 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 cache) { - final byte usedChannels; + private int getUsedChannels(final IPart part, final NBTTagCompound tag, final Object2IntMap 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); } } diff --git a/src/main/java/appeng/me/GridConnection.java b/src/main/java/appeng/me/GridConnection.java index ea0b3b59b..4aa405475 100644 --- a/src/main/java/appeng/me/GridConnection.java +++ b/src/main/java/appeng/me/GridConnection.java @@ -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() { diff --git a/src/main/java/appeng/me/GridNode.java b/src/main/java/appeng/me/GridNode.java index c32cd636f..390015d5f 100644 --- a/src/main/java/appeng/me/GridNode.java +++ b/src/main/java/appeng/me/GridNode.java @@ -77,7 +77,7 @@ public class GridNode implements IGridNode, IPathItem { } public int usedChannels() { - return this.lastUsedChannels; + return this.usedChannels; } Class 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; } diff --git a/src/main/java/appeng/parts/networking/PartCable.java b/src/main/java/appeng/parts/networking/PartCable.java index be3e1653c..a1abd8748 100644 --- a/src/main/java/appeng/parts/networking/PartCable.java +++ b/src/main/java/appeng/parts/networking/PartCable.java @@ -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); } } }