diff --git a/gradle.properties b/gradle.properties index 9faa1285..eb41c51e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -17,7 +17,7 @@ modGroup=com.elytradev modVersion=5 modBaseName=teckle -forgeVersion=1.12.1-14.22.0.2456 +forgeVersion=1.12.1-14.22.0.2473 mcpVersion=snapshot_20170806 #JEI Stuff diff --git a/src/main/java/com/elytradev/teckle/client/MissingOreExceptionClient.java b/src/main/java/com/elytradev/teckle/client/MissingOreExceptionClient.java index def41dc1..a15596db 100644 --- a/src/main/java/com/elytradev/teckle/client/MissingOreExceptionClient.java +++ b/src/main/java/com/elytradev/teckle/client/MissingOreExceptionClient.java @@ -7,12 +7,16 @@ public class MissingOreExceptionClient extends CustomModLoadingErrorDisplayException { private String title; - private String message; + private String[] message; public MissingOreExceptionClient(String message, Throwable cause) { super(message, cause); this.title = "Teckle is missing ores!"; - this.message = message; + this.message = new String[4]; + for (int i = 0; i < message.split("\n").length; i++) { + // Split new lines for rendering. + this.message[i] = message.split("\n")[i]; + } } @Override @@ -22,6 +26,9 @@ public void initGui(GuiErrorScreen errorScreen, FontRenderer fontRenderer) { @Override public void drawScreen(GuiErrorScreen errorScreen, FontRenderer fontRenderer, int mouseRelX, int mouseRelY, float tickTime) { errorScreen.drawCenteredString(errorScreen.mc.fontRenderer, this.title, errorScreen.width / 2, 90, 16777215); - errorScreen.drawCenteredString(errorScreen.mc.fontRenderer, this.message, errorScreen.width / 2, 110, 16777215); + for (int i = 0; i < this.message.length; i++) { + String m = this.message[i]; + errorScreen.drawCenteredString(errorScreen.mc.fontRenderer, m, errorScreen.width / 2, 110 + (i * 10), 16777215); + } } } diff --git a/src/main/java/com/elytradev/teckle/client/proxy/ClientProxy.java b/src/main/java/com/elytradev/teckle/client/proxy/ClientProxy.java index 50b21c5c..a8d51d4c 100644 --- a/src/main/java/com/elytradev/teckle/client/proxy/ClientProxy.java +++ b/src/main/java/com/elytradev/teckle/client/proxy/ClientProxy.java @@ -175,6 +175,6 @@ public void registerHandlers() { @Override public void handleMissingOres(String m) { // FML doesn't seem to work properly but this will still cause the game to exit for now. - throw new MissingOreExceptionClient(m, new MissingOreException(m)); + throw new MissingOreExceptionClient(m, new MissingOreException(m.replaceAll("\n", ""))); } } diff --git a/src/main/java/com/elytradev/teckle/common/TeckleObjects.java b/src/main/java/com/elytradev/teckle/common/TeckleObjects.java index 20c0267d..d7c94d22 100644 --- a/src/main/java/com/elytradev/teckle/common/TeckleObjects.java +++ b/src/main/java/com/elytradev/teckle/common/TeckleObjects.java @@ -130,10 +130,10 @@ public void init(FMLInitializationEvent e) { boolean foundMatchingOres = foundSilver && foundTin && foundCopper; if (!foundMatchingOres && !TeckleMod.INDEV && !TeckleMod.CONFIG.skipOreChecks) { - String additionalData = (foundSilver ? "Found " : "Couldn't find ") + "silver ingots. "; - additionalData += (foundTin ? "Found " : "Couldn't find ") + "tin ingots. "; - additionalData += (foundCopper ? "Found " : "Couldn't find ") + "copper ingots."; - TeckleMod.PROXY.handleMissingOres("Teckle is missing ores, Tin, Silver, and Copper must be present to run. " + additionalData); + String additionalData = "\n" + "Silver ingots " + (foundSilver ? "✔" : "✘"); + additionalData += "\n" + "Tin ingots " + (foundTin ? "✔" : "✘"); + additionalData += "\n" + "Copper ingots " + (foundCopper ? "✔" : "✘"); + TeckleMod.PROXY.handleMissingOres("Tin, Silver, and Copper must be present to run. " + additionalData); } } diff --git a/src/main/java/com/elytradev/teckle/common/exception/MissingOreException.java b/src/main/java/com/elytradev/teckle/common/exception/MissingOreException.java index b4aa8cf2..11aef011 100644 --- a/src/main/java/com/elytradev/teckle/common/exception/MissingOreException.java +++ b/src/main/java/com/elytradev/teckle/common/exception/MissingOreException.java @@ -2,6 +2,6 @@ public class MissingOreException extends RuntimeException { public MissingOreException(String data) { - super(data); + super("Teckle is missing ores, " + data.replaceAll("\n", "")); } } diff --git a/src/main/java/com/elytradev/teckle/common/proxy/CommonProxy.java b/src/main/java/com/elytradev/teckle/common/proxy/CommonProxy.java index 8ba9026e..abe10148 100644 --- a/src/main/java/com/elytradev/teckle/common/proxy/CommonProxy.java +++ b/src/main/java/com/elytradev/teckle/common/proxy/CommonProxy.java @@ -30,7 +30,6 @@ import java.util.Objects; - public class CommonProxy { public void registerRenderers(LoaderState.ModState state) { diff --git a/src/main/java/com/elytradev/teckle/common/tile/inv/pool/AdvancedStackHandlerPool.java b/src/main/java/com/elytradev/teckle/common/tile/inv/pool/AdvancedStackHandlerPool.java index fe90c284..46222948 100644 --- a/src/main/java/com/elytradev/teckle/common/tile/inv/pool/AdvancedStackHandlerPool.java +++ b/src/main/java/com/elytradev/teckle/common/tile/inv/pool/AdvancedStackHandlerPool.java @@ -22,6 +22,7 @@ public class AdvancedStackHandlerPool extends WorldSavedData { private static final HashMap FALLBACK_POOLS = Maps.newHashMap(); private Map registeredHandlers = Maps.newHashMap(); + private int dimension = 0; public AdvancedStackHandlerPool(String name) { super(name); @@ -59,12 +60,14 @@ public static AdvancedStackHandlerPool getPool(@Nonnull World world) { public static AdvancedStackHandlerPool getPool(Integer dim) { if (!DIMENSION_POOLS.containsKey(dim)) { DIMENSION_POOLS.put(dim, new AdvancedStackHandlerPool()); + DIMENSION_POOLS.get(dim).dimension = dim; if (FMLCommonHandler.instance().getEffectiveSide().isServer()) { getSavedPool(DimensionManager.getWorld(dim)); } } if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { FALLBACK_POOLS.put(dim, new AdvancedStackHandlerPool()); + FALLBACK_POOLS.get(dim).dimension = dim; return FALLBACK_POOLS.get(dim); } return DIMENSION_POOLS.get(dim); @@ -170,7 +173,8 @@ public NBTTagCompound writeToNBT(NBTTagCompound tag) { for (int i = 0; i < entries.size(); i++) { tag.setTag("e" + i, entries.get(i)); } - TeckleMod.LOG.debug("Serialized {} stack handlers, skipped {}", entries.size(), skipped); + if (entries.size() != 0) + TeckleMod.LOG.debug("Serialized {} stack handlers in {}, skipped {}", entries.size(), this.dimension, skipped); return tag; } } diff --git a/src/main/java/com/elytradev/teckle/common/worldnetwork/common/WorldNetwork.java b/src/main/java/com/elytradev/teckle/common/worldnetwork/common/WorldNetwork.java index acb73958..8735f8fb 100644 --- a/src/main/java/com/elytradev/teckle/common/worldnetwork/common/WorldNetwork.java +++ b/src/main/java/com/elytradev/teckle/common/worldnetwork/common/WorldNetwork.java @@ -35,6 +35,7 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; import java.util.*; +import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -111,13 +112,25 @@ public void unregisterNodeAtPosition(BlockPos nodePosition, EnumFacing face) { List removedNodeContainers = positionData.getNodeContainers(this.getNetworkID()).stream() .filter(nodeContainer -> faceMatches(face, nodeContainer.getFacing()) && nodeContainer.getPos().equals(nodePosition)) .collect(Collectors.toList()); + + // Tell the removed node that everything else was removed. + removedNodeContainers.stream().filter(nC -> nC.getNetworkTile() != null && nC.getNetworkTile().listenToNetworkChange()) + .forEach(removedContainer -> networkNodes.values().stream() + .flatMap((Function>) posData -> posData.getNodeContainers(getNetworkID()).stream()) + .forEach(nodeContainer -> { + if (!Objects.equals(removedContainer, nodeContainer)) + removedContainer.getNetworkTile().onNodeRemoved(nodeContainer.getNode()); + })); + // Clean position data of any garbage data just in case. positionData.removeIf(getNetworkID(), nodeContainer -> faceMatches(face, nodeContainer.getFacing()) && nodeContainer.getPos().equals(nodePosition)); + // Notify listeners of the removed node. removedNodeContainers.forEach(removedContainer -> listenerNodePositions.stream().map(networkNodes::get).flatMap(pD -> pD.getNodeContainers(getNetworkID()).stream()) .filter(nodeContainer -> nodeContainer.getNode() != null && nodeContainer.getNode().getNetworkTile().listenToNetworkChange()) .forEach(nodeContainer -> nodeContainer.getNode().getNetworkTile().onNodeRemoved(removedContainer.getNode()))); + //Actually remove the nodes from the position data. removedNodeContainers.forEach(removed -> positionData.removeNodeContainer(getNetworkID(), removed)); - // Clean position data of any old stuff. + // Clean positiondata map of empty positions. networkNodes.values().removeIf(posData -> posData.getNodeContainers(getNetworkID()).isEmpty()); checkListeners(); } @@ -237,6 +250,11 @@ public WorldNetwork merge(IWorldNetwork otherNetwork) { WorldNetwork mergedNetwork = new WorldNetwork(this.world, null); this.transferNetworkData(mergedNetwork); otherNetwork.transferNetworkData(mergedNetwork); + mergedNetwork.listenerNodePositions.stream().flatMap((Function>) + blockPos -> mergedNetwork.getNodeContainersAtPosition(blockPos).stream() + .filter(nC -> nC.hasNetworkTile() && nC.getNetworkTile().listenToNetworkChange())).forEach(nodeContainer -> + mergedNetwork.nodeStream().filter(streamedContainer -> streamedContainer != nodeContainer) + .forEach(streamedContainer -> nodeContainer.getNetworkTile().onNodeAdded(streamedContainer.getNode()))); TeckleMod.LOG.debug("Completed merge, resulted in " + mergedNetwork); return mergedNetwork; } @@ -256,7 +274,7 @@ public void transferNetworkData(IWorldNetwork to) { any.ifPresent(blockPosEnumFacingPair -> networkDB.getRemappedNodes().remove(blockPosEnumFacingPair)); if (!node.isLoaded()) { networkDB.getRemappedNodes().put(new MutablePair<>(node.getPosition(), node.getCapabilityFace()), to.getNetworkID()); - TeckleMod.LOG.debug("marking node as remapped " + node.getPosition()); + TeckleMod.LOG.debug("Marking node as remapped " + node.getPosition()); } this.unregisterNode(node); diff --git a/src/main/java/com/elytradev/teckle/common/worldnetwork/common/WorldNetworkDatabase.java b/src/main/java/com/elytradev/teckle/common/worldnetwork/common/WorldNetworkDatabase.java index 82746e0d..c73c8586 100644 --- a/src/main/java/com/elytradev/teckle/common/worldnetwork/common/WorldNetworkDatabase.java +++ b/src/main/java/com/elytradev/teckle/common/worldnetwork/common/WorldNetworkDatabase.java @@ -167,7 +167,8 @@ private NBTTagCompound saveDatabase(NBTTagCompound databaseCompound) { databaseCompound.setUniqueId("rNN" + i, remappedNodes.get(i).getValue()); } - TeckleMod.LOG.debug("Serialized networks in {}, total is {}", world.provider.getDimension(), networks.size()); + if (!networks.isEmpty()) + TeckleMod.LOG.debug("Serialized networks in {}, total is {}", world.provider.getDimension(), networks.size()); return databaseCompound; }