diff options
Diffstat (limited to 'src/main/java/makamys/neodymium')
-rw-r--r-- | src/main/java/makamys/neodymium/renderer/GPUMemoryManager.java | 4 | ||||
-rw-r--r-- | src/main/java/makamys/neodymium/util/ChatUtil.java | 57 | ||||
-rw-r--r-- | src/main/java/makamys/neodymium/util/MCUtil.java | 36 |
3 files changed, 59 insertions, 38 deletions
diff --git a/src/main/java/makamys/neodymium/renderer/GPUMemoryManager.java b/src/main/java/makamys/neodymium/renderer/GPUMemoryManager.java index cb08c43..4f13327 100644 --- a/src/main/java/makamys/neodymium/renderer/GPUMemoryManager.java +++ b/src/main/java/makamys/neodymium/renderer/GPUMemoryManager.java @@ -10,7 +10,7 @@ import makamys.neodymium.Config; import makamys.neodymium.Neodymium; import makamys.neodymium.renderer.Mesh.GPUStatus; import makamys.neodymium.util.GuiHelper; -import makamys.neodymium.util.MCUtil; +import makamys.neodymium.util.ChatUtil; import net.minecraft.util.EnumChatFormatting; /** Manages dynamic memory allocation inside a fixed buffer on the GPU. */ @@ -99,7 +99,7 @@ public class GPUMemoryManager { } if(end() + mesh.bufferSize() >= bufferSize) { - MCUtil.showChatMessage("" + "[" + EnumChatFormatting.LIGHT_PURPLE + Neodymium.MODID + EnumChatFormatting.RESET + "/" + EnumChatFormatting.RED + "ERROR" + EnumChatFormatting.RESET + "] VRAM is full! Reverting to vanilla renderer. Try increasing the VRAM buffer size in the config, if possible."); + ChatUtil.showNeoChatMessage("VRAM is full! Reverting to vanilla renderer. Try increasing the VRAM buffer size in the config, if possible.", ChatUtil.MessageVerbosity.ERROR); Neodymium.renderer.destroyPending = true; // TODO restart renderer with more VRAM allocated when this happens. return; diff --git a/src/main/java/makamys/neodymium/util/ChatUtil.java b/src/main/java/makamys/neodymium/util/ChatUtil.java new file mode 100644 index 0000000..05b31cf --- /dev/null +++ b/src/main/java/makamys/neodymium/util/ChatUtil.java @@ -0,0 +1,57 @@ +package makamys.neodymium.util; + +import static makamys.neodymium.Neodymium.LOGGER; +import static makamys.neodymium.Neodymium.MODID; + +import java.util.HashSet; +import java.util.Set; + +import net.minecraft.client.Minecraft; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.EnumChatFormatting; + +public class ChatUtil { + + private static Set<String> shownChatMessages = new HashSet<>(); + + public static void showChatMessage(String text) { + EntityPlayer player = Minecraft.getMinecraft().thePlayer; + + if(player != null) { + ChatComponentText cc = new ChatComponentText(text); + player.addChatComponentMessage(cc); + } else { + LOGGER.info(text); + } + } + + public static void showNeoChatMessage(String text, MessageVerbosity verbosity) { + showNeoChatMessage(text, verbosity, false); + } + + public static void showNeoChatMessage(String text, MessageVerbosity verbosity, boolean once) { + if(shownChatMessages.contains(text)) return; + + String verbosityText = + verbosity == MessageVerbosity.WARNING + ? EnumChatFormatting.YELLOW + "WARNING" + : verbosity == MessageVerbosity.ERROR + ? EnumChatFormatting.RED + "ERROR" + : + "INFO"; + + ChatUtil.showChatMessage("" + "[" + EnumChatFormatting.LIGHT_PURPLE + MODID + EnumChatFormatting.RESET + "/" + verbosityText + EnumChatFormatting.RESET + "] " + text); + + shownChatMessages.add(text); + } + + public static void resetShownChatMessages() { + shownChatMessages.clear(); + } + + public static enum MessageVerbosity { + INFO, WARNING, ERROR + } + +} diff --git a/src/main/java/makamys/neodymium/util/MCUtil.java b/src/main/java/makamys/neodymium/util/MCUtil.java deleted file mode 100644 index 2e14d16..0000000 --- a/src/main/java/makamys/neodymium/util/MCUtil.java +++ /dev/null @@ -1,36 +0,0 @@ -package makamys.neodymium.util; - -import static makamys.neodymium.Neodymium.LOGGER; - -import net.minecraft.client.Minecraft; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.ChatComponentText; -import net.minecraft.world.biome.BiomeGenBase; - -public class MCUtil { - - public static float getBiomeTemperatureVanilla(BiomeGenBase biome, int p_150564_1_, int p_150564_2_, int p_150564_3_){ - if (p_150564_2_ > 64) - { - float f = (float)BiomeGenBase.temperatureNoise - .func_151601_a((double)p_150564_1_ * 1.0D / 8.0D, (double)p_150564_3_ * 1.0D / 8.0D) * 4.0F; - return biome.temperature - (f + (float)p_150564_2_ - 64.0F) * 0.05F / 30.0F; - } - else - { - return biome.temperature; - } - } - - public static void showChatMessage(String text) { - EntityPlayer player = Minecraft.getMinecraft().thePlayer; - - if(player != null) { - ChatComponentText cc = new ChatComponentText(text); - player.addChatComponentMessage(cc); - } else { - LOGGER.info(text); - } - } - -} |