diff options
| author | Moulberry <jjenour@student.unimelb.edu.au> | 2021-09-02 14:09:31 +0930 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-09-02 14:09:31 +0930 |
| commit | 81eea6bf1f653fa194735d892b40614389975dd3 (patch) | |
| tree | a955e0d03401302332c743f6c396184e45c94c80 /src/main/java | |
| parent | 05428d1ccb15f58ccbdb4b14eb9e10b61b0477cc (diff) | |
| parent | 05d6207281e18980b8a28046621c741fa81c1606 (diff) | |
| download | NotEnoughUpdates-81eea6bf1f653fa194735d892b40614389975dd3.tar.gz NotEnoughUpdates-81eea6bf1f653fa194735d892b40614389975dd3.tar.bz2 NotEnoughUpdates-81eea6bf1f653fa194735d892b40614389975dd3.zip | |
Merge pull request #226 from DoKM/master
Pre31 update
Diffstat (limited to 'src/main/java')
57 files changed, 4362 insertions, 993 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/ItemPriceInformation.java b/src/main/java/io/github/moulberry/notenoughupdates/ItemPriceInformation.java index ff618f10..83c4b7ae 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/ItemPriceInformation.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/ItemPriceInformation.java @@ -2,6 +2,7 @@ package io.github.moulberry.notenoughupdates; import com.google.gson.JsonObject; import io.github.moulberry.notenoughupdates.auction.APIManager; +import io.github.moulberry.notenoughupdates.core.config.KeybindHelper; import io.github.moulberry.notenoughupdates.util.Constants; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.item.ItemStack; @@ -20,6 +21,12 @@ public class ItemPriceInformation { } public static boolean addToTooltip(List<String> tooltip, String internalname, ItemStack stack, boolean useStackSize) { + if(stack.getTagCompound().hasKey("disableNeuTooltip") && stack.getTagCompound().getBoolean("disableNeuTooltip")){ + return false; + } + if(NotEnoughUpdates.INSTANCE.config.tooltipTweaks.disablePriceKey && !KeybindHelper.isKeyDown(NotEnoughUpdates.INSTANCE.config.tooltipTweaks.disablePriceKeyKeybind)){ + return false; + } JsonObject auctionInfo = NotEnoughUpdates.INSTANCE.manager.auctionManager.getItemAuctionInfo(internalname); JsonObject bazaarInfo = NotEnoughUpdates.INSTANCE.manager.auctionManager.getBazaarInfo(internalname); float lowestBinAvg = NotEnoughUpdates.INSTANCE.manager.auctionManager.getItemAvgBin(internalname); @@ -98,6 +105,7 @@ public class ItemPriceInformation { break; case 4: if(craftCost.fromRecipe) { + if((int)craftCost.craftCost == 0){ continue;} if(!added) { tooltip.add(""); added = true; @@ -165,6 +173,7 @@ public class ItemPriceInformation { break; case 3: if(craftCost.fromRecipe) { + if((int)craftCost.craftCost == 0){ continue;} if(!added) { tooltip.add(""); added = true; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUApi.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUApi.java new file mode 100644 index 00000000..56a196b4 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUApi.java @@ -0,0 +1,10 @@ +package io.github.moulberry.notenoughupdates; + +import net.minecraftforge.fml.relauncher.ReflectionHelper; + +public class NEUApi { + static boolean disableInventoryButtons = false; + public static void setInventoryButtonsToDisabled(){ + disableInventoryButtons = true; + } +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java index b849c890..48cd0e57 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java @@ -1,10 +1,7 @@ package io.github.moulberry.notenoughupdates; import com.google.common.collect.Lists; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonPrimitive; +import com.google.gson.*; import com.mojang.authlib.GameProfile; import com.mojang.authlib.minecraft.MinecraftProfileTexture; import io.github.moulberry.notenoughupdates.auction.CustomAHGui; @@ -15,14 +12,10 @@ import io.github.moulberry.notenoughupdates.core.util.render.RenderUtils; import io.github.moulberry.notenoughupdates.cosmetics.CapeManager; import io.github.moulberry.notenoughupdates.dungeons.DungeonBlocks; import io.github.moulberry.notenoughupdates.dungeons.DungeonWin; -import io.github.moulberry.notenoughupdates.gamemodes.SBGamemodes; import io.github.moulberry.notenoughupdates.miscfeatures.*; import io.github.moulberry.notenoughupdates.miscgui.*; import io.github.moulberry.notenoughupdates.options.NEUConfig; -import io.github.moulberry.notenoughupdates.overlays.AuctionSearchOverlay; -import io.github.moulberry.notenoughupdates.overlays.OverlayManager; -import io.github.moulberry.notenoughupdates.overlays.RancherBootOverlay; -import io.github.moulberry.notenoughupdates.overlays.TextOverlay; +import io.github.moulberry.notenoughupdates.overlays.*; import io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer; import io.github.moulberry.notenoughupdates.util.*; import net.minecraft.client.Minecraft; @@ -41,6 +34,7 @@ import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.inventory.ContainerChest; import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -51,6 +45,7 @@ import net.minecraftforge.client.ClientCommandHandler; import net.minecraftforge.client.event.*; import net.minecraftforge.event.entity.player.ItemTooltipEvent; import net.minecraftforge.event.world.WorldEvent; +import net.minecraftforge.fml.common.Loader; import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; @@ -64,6 +59,7 @@ import java.awt.*; import java.awt.datatransfer.StringSelection; import java.io.File; import java.io.IOException; +import java.text.DecimalFormat; import java.text.NumberFormat; import java.util.List; import java.util.*; @@ -170,10 +166,12 @@ public class NEUEventListener { @SubscribeEvent public void onWorldLoad(WorldEvent.Unload event) { NotEnoughUpdates.INSTANCE.saveConfig(); + CrystalMetalDetectorSolver.reset(); } private static long notificationDisplayMillis = 0; private static List<String> notificationLines = null; + private static boolean showNotificationOverInv = false; private static final Pattern BAD_ITEM_REGEX = Pattern.compile("x[0-9]{1,2}$"); @@ -192,18 +190,23 @@ public class NEUEventListener { private int inventoryLoadedTicks = 0; private String loadedInvName = ""; public static boolean inventoryLoaded = false; - public static void displayNotification(List<String> lines, boolean showForever) { + displayNotification(lines, showForever, false); + } + + public static void displayNotification(List<String> lines, boolean showForever, boolean overInventory) { if(showForever) { notificationDisplayMillis = -420; } else { notificationDisplayMillis = System.currentTimeMillis(); } notificationLines = lines; + showNotificationOverInv = overInventory; } @SubscribeEvent public void onTick(TickEvent.ClientTickEvent event) { + Keyboard.enableRepeatEvents(false); if(event.phase != TickEvent.Phase.START) return; if(Minecraft.getMinecraft().theWorld == null) return; if(Minecraft.getMinecraft().thePlayer == null) return; @@ -340,7 +343,7 @@ public class NEUEventListener { if(!joinedSB) { joinedSB = true; - SBGamemodes.loadFromFile(); + //SBGamemodes.loadFromFile(); if(NotEnoughUpdates.INSTANCE.config.notifications.showUpdateMsg) { @@ -363,14 +366,26 @@ public class NEUEventListener { if(!NotEnoughUpdates.INSTANCE.config.hidden.loadedModBefore) { NotEnoughUpdates.INSTANCE.config.hidden.loadedModBefore = true; - + if(Constants.MISC == null || !Constants.MISC.has("featureslist")){ + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(""+EnumChatFormatting.DARK_RED+EnumChatFormatting.BOLD+"WARNING: "+EnumChatFormatting.RESET+EnumChatFormatting.RED+"Could not load Feature List URL from repo.")); + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(""+EnumChatFormatting.RED+ "Please run "+EnumChatFormatting.BOLD+"/neuresetrepo"+EnumChatFormatting.RESET+EnumChatFormatting.RED+" and "+EnumChatFormatting.BOLD+"restart your game"+EnumChatFormatting.RESET+EnumChatFormatting.RED+" in order to fix. "+EnumChatFormatting.DARK_RED+EnumChatFormatting.BOLD+"If that doesn't fix it"+EnumChatFormatting.RESET+EnumChatFormatting.RED+", please join discord.gg/moulberry and post in #neu-support")); + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("")); + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(""+EnumChatFormatting.GOLD+"To view the feature list after restarting type /neufeatures")); + } else { + String url = Constants.MISC.get("featureslist").getAsString(); + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("")); + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText( + EnumChatFormatting.BLUE + "It seems this is your first time using NotEnoughUpdates.")); + ChatComponentText clickTextFeatures = new ChatComponentText( + EnumChatFormatting.YELLOW + "Click this message if you would like to view a list of NotEnoughUpdate's Features."); + clickTextFeatures.setChatStyle(Utils.createClickStyle(ClickEvent.Action.OPEN_URL, url)); + Minecraft.getMinecraft().thePlayer.addChatMessage(clickTextFeatures); + } Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("")); - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText( - EnumChatFormatting.BLUE+"It seems this is your first time using NotEnoughUpdates.")); - ChatComponentText clickText = new ChatComponentText( - EnumChatFormatting.YELLOW+"Click this message if you would like to view a short tutorial."); - clickText.setChatStyle(Utils.createClickStyle(ClickEvent.Action.RUN_COMMAND, "/neututorial")); - Minecraft.getMinecraft().thePlayer.addChatMessage(clickText); + ChatComponentText clickTextHelp = new ChatComponentText( + EnumChatFormatting.YELLOW+"Click this message if you would like to view a list of NotEnoughUpdate's commands."); + clickTextHelp.setChatStyle(Utils.createClickStyle(ClickEvent.Action.RUN_COMMAND, "/neuhelp")); + Minecraft.getMinecraft().thePlayer.addChatMessage(clickTextHelp); Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("")); } } @@ -501,13 +516,20 @@ public class NEUEventListener { if(Keyboard.isKeyDown(Keyboard.KEY_X)) { notificationDisplayMillis = 0; } + + if(event.type == RenderGameOverlayEvent.ElementType.ALL){ + renderNotification(); + } + + } + private static void renderNotification(){ + long timeRemaining = 15000 - (System.currentTimeMillis() - notificationDisplayMillis); boolean display = timeRemaining > 0 || notificationDisplayMillis == -420; - if(event.type == RenderGameOverlayEvent.ElementType.ALL && - display && notificationLines != null && notificationLines.size() > 0) { + if(display && notificationLines != null && notificationLines.size() > 0) { int width = 0; int height = notificationLines.size()*10+10; - + for(String line : notificationLines) { int len = Minecraft.getMinecraft().fontRendererObj.getStringWidth(line) + 8; if(len > width) { @@ -556,6 +578,9 @@ public class NEUEventListener { AtomicBoolean missingRecipe = new AtomicBoolean(false); @SubscribeEvent public void onGuiOpen(GuiOpenEvent event) { + CraftingOverlay.shouldRender = false; + NEUApi.disableInventoryButtons = false; + if((Minecraft.getMinecraft().currentScreen instanceof GuiScreenElementWrapper || Minecraft.getMinecraft().currentScreen instanceof GuiItemRecipe) && event.gui == null && !(Keyboard.getEventKeyState() && Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) && @@ -756,7 +781,7 @@ public class NEUEventListener { private String processText(String text) { if(SBInfo.getInstance().getLocation() == null) return text; - if(!SBInfo.getInstance().getLocation().startsWith("mining_")) return text; + if(!SBInfo.getInstance().getLocation().startsWith("mining_")&&!SBInfo.getInstance().getLocation().equals("crystal_hollows")) return text; if(Minecraft.getMinecraft().thePlayer == null) return text; if(!NotEnoughUpdates.INSTANCE.config.mining.drillFuelBar) return text; @@ -764,6 +789,20 @@ public class NEUEventListener { return Utils.trimIgnoreColour(text.replaceAll(EnumChatFormatting.DARK_GREEN+"\\S+ Drill Fuel", "")); } + + private IChatComponent replaceSocialControlsWithPV(IChatComponent chatComponent){ + + if(NotEnoughUpdates.INSTANCE.config.misc.replaceSocialOptions && chatComponent.getChatStyle() != null && chatComponent.getChatStyle().getChatClickEvent() != null && chatComponent.getChatStyle().getChatClickEvent().getAction() == ClickEvent.Action.RUN_COMMAND){ + if(chatComponent.getChatStyle().getChatClickEvent().getValue().startsWith("/socialoptions")){ + String username = chatComponent.getChatStyle().getChatClickEvent().getValue().substring(15); + + chatComponent.setChatStyle(Utils.createClickStyle(ClickEvent.Action.RUN_COMMAND, "/pv "+username, ""+EnumChatFormatting.YELLOW+"Click to open "+EnumChatFormatting.AQUA+EnumChatFormatting.BOLD+username+EnumChatFormatting.RESET+EnumChatFormatting.YELLOW+"'s profile in "+EnumChatFormatting.DARK_PURPLE+EnumChatFormatting.BOLD+"NEU's"+EnumChatFormatting.RESET+EnumChatFormatting.YELLOW+ " profile viewer.")); + return chatComponent; + } + } + return chatComponent; + } + /** * 1) When receiving "You are playing on profile" messages, will set the current profile. * 2) When a /viewrecipe command fails (i.e. player does not have recipe unlocked, will open the custom recipe GUI) @@ -772,8 +811,11 @@ public class NEUEventListener { @SubscribeEvent(priority = EventPriority.LOW, receiveCanceled = true) public void onGuiChat(ClientChatReceivedEvent e) { |
