From 7c00af18febf6c0b833c7633b4fb60a9a1bb93af Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Sat, 16 Oct 2021 15:50:41 -0400 Subject: Code Clean Up (#2) * intellij code clean up * optimize imports * format * intellij suggestions * fix empty catch issues --- .../notenoughupdates/NotEnoughUpdates.java | 141 ++++++++------------- 1 file changed, 56 insertions(+), 85 deletions(-) (limited to 'src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java index 6a0d3ab4..29eaf38e 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java @@ -1,85 +1,45 @@ package io.github.moulberry.notenoughupdates; -import com.google.common.collect.Lists; import com.google.common.collect.Sets; import com.google.gson.Gson; import com.google.gson.GsonBuilder; -import com.google.gson.JsonElement; import com.google.gson.JsonObject; -import io.github.moulberry.notenoughupdates.auction.CustomAHGui; -import io.github.moulberry.notenoughupdates.collectionlog.GuiCollectionLog; import io.github.moulberry.notenoughupdates.commands.Commands; -import io.github.moulberry.notenoughupdates.commands.SimpleCommand; import io.github.moulberry.notenoughupdates.core.BackgroundBlur; -import io.github.moulberry.notenoughupdates.core.GuiScreenElementWrapper; -import io.github.moulberry.notenoughupdates.core.config.GuiPositionEditor; -import io.github.moulberry.notenoughupdates.core.util.MiscUtils; import io.github.moulberry.notenoughupdates.cosmetics.CapeManager; -import io.github.moulberry.notenoughupdates.cosmetics.GuiCosmetics; import io.github.moulberry.notenoughupdates.dungeons.DungeonMap; -import io.github.moulberry.notenoughupdates.dungeons.DungeonWin; -import io.github.moulberry.notenoughupdates.dungeons.GuiDungeonMapEditor; -import io.github.moulberry.notenoughupdates.gamemodes.GuiGamemodes; import io.github.moulberry.notenoughupdates.miscfeatures.*; -import io.github.moulberry.notenoughupdates.miscgui.*; -import io.github.moulberry.notenoughupdates.miscgui.tutorials.NeuTutorial; +import io.github.moulberry.notenoughupdates.miscgui.CalendarOverlay; +import io.github.moulberry.notenoughupdates.miscgui.InventoryStorageSelector; import io.github.moulberry.notenoughupdates.options.NEUConfig; -import io.github.moulberry.notenoughupdates.options.NEUConfigEditor; import io.github.moulberry.notenoughupdates.overlays.FuelBar; import io.github.moulberry.notenoughupdates.overlays.OverlayManager; -import io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer; -import io.github.moulberry.notenoughupdates.profileviewer.PlayerStats; import io.github.moulberry.notenoughupdates.profileviewer.ProfileViewer; import io.github.moulberry.notenoughupdates.util.SBInfo; -import io.github.moulberry.notenoughupdates.util.Constants; import io.github.moulberry.notenoughupdates.util.Utils; import io.github.moulberry.notenoughupdates.util.XPInformation; -import net.minecraft.block.material.MapColor; import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.AbstractClientPlayer; -import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.resources.IReloadableResourceManager; import net.minecraft.client.settings.KeyBinding; -import net.minecraft.command.ICommandSender; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.event.ClickEvent; -import net.minecraft.item.ItemMap; -import net.minecraft.item.ItemStack; import net.minecraft.scoreboard.ScoreObjective; import net.minecraft.scoreboard.Scoreboard; -import net.minecraft.util.*; -import net.minecraft.world.storage.MapData; -import net.minecraftforge.client.ClientCommandHandler; -import net.minecraftforge.common.ForgeVersion; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.client.registry.ClientRegistry; -import net.minecraftforge.fml.common.Loader; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; -import net.minecraftforge.fml.common.ModContainer; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; -import org.apache.commons.lang3.StringUtils; -import org.apache.commons.lang3.text.WordUtils; -import org.lwjgl.opengl.Display; -import org.lwjgl.opengl.GL11; import java.awt.*; -import java.awt.datatransfer.StringSelection; import java.io.*; -import java.lang.management.ManagementFactory; -import java.net.URI; -import java.net.URISyntaxException; import java.nio.charset.StandardCharsets; -import java.util.*; -import java.util.List; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; +import java.util.HashMap; +import java.util.Set; @Mod(modid = NotEnoughUpdates.MODID, version = NotEnoughUpdates.VERSION, clientSideOnly = true) public class NotEnoughUpdates { @@ -97,10 +57,11 @@ public class NotEnoughUpdates { private File configFile; - public File getConfigFile(){ + public File getConfigFile() { return this.configFile; } - public void newConfigFile(){ + + public void newConfigFile() { this.configFile = new File(NotEnoughUpdates.INSTANCE.getNeuDir(), "configNew.json"); } @@ -110,16 +71,15 @@ public class NotEnoughUpdates { private String currChatMessage = null; //Stolen from Biscut and used for detecting whether in skyblock - private static final Set SKYBLOCK_IN_ALL_LANGUAGES = Sets.newHashSet("SKYBLOCK","\u7A7A\u5C9B\u751F\u5B58", "\u7A7A\u5CF6\u751F\u5B58"); + private static final Set SKYBLOCK_IN_ALL_LANGUAGES = Sets.newHashSet("SKYBLOCK", "\u7A7A\u5C9B\u751F\u5B58", "\u7A7A\u5CF6\u751F\u5B58"); public GuiScreen openGui = null; public long lastOpenedGui = 0; public Commands commands; - - public static HashMap petRarityToColourMap = new HashMap<>(); + static { petRarityToColourMap.put("UNKNOWN", EnumChatFormatting.RED.toString()); @@ -135,15 +95,16 @@ public class NotEnoughUpdates { public boolean packDevEnabled = false; - private Gson gson = new GsonBuilder().setPrettyPrinting().excludeFieldsWithoutExposeAnnotation().create(); + private final Gson gson = new GsonBuilder().setPrettyPrinting().excludeFieldsWithoutExposeAnnotation().create(); private File neuDir; - public File getNeuDir(){ return this.neuDir;} + public File getNeuDir() {return this.neuDir;} public Color[][] colourMap = null; /** * Instantiates NEUIo, NEUManager and NEUOverlay instances. Registers keybinds and adds a shutdown hook to clear tmp folder. + * * @param event */ @EventHandler @@ -155,10 +116,10 @@ public class NotEnoughUpdates { configFile = new File(neuDir, "configNew.json"); - if(configFile.exists()) { - try(BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(configFile), StandardCharsets.UTF_8))) { + if (configFile.exists()) { + try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(configFile), StandardCharsets.UTF_8))) { config = gson.fromJson(reader, NEUConfig.class); - } catch(Exception e) { } + } catch (Exception ignored) {} } ItemCustomizeManager.loadCustomization(new File(neuDir, "itemCustomization.json")); @@ -167,7 +128,7 @@ public class NotEnoughUpdates { PetInfoOverlay.loadConfig(new File(neuDir, "petCache.json")); SlotLocking.getInstance().loadConfig(new File(neuDir, "slotLocking.json")); - if(config == null) { + if (config == null) { config = new NEUConfig(); saveConfig(); } @@ -198,10 +159,10 @@ public class NotEnoughUpdates { MinecraftForge.EVENT_BUS.register(SlotLocking.getInstance()); MinecraftForge.EVENT_BUS.register(FishingHelper.getInstance()); - if(Minecraft.getMinecraft().getResourceManager() instanceof IReloadableResourceManager) { - ((IReloadableResourceManager)Minecraft.getMinecraft().getResourceManager()).registerReloadListener(CustomSkulls.getInstance()); - ((IReloadableResourceManager)Minecraft.getMinecraft().getResourceManager()).registerReloadListener(NPCRetexturing.getInstance()); - ((IReloadableResourceManager)Minecraft.getMinecraft().getResourceManager()).registerReloadListener(new ItemCustomizeManager.ReloadListener()); + if (Minecraft.getMinecraft().getResourceManager() instanceof IReloadableResourceManager) { + ((IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager()).registerReloadListener(CustomSkulls.getInstance()); + ((IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager()).registerReloadListener(NPCRetexturing.getInstance()); + ((IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager()).registerReloadListener(new ItemCustomizeManager.ReloadListener()); } this.commands = new Commands(); @@ -213,14 +174,14 @@ public class NotEnoughUpdates { overlay = new NEUOverlay(manager); profileViewer = new ProfileViewer(manager); - for(KeyBinding kb : manager.keybinds) { + for (KeyBinding kb : manager.keybinds) { ClientRegistry.registerKeyBinding(kb); } Runtime.getRuntime().addShutdownHook(new Thread(() -> { File tmp = new File(neuDir, "tmp"); - if(tmp.exists()) { - for(File tmpFile : tmp.listFiles()) { + if (tmp.exists()) { + for (File tmpFile : tmp.listFiles()) { tmpFile.delete(); } tmp.delete(); @@ -233,16 +194,26 @@ public class NotEnoughUpdates { try { configFile.createNewFile(); - try(BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(configFile), StandardCharsets.UTF_8))) { + try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(configFile), StandardCharsets.UTF_8))) { writer.write(gson.toJson(config)); } - } catch(Exception ignored) {} + } catch (Exception ignored) {} - try { ItemCustomizeManager.saveCustomization(new File(neuDir, "itemCustomization.json")); } catch(Exception ignored) {} - try { StorageManager.getInstance().saveConfig(new File(neuDir, "storageItems.json")); } catch(Exception ignored) {} - try { FairySouls.save(new File(neuDir, "collected_fairy_souls.json"), gson); } catch(Exception ignored) {} - try { PetInfoOverlay.saveConfig(new File(neuDir, "petCache.json")); } catch(Exception ignored) {} - try { SlotLocking.getInstance().saveConfig(new File(neuDir, "slotLocking.json")); } catch(Exception ignored) {} + try { + ItemCustomizeManager.saveCustomization(new File(neuDir, "itemCustomization.json")); + } catch (Exception ignored) {} + try { + StorageManager.getInstance().saveConfig(new File(neuDir, "storageItems.json")); + } catch (Exception ignored) {} + try { + FairySouls.save(new File(neuDir, "collected_fairy_souls.json"), gson); + } catch (Exception ignored) {} + try { + PetInfoOverlay.saveConfig(new File(neuDir, "petCache.json")); + } catch (Exception ignored) {} + try { + SlotLocking.getInstance().saveConfig(new File(neuDir, "slotLocking.json")); + } catch (Exception ignored) {} } /** @@ -250,7 +221,7 @@ public class NotEnoughUpdates { * If the last chat message was sent <200 ago, will cache the message for #onTick to handle. */ public void sendChatMessage(String message) { - if(System.currentTimeMillis() - lastChatMessage > CHAT_MSG_COOLDOWN) { + if (System.currentTimeMillis() - lastChatMessage > CHAT_MSG_COOLDOWN) { secondLastChatMessage = lastChatMessage; lastChatMessage = System.currentTimeMillis(); Minecraft.getMinecraft().thePlayer.sendChatMessage(message); @@ -270,22 +241,22 @@ public class NotEnoughUpdates { String other_link = update.get("other_link").getAsString(); ChatComponentText other = null; - if(other_text.length() > 0) { - other = new ChatComponentText(EnumChatFormatting.GRAY+"["+EnumChatFormatting.BLUE+other_text+EnumChatFormatting.GRAY+"]"); + if (other_text.length() > 0) { + other = new ChatComponentText(EnumChatFormatting.GRAY + "[" + EnumChatFormatting.BLUE + other_text + EnumChatFormatting.GRAY + "]"); other.setChatStyle(Utils.createClickStyle(ClickEvent.Action.OPEN_URL, other_link)); } ChatComponentText links = new ChatComponentText(""); ChatComponentText separator = new ChatComponentText( - EnumChatFormatting.GRAY+EnumChatFormatting.BOLD.toString()+EnumChatFormatting.STRIKETHROUGH+(other==null?"--":"-")); - ChatComponentText discord = new ChatComponentText(EnumChatFormatting.GRAY+"["+EnumChatFormatting.BLUE+"Discord"+EnumChatFormatting.GRAY+"]"); + EnumChatFormatting.GRAY + EnumChatFormatting.BOLD.toString() + EnumChatFormatting.STRIKETHROUGH + (other == null ? "--" : "-")); + ChatComponentText discord = new ChatComponentText(EnumChatFormatting.GRAY + "[" + EnumChatFormatting.BLUE + "Discord" + EnumChatFormatting.GRAY + "]"); discord.setChatStyle(Utils.createClickStyle(ClickEvent.Action.OPEN_URL, discord_link)); - ChatComponentText youtube = new ChatComponentText(EnumChatFormatting.GRAY+"["+EnumChatFormatting.RED+"YouTube"+EnumChatFormatting.GRAY+"]"); + ChatComponentText youtube = new ChatComponentText(EnumChatFormatting.GRAY + "[" + EnumChatFormatting.RED + "YouTube" + EnumChatFormatting.GRAY + "]"); youtube.setChatStyle(Utils.createClickStyle(ClickEvent.Action.OPEN_URL, youtube_link)); - ChatComponentText twitch = new ChatComponentText(EnumChatFormatting.GRAY+"["+EnumChatFormatting.DARK_PURPLE+"Twitch"+EnumChatFormatting.GRAY+"]"); + ChatComponentText twitch = new ChatComponentText(EnumChatFormatting.GRAY + "[" + EnumChatFormatting.DARK_PURPLE + "Twitch" + EnumChatFormatting.GRAY + "]"); twitch.setChatStyle(Utils.createClickStyle(ClickEvent.Action.OPEN_URL, twitch_link)); - ChatComponentText release = new ChatComponentText(EnumChatFormatting.GRAY+"["+EnumChatFormatting.GREEN+"Release"+EnumChatFormatting.GRAY+"]"); + ChatComponentText release = new ChatComponentText(EnumChatFormatting.GRAY + "[" + EnumChatFormatting.GREEN + "Release" + EnumChatFormatting.GRAY + "]"); release.setChatStyle(Utils.createClickStyle(ClickEvent.Action.OPEN_URL, update_link)); - ChatComponentText github = new ChatComponentText(EnumChatFormatting.GRAY+"["+EnumChatFormatting.DARK_PURPLE+"GitHub"+EnumChatFormatting.GRAY+"]"); + ChatComponentText github = new ChatComponentText(EnumChatFormatting.GRAY + "[" + EnumChatFormatting.DARK_PURPLE + "GitHub" + EnumChatFormatting.GRAY + "]"); github.setChatStyle(Utils.createClickStyle(ClickEvent.Action.OPEN_URL, github_link)); links.appendSibling(separator); @@ -299,7 +270,7 @@ public class NotEnoughUpdates { links.appendSibling(separator); links.appendSibling(github); links.appendSibling(separator); - if(other != null) { + if (other != null) { links.appendSibling(other); links.appendSibling(separator); } @@ -310,7 +281,7 @@ public class NotEnoughUpdates { @SubscribeEvent public void onTick(TickEvent.ClientTickEvent event) { if (event.phase != TickEvent.Phase.START) return; - if(Minecraft.getMinecraft().thePlayer == null) { + if (Minecraft.getMinecraft().thePlayer == null) { openGui = null; currChatMessage = null; return; @@ -318,14 +289,14 @@ public class NotEnoughUpdates { long currentTime = System.currentTimeMillis(); if (openGui != null) { - if(Minecraft.getMinecraft().thePlayer.openContainer != null) { + if (Minecraft.getMinecraft().thePlayer.openContainer != null) { Minecraft.getMinecraft().thePlayer.closeScreen(); } Minecraft.getMinecraft().displayGuiScreen(openGui); openGui = null; lastOpenedGui = System.currentTimeMillis(); } - if(currChatMessage != null && currentTime - lastChatMessage > CHAT_MSG_COOLDOWN) { + if (currChatMessage != null && currentTime - lastChatMessage > CHAT_MSG_COOLDOWN) { lastChatMessage = currentTime; Minecraft.getMinecraft().thePlayer.sendChatMessage(currChatMessage); currChatMessage = null; @@ -333,7 +304,7 @@ public class NotEnoughUpdates { } public boolean isOnSkyblock() { - if(!config.misc.onlyShowOnSkyblock) return true; + if (!config.misc.onlyShowOnSkyblock) return true; return hasSkyblockScoreboard(); } -- cgit From 9f8867018ef7232c1e17af54c9818ddcafa26759 Mon Sep 17 00:00:00 2001 From: Lulonaut <67191924+Lulonaut@users.noreply.github.com> Date: Sat, 11 Dec 2021 05:13:04 +0100 Subject: Store auctionable items locally to only show price warning if the item can actually have a price (#29) --- src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java | 1 + 1 file changed, 1 insertion(+) (limited to 'src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java index 29eaf38e..c1e1cd0d 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java @@ -127,6 +127,7 @@ public class NotEnoughUpdates { FairySouls.load(new File(neuDir, "collected_fairy_souls.json"), gson); PetInfoOverlay.loadConfig(new File(neuDir, "petCache.json")); SlotLocking.getInstance().loadConfig(new File(neuDir, "slotLocking.json")); + ItemPriceInformation.init(new File(neuDir, "auctionable_items.json"), gson); if (config == null) { config = new NEUConfig(); -- cgit From 58ff94539f7e9fc092c2755bb9aba884abe7f5ee Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Wed, 22 Dec 2021 06:50:31 -0500 Subject: fix /locraw bug, bumped version (#37) closes #35 --- .../io/github/moulberry/notenoughupdates/NotEnoughUpdates.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java index c1e1cd0d..881e3d3c 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java @@ -44,10 +44,10 @@ import java.util.Set; @Mod(modid = NotEnoughUpdates.MODID, version = NotEnoughUpdates.VERSION, clientSideOnly = true) public class NotEnoughUpdates { public static final String MODID = "notenoughupdates"; - public static final String VERSION = "2.0.0-REL"; - public static final String PRE_VERSION = "30.2"; - public static final int VERSION_ID = 20000; - public static final int PRE_VERSION_ID = 3002; + public static final String VERSION = "2.1.0-REL"; + public static final String PRE_VERSION = "0.0"; + public static final int VERSION_ID = 20100; + public static final int PRE_VERSION_ID = 0; public static NotEnoughUpdates INSTANCE = null; -- cgit From ea3ec354ba3bb5b4ac64b8032816b8e4c407f099 Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Tue, 28 Dec 2021 00:49:28 -0500 Subject: more code clean up (#38) --- .../notenoughupdates/NotEnoughUpdates.java | 24 ++++++++-------------- 1 file changed, 9 insertions(+), 15 deletions(-) (limited to 'src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java index 881e3d3c..23b89b44 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java @@ -78,18 +78,15 @@ public class NotEnoughUpdates { public Commands commands; - public static HashMap petRarityToColourMap = new HashMap<>(); - - static { - petRarityToColourMap.put("UNKNOWN", EnumChatFormatting.RED.toString()); - - petRarityToColourMap.put("COMMON", EnumChatFormatting.WHITE.toString()); - petRarityToColourMap.put("UNCOMMON", EnumChatFormatting.GREEN.toString()); - petRarityToColourMap.put("RARE", EnumChatFormatting.BLUE.toString()); - petRarityToColourMap.put("EPIC", EnumChatFormatting.DARK_PURPLE.toString()); - petRarityToColourMap.put("LEGENDARY", EnumChatFormatting.GOLD.toString()); - petRarityToColourMap.put("MYTHIC", EnumChatFormatting.LIGHT_PURPLE.toString()); - } + public static HashMap petRarityToColourMap = new HashMap() {{ + put("UNKNOWN", EnumChatFormatting.RED.toString()); + put("COMMON", EnumChatFormatting.WHITE.toString()); + put("UNCOMMON", EnumChatFormatting.GREEN.toString()); + put("RARE", EnumChatFormatting.BLUE.toString()); + put("EPIC", EnumChatFormatting.DARK_PURPLE.toString()); + put("LEGENDARY", EnumChatFormatting.GOLD.toString()); + put("MYTHIC", EnumChatFormatting.LIGHT_PURPLE.toString()); + }}; public static ProfileViewer profileViewer; @@ -104,8 +101,6 @@ public class NotEnoughUpdates { /** * Instantiates NEUIo, NEUManager and NEUOverlay instances. Registers keybinds and adds a shutdown hook to clear tmp folder. - * - * @param event */ @EventHandler public void preinit(FMLPreInitializationEvent event) { @@ -339,6 +334,5 @@ public class NotEnoughUpdates { hasSkyblockScoreboard = false; } - } } -- cgit From b0b0b7567ec0656c60f2f3e4730c0edace353fb7 Mon Sep 17 00:00:00 2001 From: Roman / Nea Date: Thu, 30 Dec 2021 14:37:02 +0100 Subject: Adding support for more recipe types and forge recipes (#40) * Foundations for support of different crafting recipe types. NeuRecipe is now a base class for a recipe which provides common concepts, such as inputs, outputs and a rendering task. GuiItemRecipe has been reworked to work with this new NeuRecipe. NeuManager now parses said recipes. This should be reworked to be a two step process (first register items, then register recipes). To keep compatibility with older repo versions, NeuRecipes are parse lenient and default to a crafting recipe. New recipes should be added in the `recipes` json field which is an array of json dictionaries, which have a `type` and other fields depending on the `type` of that recipe. This also adds support for having multiple recipes for a single item (e.g. uncrafting storage blocks). * Remove references in existing code * Recipe Generation * ring recipes * recipe generator v2 * quick forge * bugfixes and performance improvements * fix raw craft cost * reload hotm if you open the hotm tree inv * add myself to the changelog * replace quickforge formular with lookup table * do not crash anymore when opening recipes outside of skyblock * format coins differently * remove debug logs * change recipe generator so that it doesnt crash old versions --- .../java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java index 23b89b44..3a6afef8 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java @@ -15,6 +15,7 @@ import io.github.moulberry.notenoughupdates.options.NEUConfig; import io.github.moulberry.notenoughupdates.overlays.FuelBar; import io.github.moulberry.notenoughupdates.overlays.OverlayManager; import io.github.moulberry.notenoughupdates.profileviewer.ProfileViewer; +import io.github.moulberry.notenoughupdates.recipes.RecipeGenerator; import io.github.moulberry.notenoughupdates.util.SBInfo; import io.github.moulberry.notenoughupdates.util.Utils; import io.github.moulberry.notenoughupdates.util.XPInformation; @@ -131,6 +132,7 @@ public class NotEnoughUpdates { MinecraftForge.EVENT_BUS.register(this); MinecraftForge.EVENT_BUS.register(new NEUEventListener(this)); + MinecraftForge.EVENT_BUS.register(new RecipeGenerator(this)); MinecraftForge.EVENT_BUS.register(CapeManager.getInstance()); //MinecraftForge.EVENT_BUS.register(new SBGamemodes()); MinecraftForge.EVENT_BUS.register(new EnchantingSolvers()); -- cgit From c81b6a34ae7bbb70a11f23f49422f2fceffa689c Mon Sep 17 00:00:00 2001 From: Roman / Nea Date: Sun, 16 Jan 2022 01:03:04 +0100 Subject: Add sounds and rework the existing textures to custom Dwarven Mines /… (#51) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Pre Work of custom biomes * Work on auto chunk update, Add Debug command * Added 6 new biomes that are used in crystal hollows * Made it so the biomes are registered in the main class so it loads properly * Add sounds and rework the existing textures to custom Dwarven Mines / CH blocks * Config fixups * make titanium sounds work * Added sounds per gemstone type * fix dwarven mines sounds * stop spamming sound effects with config * Changelog for CH custom blocks * add all the files * Update src/main/resources/assets/notenoughupdates/sounds/titaniumbreak.json * Update src/main/resources/assets/notenoughupdates/sounds/mithrilbreak.json * Update src/main/resources/assets/notenoughupdates/sounds/gemstonetopazbreak.json * Update src/main/resources/assets/notenoughupdates/sounds/gemstonerubybreak.json * Update src/main/resources/assets/notenoughupdates/sounds/gemstonesapphirebreak.json * Update src/main/resources/assets/notenoughupdates/sounds/gemstonejasperbreak.json * Update src/main/resources/assets/notenoughupdates/sounds/gemstoneamethystbreak.json * Update src/main/resources/assets/notenoughupdates/sounds/gemstonejadebreak.json * Update src/main/resources/assets/notenoughupdates/sounds/gemstoneamberbreak.json * Update src/main/java/io/github/moulberry/notenoughupdates/commands/Commands.java * Update src/main/java/io/github/moulberry/notenoughupdates/commands/Commands.java * Update src/main/java/io/github/moulberry/notenoughupdates/commands/Commands.java * Update src/main/java/io/github/moulberry/notenoughupdates/commands/Commands.java * Update src/main/java/io/github/moulberry/notenoughupdates/commands/Commands.java * Update src/main/java/io/github/moulberry/notenoughupdates/commands/Commands.java Co-authored-by: DoKM Co-authored-by: nopothegamer <40329022+nopothegamer@users.noreply.github.com> Co-authored-by: IRONM00N <64110067+IRONM00N@users.noreply.github.com> --- .../notenoughupdates/NotEnoughUpdates.java | 29 +++++++++++++++++++--- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java index 3a6afef8..0cff5de1 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java @@ -9,6 +9,9 @@ import io.github.moulberry.notenoughupdates.core.BackgroundBlur; import io.github.moulberry.notenoughupdates.cosmetics.CapeManager; import io.github.moulberry.notenoughupdates.dungeons.DungeonMap; import io.github.moulberry.notenoughupdates.miscfeatures.*; +import io.github.moulberry.notenoughupdates.miscfeatures.customblockzones.CustomBiomes; +import io.github.moulberry.notenoughupdates.miscfeatures.customblockzones.CustomBlockSounds; +import io.github.moulberry.notenoughupdates.miscfeatures.customblockzones.DwarvenMinesTextures; import io.github.moulberry.notenoughupdates.miscgui.CalendarOverlay; import io.github.moulberry.notenoughupdates.miscgui.InventoryStorageSelector; import io.github.moulberry.notenoughupdates.options.NEUConfig; @@ -28,6 +31,7 @@ import net.minecraft.scoreboard.ScoreObjective; import net.minecraft.scoreboard.Scoreboard; import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.biome.*; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.client.registry.ClientRegistry; import net.minecraftforge.fml.common.Mod; @@ -35,6 +39,7 @@ import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; +import scala.collection.parallel.ParIterableLike; import java.awt.*; import java.io.*; @@ -100,6 +105,17 @@ public class NotEnoughUpdates { public Color[][] colourMap = null; + /** + * Registers the biomes for the crystal hollows here so optifine knows they exists + */ + public static final BiomeGenBase crystalHollowsJungle = (new BiomeGenJungle(101, true)).setColor(5470985).setBiomeName("NeuCrystalHollowsJungle").setFillerBlockMetadata(5470985).setTemperatureRainfall(0.95F, 0.9F); + public static final BiomeGenBase crystalHollowsMagmaFields = (new BiomeGenHell(102)).setColor(16711680).setBiomeName("NeuCrystalHollowsMagmaFields").setDisableRain().setTemperatureRainfall(2.0F, 0.0F); + public static final BiomeGenBase crystalHollowsGoblinHoldout = (new BiomeGenMesa(103, false, false)).setColor(13274213).setBiomeName("NeuCrystalHollowsGoblinHoldout"); + public static final BiomeGenBase crystalHollowsPrecursorRemnants = (new BiomeGenMesa(104, false, true)).setColor(11573093).setBiomeName("NeuCrystalHollowsPrecursorRemnants"); + public static final BiomeGenBase crystalHollowsMithrilDeposit = (new BiomeGenSnow(105, false)).setColor(16777215).setBiomeName("NeuCrystalHollowsMithrilDeposits"); + public static final BiomeGenBase crystalHollowsCrystalNucleus = (new BiomeGenJungle(106, true)).setColor(5470985).setBiomeName("NeuCrystalHollowsCrystalNucleus").setFillerBlockMetadata(5470985).setTemperatureRainfall(0.95F, 0.9F); + + /** * Instantiates NEUIo, NEUManager and NEUOverlay instances. Registers keybinds and adds a shutdown hook to clear tmp folder. */ @@ -145,7 +161,7 @@ public class NotEnoughUpdates { MinecraftForge.EVENT_BUS.register(new FairySouls()); MinecraftForge.EVENT_BUS.register(new CrystalOverlay()); MinecraftForge.EVENT_BUS.register(new ItemCooldowns()); - MinecraftForge.EVENT_BUS.register(new DwarvenMinesTextures()); + MinecraftForge.EVENT_BUS.register(new DwarvenMinesWaypoints()); MinecraftForge.EVENT_BUS.register(new FuelBar()); //MinecraftForge.EVENT_BUS.register(new FancyPortals()); @@ -157,10 +173,15 @@ public class NotEnoughUpdates { MinecraftForge.EVENT_BUS.register(SlotLocking.getInstance()); MinecraftForge.EVENT_BUS.register(FishingHelper.getInstance()); + MinecraftForge.EVENT_BUS.register(new DwarvenMinesTextures()); + MinecraftForge.EVENT_BUS.register(CustomBiomes.INSTANCE); + if (Minecraft.getMinecraft().getResourceManager() instanceof IReloadableResourceManager) { - ((IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager()).registerReloadListener(CustomSkulls.getInstance()); - ((IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager()).registerReloadListener(NPCRetexturing.getInstance()); - ((IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager()).registerReloadListener(new ItemCustomizeManager.ReloadListener()); + IReloadableResourceManager manager = (IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager(); + manager.registerReloadListener(CustomSkulls.getInstance()); + manager.registerReloadListener(NPCRetexturing.getInstance()); + manager.registerReloadListener(new ItemCustomizeManager.ReloadListener()); + manager.registerReloadListener(new CustomBlockSounds.ReloaderListener()); } this.commands = new Commands(); -- cgit From 22cb02adbeb24b7ec98f843bcaba99cebe3e4f03 Mon Sep 17 00:00:00 2001 From: Lulonaut <67191924+Lulonaut@users.noreply.github.com> Date: Fri, 25 Feb 2022 23:05:42 +0100 Subject: Hide Hypixel reforge stats in Reforge Stone lore (#85) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * hide Hypixel reforge stats * unused import? * better comments * 2.1.md 🙂 * 2.1.md 🙂 --- src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java | 1 - 1 file changed, 1 deletion(-) (limited to 'src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java index 0cff5de1..e6cfd7c0 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java @@ -39,7 +39,6 @@ import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; -import scala.collection.parallel.ParIterableLike; import java.awt.*; import java.io.*; -- cgit From b09f774d422263ce15b97d6d0804beddf856176d Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Sun, 27 Feb 2022 11:53:57 -0500 Subject: feat: improve formating :) --- .../notenoughupdates/NotEnoughUpdates.java | 666 +++++++++++---------- 1 file changed, 357 insertions(+), 309 deletions(-) (limited to 'src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java index e6cfd7c0..b6ac71a4 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java @@ -48,313 +48,361 @@ import java.util.Set; @Mod(modid = NotEnoughUpdates.MODID, version = NotEnoughUpdates.VERSION, clientSideOnly = true) public class NotEnoughUpdates { - public static final String MODID = "notenoughupdates"; - public static final String VERSION = "2.1.0-REL"; - public static final String PRE_VERSION = "0.0"; - public static final int VERSION_ID = 20100; - public static final int PRE_VERSION_ID = 0; - - public static NotEnoughUpdates INSTANCE = null; - - public NEUManager manager; - public NEUOverlay overlay; - public NEUConfig config; - - private File configFile; - - public File getConfigFile() { - return this.configFile; - } - - public void newConfigFile() { - this.configFile = new File(NotEnoughUpdates.INSTANCE.getNeuDir(), "configNew.json"); - } - - private static final long CHAT_MSG_COOLDOWN = 200; - private long lastChatMessage = 0; - private long secondLastChatMessage = 0; - private String currChatMessage = null; - - //Stolen from Biscut and used for detecting whether in skyblock - private static final Set SKYBLOCK_IN_ALL_LANGUAGES = Sets.newHashSet("SKYBLOCK", "\u7A7A\u5C9B\u751F\u5B58", "\u7A7A\u5CF6\u751F\u5B58"); - - public GuiScreen openGui = null; - public long lastOpenedGui = 0; - - public Commands commands; - - public static HashMap petRarityToColourMap = new HashMap() {{ - put("UNKNOWN", EnumChatFormatting.RED.toString()); - put("COMMON", EnumChatFormatting.WHITE.toString()); - put("UNCOMMON", EnumChatFormatting.GREEN.toString()); - put("RARE", EnumChatFormatting.BLUE.toString()); - put("EPIC", EnumChatFormatting.DARK_PURPLE.toString()); - put("LEGENDARY", EnumChatFormatting.GOLD.toString()); - put("MYTHIC", EnumChatFormatting.LIGHT_PURPLE.toString()); - }}; - - public static ProfileViewer profileViewer; - - public boolean packDevEnabled = false; - - private final Gson gson = new GsonBuilder().setPrettyPrinting().excludeFieldsWithoutExposeAnnotation().create(); - private File neuDir; - - public File getNeuDir() {return this.neuDir;} - - public Color[][] colourMap = null; - - /** - * Registers the biomes for the crystal hollows here so optifine knows they exists - */ - public static final BiomeGenBase crystalHollowsJungle = (new BiomeGenJungle(101, true)).setColor(5470985).setBiomeName("NeuCrystalHollowsJungle").setFillerBlockMetadata(5470985).setTemperatureRainfall(0.95F, 0.9F); - public static final BiomeGenBase crystalHollowsMagmaFields = (new BiomeGenHell(102)).setColor(16711680).setBiomeName("NeuCrystalHollowsMagmaFields").setDisableRain().setTemperatureRainfall(2.0F, 0.0F); - public static final BiomeGenBase crystalHollowsGoblinHoldout = (new BiomeGenMesa(103, false, false)).setColor(13274213).setBiomeName("NeuCrystalHollowsGoblinHoldout"); - public static final BiomeGenBase crystalHollowsPrecursorRemnants = (new BiomeGenMesa(104, false, true)).setColor(11573093).setBiomeName("NeuCrystalHollowsPrecursorRemnants"); - public static final BiomeGenBase crystalHollowsMithrilDeposit = (new BiomeGenSnow(105, false)).setColor(16777215).setBiomeName("NeuCrystalHollowsMithrilDeposits"); - public static final BiomeGenBase crystalHollowsCrystalNucleus = (new BiomeGenJungle(106, true)).setColor(5470985).setBiomeName("NeuCrystalHollowsCrystalNucleus").setFillerBlockMetadata(5470985).setTemperatureRainfall(0.95F, 0.9F); - - - /** - * Instantiates NEUIo, NEUManager and NEUOverlay instances. Registers keybinds and adds a shutdown hook to clear tmp folder. - */ - @EventHandler - public void preinit(FMLPreInitializationEvent event) { - INSTANCE = this; - - neuDir = new File(event.getModConfigurationDirectory(), "notenoughupdates"); - neuDir.mkdirs(); - - configFile = new File(neuDir, "configNew.json"); - - if (configFile.exists()) { - try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(configFile), StandardCharsets.UTF_8))) { - config = gson.fromJson(reader, NEUConfig.class); - } catch (Exception ignored) {} - } - - ItemCustomizeManager.loadCustomization(new File(neuDir, "itemCustomization.json")); - StorageManager.getInstance().loadConfig(new File(neuDir, "storageItems.json")); - FairySouls.load(new File(neuDir, "collected_fairy_souls.json"), gson); - PetInfoOverlay.loadConfig(new File(neuDir, "petCache.json")); - SlotLocking.getInstance().loadConfig(new File(neuDir, "slotLocking.json")); - ItemPriceInformation.init(new File(neuDir, "auctionable_items.json"), gson); - - if (config == null) { - config = new NEUConfig(); - saveConfig(); - } - - MinecraftForge.EVENT_BUS.register(this); - MinecraftForge.EVENT_BUS.register(new NEUEventListener(this)); - MinecraftForge.EVENT_BUS.register(new RecipeGenerator(this)); - MinecraftForge.EVENT_BUS.register(CapeManager.getInstance()); - //MinecraftForge.EVENT_BUS.register(new SBGamemodes()); - MinecraftForge.EVENT_BUS.register(new EnchantingSolvers()); - MinecraftForge.EVENT_BUS.register(new CalendarOverlay()); - MinecraftForge.EVENT_BUS.register(SBInfo.getInstance()); - MinecraftForge.EVENT_BUS.register(CustomItemEffects.INSTANCE); - MinecraftForge.EVENT_BUS.register(new DungeonMap()); - MinecraftForge.EVENT_BUS.register(new SunTzu()); - MinecraftForge.EVENT_BUS.register(new MiningStuff()); - MinecraftForge.EVENT_BUS.register(new FairySouls()); - MinecraftForge.EVENT_BUS.register(new CrystalOverlay()); - MinecraftForge.EVENT_BUS.register(new ItemCooldowns()); - - MinecraftForge.EVENT_BUS.register(new DwarvenMinesWaypoints()); - MinecraftForge.EVENT_BUS.register(new FuelBar()); - //MinecraftForge.EVENT_BUS.register(new FancyPortals()); - MinecraftForge.EVENT_BUS.register(XPInformation.getInstance()); - MinecraftForge.EVENT_BUS.register(OverlayManager.petInfoOverlay); - MinecraftForge.EVENT_BUS.register(OverlayManager.timersOverlay); - MinecraftForge.EVENT_BUS.register(new NullzeeSphere()); - MinecraftForge.EVENT_BUS.register(InventoryStorageSelector.getInstance()); - MinecraftForge.EVENT_BUS.register(SlotLocking.getInstance()); - MinecraftForge.EVENT_BUS.register(FishingHelper.getInstance()); - - MinecraftForge.EVENT_BUS.register(new DwarvenMinesTextures()); - MinecraftForge.EVENT_BUS.register(CustomBiomes.INSTANCE); - - if (Minecraft.getMinecraft().getResourceManager() instanceof IReloadableResourceManager) { - IReloadableResourceManager manager = (IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager(); - manager.registerReloadListener(CustomSkulls.getInstance()); - manager.registerReloadListener(NPCRetexturing.getInstance()); - manager.registerReloadListener(new ItemCustomizeManager.ReloadListener()); - manager.registerReloadListener(new CustomBlockSounds.ReloaderListener()); - } - - this.commands = new Commands(); - - BackgroundBlur.registerListener(); - - manager = new NEUManager(this, neuDir); - manager.loadItemInformation(); - overlay = new NEUOverlay(manager); - profileViewer = new ProfileViewer(manager); - - for (KeyBinding kb : manager.keybinds) { - ClientRegistry.registerKeyBinding(kb); - } - - Runtime.getRuntime().addShutdownHook(new Thread(() -> { - File tmp = new File(neuDir, "tmp"); - if (tmp.exists()) { - for (File tmpFile : tmp.listFiles()) { - tmpFile.delete(); - } - tmp.delete(); - } - //saveConfig(); - })); - } - - public void saveConfig() { - try { - configFile.createNewFile(); - - try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(configFile), StandardCharsets.UTF_8))) { - writer.write(gson.toJson(config)); - } - } catch (Exception ignored) {} - - try { - ItemCustomizeManager.saveCustomization(new File(neuDir, "itemCustomization.json")); - } catch (Exception ignored) {} - try { - StorageManager.getInstance().saveConfig(new File(neuDir, "storageItems.json")); - } catch (Exception ignored) {} - try { - FairySouls.save(new File(neuDir, "collected_fairy_souls.json"), gson); - } catch (Exception ignored) {} - try { - PetInfoOverlay.saveConfig(new File(neuDir, "petCache.json")); - } catch (Exception ignored) {} - try { - SlotLocking.getInstance().saveConfig(new File(neuDir, "slotLocking.json")); - } catch (Exception ignored) {} - } - - /** - * If the last chat messages was sent >200ms ago, sends the message. - * If the last chat message was sent <200 ago, will cache the message for #onTick to handle. - */ - public void sendChatMessage(String message) { - if (System.currentTimeMillis() - lastChatMessage > CHAT_MSG_COOLDOWN) { - secondLastChatMessage = lastChatMessage; - lastChatMessage = System.currentTimeMillis(); - Minecraft.getMinecraft().thePlayer.sendChatMessage(message); - currChatMessage = null; - } else { - currChatMessage = message; - } - } - - public void displayLinks(JsonObject update) { - String discord_link = update.get("discord_link").getAsString(); - String youtube_link = update.get("youtube_link").getAsString(); - String twitch_link = update.get("twitch_link").getAsString(); - String update_link = update.get("update_link").getAsString(); - String github_link = update.get("github_link").getAsString(); - String other_text = update.get("other_text").getAsString(); - String other_link = update.get("other_link").getAsString(); - - ChatComponentText other = null; - if (other_text.length() > 0) { - other = new ChatComponentText(EnumChatFormatting.GRAY + "[" + EnumChatFormatting.BLUE + other_text + EnumChatFormatting.GRAY + "]"); - other.setChatStyle(Utils.createClickStyle(ClickEvent.Action.OPEN_URL, other_link)); - } - ChatComponentText links = new ChatComponentText(""); - ChatComponentText separator = new ChatComponentText( - EnumChatFormatting.GRAY + EnumChatFormatting.BOLD.toString() + EnumChatFormatting.STRIKETHROUGH + (other == null ? "--" : "-")); - ChatComponentText discord = new ChatComponentText(EnumChatFormatting.GRAY + "[" + EnumChatFormatting.BLUE + "Discord" + EnumChatFormatting.GRAY + "]"); - discord.setChatStyle(Utils.createClickStyle(ClickEvent.Action.OPEN_URL, discord_link)); - ChatComponentText youtube = new ChatComponentText(EnumChatFormatting.GRAY + "[" + EnumChatFormatting.RED + "YouTube" + EnumChatFormatting.GRAY + "]"); - youtube.setChatStyle(Utils.createClickStyle(ClickEvent.Action.OPEN_URL, youtube_link)); - ChatComponentText twitch = new ChatComponentText(EnumChatFormatting.GRAY + "[" + EnumChatFormatting.DARK_PURPLE + "Twitch" + EnumChatFormatting.GRAY + "]"); - twitch.setChatStyle(Utils.createClickStyle(ClickEvent.Action.OPEN_URL, twitch_link)); - ChatComponentText release = new ChatComponentText(EnumChatFormatting.GRAY + "[" + EnumChatFormatting.GREEN + "Release" + EnumChatFormatting.GRAY + "]"); - release.setChatStyle(Utils.createClickStyle(ClickEvent.Action.OPEN_URL, update_link)); - ChatComponentText github = new ChatComponentText(EnumChatFormatting.GRAY + "[" + EnumChatFormatting.DARK_PURPLE + "GitHub" + EnumChatFormatting.GRAY + "]"); - github.setChatStyle(Utils.createClickStyle(ClickEvent.Action.OPEN_URL, github_link)); - - links.appendSibling(separator); - links.appendSibling(discord); - links.appendSibling(separator); - links.appendSibling(youtube); - links.appendSibling(separator); - links.appendSibling(twitch); - links.appendSibling(separator); - links.appendSibling(release); - links.appendSibling(separator); - links.appendSibling(github); - links.appendSibling(separator); - if (other != null) { - links.appendSibling(other); - links.appendSibling(separator); - } - - Minecraft.getMinecraft().thePlayer.addChatMessage(links); - } - - @SubscribeEvent - public void onTick(TickEvent.ClientTickEvent event) { - if (event.phase != TickEvent.Phase.START) return; - if (Minecraft.getMinecraft().thePlayer == null) { - openGui = null; - currChatMessage = null; - return; - } - long currentTime = System.currentTimeMillis(); - - if (openGui != null) { - if (Minecraft.getMinecraft().thePlayer.openContainer != null) { - Minecraft.getMinecraft().thePlayer.closeScreen(); - } - Minecraft.getMinecraft().displayGuiScreen(openGui); - openGui = null; - lastOpenedGui = System.currentTimeMillis(); - } - if (currChatMessage != null && currentTime - lastChatMessage > CHAT_MSG_COOLDOWN) { - lastChatMessage = currentTime; - Minecraft.getMinecraft().thePlayer.sendChatMessage(currChatMessage); - currChatMessage = null; - } - } - - public boolean isOnSkyblock() { - if (!config.misc.onlyShowOnSkyblock) return true; - return hasSkyblockScoreboard(); - } - - private boolean hasSkyblockScoreboard; - - public boolean hasSkyblockScoreboard() { - return hasSkyblockScoreboard; - } - - public void updateSkyblockScoreboard() { - Minecraft mc = Minecraft.getMinecraft(); - - if (mc != null && mc.theWorld != null && mc.thePlayer != null) { - if (mc.isSingleplayer() || mc.thePlayer.getClientBrand() == null || - !mc.thePlayer.getClientBrand().toLowerCase().contains("hypixel")) { - hasSkyblockScoreboard = false; - return; - } - - Scoreboard scoreboard = mc.theWorld.getScoreboard(); - ScoreObjective sidebarObjective = scoreboard.getObjectiveInDisplaySlot(1); - if (sidebarObjective != null) { - String objectiveName = sidebarObjective.getDisplayName().replaceAll("(?i)\\u00A7.", ""); - for (String skyblock : SKYBLOCK_IN_ALL_LANGUAGES) { - if (objectiveName.startsWith(skyblock)) { - hasSkyblockScoreboard = true; - return; - } - } - } - - hasSkyblockScoreboard = false; - } - } + public static final String MODID = "notenoughupdates"; + public static final String VERSION = "2.1.0-REL"; + public static final String PRE_VERSION = "0.0"; + public static final int VERSION_ID = 20100; + public static final int PRE_VERSION_ID = 0; + + public static NotEnoughUpdates INSTANCE = null; + + public NEUManager manager; + public NEUOverlay overlay; + public NEUConfig config; + + private File configFile; + + public File getConfigFile() { + return this.configFile; + } + + public void newConfigFile() { + this.configFile = new File(NotEnoughUpdates.INSTANCE.getNeuDir(), "configNew.json"); + } + + private static final long CHAT_MSG_COOLDOWN = 200; + private long lastChatMessage = 0; + private long secondLastChatMessage = 0; + private String currChatMessage = null; + + //Stolen from Biscut and used for detecting whether in skyblock + private static final Set SKYBLOCK_IN_ALL_LANGUAGES = + Sets.newHashSet("SKYBLOCK", "\u7A7A\u5C9B\u751F\u5B58", "\u7A7A\u5CF6\u751F\u5B58"); + + public GuiScreen openGui = null; + public long lastOpenedGui = 0; + + public Commands commands; + + public static HashMap petRarityToColourMap = new HashMap() {{ + put("UNKNOWN", EnumChatFormatting.RED.toString()); + put("COMMON", EnumChatFormatting.WHITE.toString()); + put("UNCOMMON", EnumChatFormatting.GREEN.toString()); + put("RARE", EnumChatFormatting.BLUE.toString()); + put("EPIC", EnumChatFormatting.DARK_PURPLE.toString()); + put("LEGENDARY", EnumChatFormatting.GOLD.toString()); + put("MYTHIC", EnumChatFormatting.LIGHT_PURPLE.toString()); + }}; + + public static ProfileViewer profileViewer; + + public boolean packDevEnabled = false; + + private final Gson gson = new GsonBuilder().setPrettyPrinting().excludeFieldsWithoutExposeAnnotation().create(); + private File neuDir; + + public File getNeuDir() { + return this.neuDir; + } + + public Color[][] colourMap = null; + + /** + * Registers the biomes for the crystal hollows here so optifine knows they exists + */ + public static final BiomeGenBase crystalHollowsJungle = + (new BiomeGenJungle(101, true)) + .setColor(5470985) + .setBiomeName("NeuCrystalHollowsJungle") + .setFillerBlockMetadata(5470985) + .setTemperatureRainfall(0.95F, 0.9F); + public static final BiomeGenBase crystalHollowsMagmaFields = + (new BiomeGenHell(102)) + .setColor(16711680) + .setBiomeName("NeuCrystalHollowsMagmaFields") + .setDisableRain() + .setTemperatureRainfall(2.0F, 0.0F); + public static final BiomeGenBase crystalHollowsGoblinHoldout = + (new BiomeGenMesa(103, false, false)) + .setColor(13274213) + .setBiomeName("NeuCrystalHollowsGoblinHoldout"); + public static final BiomeGenBase crystalHollowsPrecursorRemnants = + (new BiomeGenMesa(104, false, true)) + .setColor(11573093) + .setBiomeName("NeuCrystalHollowsPrecursorRemnants"); + public static final BiomeGenBase crystalHollowsMithrilDeposit = + (new BiomeGenSnow(105, false)) + .setColor(16777215) + .setBiomeName("NeuCrystalHollowsMithrilDeposits"); + public static final BiomeGenBase crystalHollowsCrystalNucleus = + (new BiomeGenJungle(106, true)) + .setColor(5470985) + .setBiomeName("NeuCrystalHollowsCrystalNucleus") + .setFillerBlockMetadata(5470985) + .setTemperatureRainfall(0.95F, 0.9F); + + /** + * Instantiates NEUIo, NEUManager and NEUOverlay instances. Registers keybinds and adds a shutdown hook to clear tmp folder. + */ + @EventHandler + public void preinit(FMLPreInitializationEvent event) { + INSTANCE = this; + + neuDir = new File(event.getModConfigurationDirectory(), "notenoughupdates"); + neuDir.mkdirs(); + + configFile = new File(neuDir, "configNew.json"); + + if (configFile.exists()) { + try ( + BufferedReader reader = new BufferedReader(new InputStreamReader( + new FileInputStream(configFile), + StandardCharsets.UTF_8 + )) + ) { + config = gson.fromJson(reader, NEUConfig.class); + } catch (Exception ignored) { + } + } + + ItemCustomizeManager.loadCustomization(new File(neuDir, "itemCustomization.json")); + StorageManager.getInstance().loadConfig(new File(neuDir, "storageItems.json")); + FairySouls.load(new File(neuDir, "collected_fairy_souls.json"), gson); + PetInfoOverlay.loadConfig(new File(neuDir, "petCache.json")); + SlotLocking.getInstance().loadConfig(new File(neuDir, "slotLocking.json")); + ItemPriceInformation.init(new File(neuDir, "auctionable_items.json"), gson); + + if (config == null) { + config = new NEUConfig(); + saveConfig(); + } + + MinecraftForge.EVENT_BUS.register(this); + MinecraftForge.EVENT_BUS.register(new NEUEventListener(this)); + MinecraftForge.EVENT_BUS.register(new RecipeGenerator(this)); + MinecraftForge.EVENT_BUS.register(CapeManager.getInstance()); + //MinecraftForge.EVENT_BUS.register(new SBGamemodes()); + MinecraftForge.EVENT_BUS.register(new EnchantingSolvers()); + MinecraftForge.EVENT_BUS.register(new CalendarOverlay()); + MinecraftForge.EVENT_BUS.register(SBInfo.getInstance()); + MinecraftForge.EVENT_BUS.register(CustomItemEffects.INSTANCE); + MinecraftForge.EVENT_BUS.register(new DungeonMap()); + MinecraftForge.EVENT_BUS.register(new SunTzu()); + MinecraftForge.EVENT_BUS.register(new MiningStuff()); + MinecraftForge.EVENT_BUS.register(new FairySouls()); + MinecraftForge.EVENT_BUS.register(new CrystalOverlay()); + MinecraftForge.EVENT_BUS.register(new ItemCooldowns()); + MinecraftForge.EVENT_BUS.register(new DwarvenMinesWaypoints()); + MinecraftForge.EVENT_BUS.register(new FuelBar()); + //MinecraftForge.EVENT_BUS.register(new FancyPortals()); + MinecraftForge.EVENT_BUS.register(XPInformation.getInstance()); + MinecraftForge.EVENT_BUS.register(OverlayManager.petInfoOverlay); + MinecraftForge.EVENT_BUS.register(OverlayManager.timersOverlay); + MinecraftForge.EVENT_BUS.register(new NullzeeSphere()); + MinecraftForge.EVENT_BUS.register(InventoryStorageSelector.getInstance()); + MinecraftForge.EVENT_BUS.register(SlotLocking.getInstance()); + MinecraftForge.EVENT_BUS.register(FishingHelper.getInstance()); + MinecraftForge.EVENT_BUS.register(new DwarvenMinesTextures()); + MinecraftForge.EVENT_BUS.register(CustomBiomes.INSTANCE); + + if (Minecraft.getMinecraft().getResourceManager() instanceof IReloadableResourceManager) { + IReloadableResourceManager manager = (IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager(); + manager.registerReloadListener(CustomSkulls.getInstance()); + manager.registerReloadListener(NPCRetexturing.getInstance()); + manager.registerReloadListener(new ItemCustomizeManager.ReloadListener()); + manager.registerReloadListener(new CustomBlockSounds.ReloaderListener()); + } + + this.commands = new Commands(); + + BackgroundBlur.registerListener(); + + manager = new NEUManager(this, neuDir); + manager.loadItemInformation(); + overlay = new NEUOverlay(manager); + profileViewer = new ProfileViewer(manager); + + for (KeyBinding kb : manager.keybinds) { + ClientRegistry.registerKeyBinding(kb); + } + + Runtime.getRuntime().addShutdownHook(new Thread(() -> { + File tmp = new File(neuDir, "tmp"); + if (tmp.exists()) { + for (File tmpFile : tmp.listFiles()) { + tmpFile.delete(); + } + tmp.delete(); + } + //saveConfig(); + })); + } + + public void saveConfig() { + try { + configFile.createNewFile(); + + try ( + BufferedWriter writer = new BufferedWriter(new OutputStreamWriter( + new FileOutputStream(configFile), + StandardCharsets.UTF_8 + )) + ) { + writer.write(gson.toJson(config)); + } + } catch (Exception ignored) { + } + + try { + ItemCustomizeManager.saveCustomization(new File(neuDir, "itemCustomization.json")); + } catch (Exception ignored) { + } + try { + StorageManager.getInstance().saveConfig(new File(neuDir, "storageItems.json")); + } catch (Exception ignored) { + } + try { + FairySouls.save(new File(neuDir, "collected_fairy_souls.json"), gson); + } catch (Exception ignored) { + } + try { + PetInfoOverlay.saveConfig(new File(neuDir, "petCache.json")); + } catch (Exception ignored) { + } + try { + SlotLocking.getInstance().saveConfig(new File(neuDir, "slotLocking.json")); + } catch (Exception ignored) { + } + } + + /** + * If the last chat messages was sent >200ms ago, sends the message. + * If the last chat message was sent <200 ago, will cache the message for #onTick to handle. + */ + public void sendChatMessage(String message) { + if (System.currentTimeMillis() - lastChatMessage > CHAT_MSG_COOLDOWN) { + secondLastChatMessage = lastChatMessage; + lastChatMessage = System.currentTimeMillis(); + Minecraft.getMinecraft().thePlayer.sendChatMessage(message); + currChatMessage = null; + } else { + currChatMessage = message; + } + } + + public void displayLinks(JsonObject update) { + String discord_link = update.get("discord_link").getAsString(); + String youtube_link = update.get("youtube_link").getAsString(); + String twitch_link = update.get("twitch_link").getAsString(); + String update_link = update.get("update_link").getAsString(); + String github_link = update.get("github_link").getAsString(); + String other_text = update.get("other_text").getAsString(); + String other_link = update.get("other_link").getAsString(); + + ChatComponentText other = null; + if (other_text.length() > 0) { + other = new ChatComponentText( + EnumChatFormatting.GRAY + "[" + EnumChatFormatting.BLUE + other_text + EnumChatFormatting.GRAY + "]"); + other.setChatStyle(Utils.createClickStyle(ClickEvent.Action.OPEN_URL, other_link)); + } + ChatComponentText links = new ChatComponentText(""); + ChatComponentText separator = new ChatComponentText( + EnumChatFormatting.GRAY + EnumChatFormatting.BOLD.toString() + EnumChatFormatting.STRIKETHROUGH + + (other == null ? "--" : "-")); + ChatComponentText discord = new ChatComponentText( + EnumChatFormatting.GRAY + "[" + EnumChatFormatting.BLUE + "Discord" + EnumChatFormatting.GRAY + "]"); + discord.setChatStyle(Utils.createClickStyle(ClickEvent.Action.OPEN_URL, discord_link)); + ChatComponentText youtube = new ChatComponentText( + EnumChatFormatting.GRAY + "[" + EnumChatFormatting.RED + "YouTube" + EnumChatFormatting.GRAY + "]"); + youtube.setChatStyle(Utils.createClickStyle(ClickEvent.Action.OPEN_URL, youtube_link)); + ChatComponentText twitch = new ChatComponentText( + EnumChatFormatting.GRAY + "[" + EnumChatFormatting.DARK_PURPLE + "Twitch" + EnumChatFormatting.GRAY + "]"); + twitch.setChatStyle(Utils.createClickStyle(ClickEvent.Action.OPEN_URL, twitch_link)); + ChatComponentText release = new ChatComponentText( + EnumChatFormatting.GRAY + "[" + EnumChatFormatting.GREEN + "Release" + EnumChatFormatting.GRAY + "]"); + release.setChatStyle(Utils.createClickStyle(ClickEvent.Action.OPEN_URL, update_link)); + ChatComponentText github = new ChatComponentText( + EnumChatFormatting.GRAY + "[" + EnumChatFormatting.DARK_PURPLE + "GitHub" + EnumChatFormatting.GRAY + "]"); + github.setChatStyle(Utils.createClickStyle(ClickEvent.Action.OPEN_URL, github_link)); + + links.appendSibling(separator); + links.appendSibling(discord); + links.appendSibling(separator); + links.appendSibling(youtube); + links.appendSibling(separator); + links.appendSibling(twitch); + links.appendSibling(separator); + links.appendSibling(release); + links.appendSibling(separator); + links.appendSibling(github); + links.appendSibling(separator); + if (other != null) { + links.appendSibling(other); + links.appendSibling(separator); + } + + Minecraft.getMinecraft().thePlayer.addChatMessage(links); + } + + @SubscribeEvent + public void onTick(TickEvent.ClientTickEvent event) { + if (event.phase != TickEvent.Phase.START) return; + if (Minecraft.getMinecraft().thePlayer == null) { + openGui = null; + currChatMessage = null; + return; + } + long currentTime = System.currentTimeMillis(); + + if (openGui != null) { + if (Minecraft.getMinecraft().thePlayer.openContainer != null) { + Minecraft.getMinecraft().thePlayer.closeScreen(); + } + Minecraft.getMinecraft().displayGuiScreen(openGui); + openGui = null; + lastOpenedGui = System.currentTimeMillis(); + } + if (currChatMessage != null && currentTime - lastChatMessage > CHAT_MSG_COOLDOWN) { + lastChatMessage = currentTime; + Minecraft.getMinecraft().thePlayer.sendChatMessage(currChatMessage); + currChatMessage = null; + } + } + + public boolean isOnSkyblock() { + if (!config.misc.onlyShowOnSkyblock) return true; + return hasSkyblockScoreboard(); + } + + private boolean hasSkyblockScoreboard; + + public boolean hasSkyblockScoreboard() { + return hasSkyblockScoreboard; + } + + public void updateSkyblockScoreboard() { + Minecraft mc = Minecraft.getMinecraft(); + + if (mc != null && mc.theWorld != null && mc.thePlayer != null) { + if (mc.isSingleplayer() || mc.thePlayer.getClientBrand() == null || + !mc.thePlayer.getClientBrand().toLowerCase().contains("hypixel")) { + hasSkyblockScoreboard = false; + return; + } + + Scoreboard scoreboard = mc.theWorld.getScoreboard(); + ScoreObjective sidebarObjective = scoreboard.getObjectiveInDisplaySlot(1); + if (sidebarObjective != null) { + String objectiveName = sidebarObjective.getDisplayName().replaceAll("(?i)\\u00A7.", ""); + for (String skyblock : SKYBLOCK_IN_ALL_LANGUAGES) { + if (objectiveName.startsWith(skyblock)) { + hasSkyblockScoreboard = true; + return; + } + } + } + + hasSkyblockScoreboard = false; + } + } } -- cgit