aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormakamys <makamys@outlook.com>2023-05-16 23:06:06 +0200
committermakamys <makamys@outlook.com>2023-05-16 23:39:39 +0200
commita2c230a4bf3659c99af90ecd5eeeab8e6d32c478 (patch)
tree8d1b02e35d4a674a08c2c29306f133f4e31ef1f7 /src
parent2a226d6b9ea7a8fdea6e1922f9c3646277d5a1d4 (diff)
downloadNeodymium-a2c230a4bf3659c99af90ecd5eeeab8e6d32c478.tar.gz
Neodymium-a2c230a4bf3659c99af90ecd5eeeab8e6d32c478.tar.bz2
Neodymium-a2c230a4bf3659c99af90ecd5eeeab8e6d32c478.zip
Only show warning once per session
Diffstat (limited to 'src')
-rw-r--r--src/main/java/makamys/neodymium/Neodymium.java8
-rw-r--r--src/main/java/makamys/neodymium/renderer/ChunkMesh.java3
-rw-r--r--src/main/java/makamys/neodymium/util/WarningHelper.java24
3 files changed, 34 insertions, 1 deletions
diff --git a/src/main/java/makamys/neodymium/Neodymium.java b/src/main/java/makamys/neodymium/Neodymium.java
index cab2e54..00e9846 100644
--- a/src/main/java/makamys/neodymium/Neodymium.java
+++ b/src/main/java/makamys/neodymium/Neodymium.java
@@ -21,6 +21,7 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerAboutToStartEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
+import cpw.mods.fml.common.network.FMLNetworkEvent.ClientConnectedToServerEvent;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import makamys.mclib.core.MCLib;
@@ -30,6 +31,7 @@ import makamys.neodymium.command.NeodymiumCommand;
import makamys.neodymium.config.Config;
import makamys.neodymium.renderer.NeoRenderer;
import makamys.neodymium.util.ChatUtil;
+import makamys.neodymium.util.WarningHelper;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
@@ -120,6 +122,12 @@ public class Neodymium
}
}
+ @SubscribeEvent
+ @SideOnly(Side.CLIENT)
+ public void onConnectToServer(ClientConnectedToServerEvent event) {
+ WarningHelper.reset();
+ }
+
public static boolean isActive() {
return renderer != null && renderer.hasInited && !renderer.destroyPending;
}
diff --git a/src/main/java/makamys/neodymium/renderer/ChunkMesh.java b/src/main/java/makamys/neodymium/renderer/ChunkMesh.java
index 6f637fc..9dd0af0 100644
--- a/src/main/java/makamys/neodymium/renderer/ChunkMesh.java
+++ b/src/main/java/makamys/neodymium/renderer/ChunkMesh.java
@@ -17,6 +17,7 @@ import makamys.neodymium.ducks.IWorldRenderer;
import makamys.neodymium.util.BufferWriter;
import makamys.neodymium.util.RecyclingList;
import makamys.neodymium.util.Util;
+import makamys.neodymium.util.WarningHelper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.WorldRenderer;
@@ -137,7 +138,7 @@ public class ChunkMesh extends Mesh {
LOGGER.error("Skipping chunk due to errors.");
quadBuf.reset();
} else {
- LOGGER.debug("Warnings in chunk ({}, {}, {}) in dimension {}: {}", x, y, z, dimId, String.join(", ", warnings));
+ WarningHelper.showDebugMessageOnce(String.format("Warnings in chunk (%d, %d, %d) in dimension %s: %s", x, y, z, dimId, String.join(", ", warnings)));
}
}
}
diff --git a/src/main/java/makamys/neodymium/util/WarningHelper.java b/src/main/java/makamys/neodymium/util/WarningHelper.java
new file mode 100644
index 0000000..1204aef
--- /dev/null
+++ b/src/main/java/makamys/neodymium/util/WarningHelper.java
@@ -0,0 +1,24 @@
+package makamys.neodymium.util;
+
+import static makamys.neodymium.Constants.LOGGER;
+
+import java.util.HashSet;
+import java.util.Set;
+
+public class WarningHelper {
+
+ private static Set<Integer> shownWarnings = new HashSet<>();
+
+ public static void showDebugMessageOnce(String warning) {
+ int hash = warning.hashCode();
+ if(!shownWarnings.contains(hash)) {
+ LOGGER.debug(warning);
+ shownWarnings.add(hash);
+ }
+ }
+
+ public static void reset() {
+ shownWarnings.clear();
+ }
+
+}