From 1ae37ce75ad3a47c47482aff977fb4bb25660d3e Mon Sep 17 00:00:00 2001 From: DoKM Date: Thu, 2 Sep 2021 21:57:08 +0200 Subject: Fix a nullpointer exception in dwarven textures (untested) but should do it --- .../moulberry/notenoughupdates/miscfeatures/DwarvenMinesTextures.java | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/main/java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DwarvenMinesTextures.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DwarvenMinesTextures.java index 735243d3..b05c430d 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DwarvenMinesTextures.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DwarvenMinesTextures.java @@ -160,6 +160,9 @@ public class DwarvenMinesTextures { } if(loadedChunkData.get(pair) != null) { HashMap map = loadedChunkData.get(pair); + if(map == null) { + return 0; + } int modX = pos.getX() % 16; int modZ = pos.getZ() % 16; -- cgit From e3fa70ec3bed0667187c44c62764fe04eb182395 Mon Sep 17 00:00:00 2001 From: DoKM Date: Thu, 2 Sep 2021 21:57:34 +0200 Subject: Fix neuec not parsing correctly and 2 crashes when copying stuff --- .../github/moulberry/notenoughupdates/miscgui/GuiEnchantColour.java | 4 ++-- .../github/moulberry/notenoughupdates/miscgui/GuiInvButtonEditor.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiEnchantColour.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiEnchantColour.java index f9344a3a..4bbcdbdd 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiEnchantColour.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiEnchantColour.java @@ -67,7 +67,7 @@ public class GuiEnchantColour extends GuiScreen { public static int UNDERLINE_MODIFIER = 0b1000; public static int STRIKETHROUGH_MODIFIER = 0b10000; private Gson gson = new Gson(); - private static final Pattern settingPattern = Pattern.compile(".*:[>=<]:[0-9]:[a-zA-Z0-9]:[0-9][0-9]?"); + private static final Pattern settingPattern = Pattern.compile(".*:[>=<]:[0-9]+:[a-zA-Z0-9]+(:[a-zA-Z0-9])?"); private List getEnchantNamesPretty() { if(enchantNamesPretty == null) { @@ -318,7 +318,7 @@ public class GuiEnchantColour extends GuiScreen { } catch (IllegalArgumentException e){ return false; } - } catch (HeadlessException | IOException | UnsupportedFlavorException e) { + } catch (HeadlessException | IOException | UnsupportedFlavorException | IllegalStateException e) { return false; } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiInvButtonEditor.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiInvButtonEditor.java index cfc51708..22a17c9f 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiInvButtonEditor.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiInvButtonEditor.java @@ -495,7 +495,7 @@ public class GuiInvButtonEditor extends GuiScreen { } catch (IllegalArgumentException e){ return false; } - } catch (HeadlessException | IOException | UnsupportedFlavorException e) { + } catch (HeadlessException | IOException | UnsupportedFlavorException | IllegalStateException e) { return false; } } -- cgit From 3124dd9341b3437cf7284534cc8779fe13a2c904 Mon Sep 17 00:00:00 2001 From: DoKM Date: Fri, 3 Sep 2021 10:55:36 +0200 Subject: some small fixes --- .../io/github/moulberry/notenoughupdates/miscgui/StorageOverlay.java | 2 +- .../io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/StorageOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/StorageOverlay.java index d80a5daf..664d684b 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/StorageOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/StorageOverlay.java @@ -1968,7 +1968,7 @@ public class StorageOverlay extends GuiElement { } public void fastRenderCheck(){ - if(!OpenGlHelper.isFramebufferEnabled()) { + if(!OpenGlHelper.isFramebufferEnabled() && NotEnoughUpdates.INSTANCE.config.storageGUI.enableStorageGUI3) { this.fastRender = true; NEUEventListener.displayNotification(Lists.newArrayList( "\u00a74Fast Render Warning", diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java index 56fa2e99..65c7d3f6 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java @@ -213,7 +213,7 @@ public class TimersOverlay extends TextOverlay { return; } else if(containerName.equals("Superpairs Rewards") && lower.getSizeInventory() >= 27){ ItemStack stack = lower.getStackInSlot(13); - if(Utils.cleanColour(stack.getDisplayName()).equals("Superpairs")){ + if(stack != null && Utils.cleanColour(stack.getDisplayName()).equals("Superpairs")){ hidden.experimentsCompleted = currentTime; } } -- cgit From 794609ad1bc7953281aede7e095f04d399f4c25f Mon Sep 17 00:00:00 2001 From: DoKM Date: Fri, 3 Sep 2021 21:51:48 +0200 Subject: Fix accessory bag overlay not counting stats with a % and golden goblin not having a icon --- .../miscgui/AccessoryBagOverlay.java | 57 ++++++++++++---------- .../notenoughupdates/overlays/MiningOverlay.java | 4 ++ 2 files changed, 35 insertions(+), 26 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/AccessoryBagOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/AccessoryBagOverlay.java index 1b04ca88..ec676ec5 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/AccessoryBagOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/AccessoryBagOverlay.java @@ -752,19 +752,21 @@ public class AccessoryBagOverlay { } }*/ - private static final Pattern HEALTH_PATTERN_BONUS = Pattern.compile("^Health: (?:\\+|-)[0-9]+(?:\\.[0-9]+)? \\([a-zA-Z]+ ((?:\\+|-)[0-9]+)"); - private static final Pattern DEFENCE_PATTERN_BONUS = Pattern.compile("^Defense: (?:\\+|-)[0-9]+(?:\\.[0-9]+)? \\([a-zA-Z]+ ((?:\\+|-)[0-9]+)"); - private static final Pattern STRENGTH_PATTERN_BONUS = Pattern.compile("^Strength: (?:\\+|-)[0-9]+(?:\\.[0-9]+)? \\([a-zA-Z]+ ((?:\\+|-)[0-9]+)"); - private static final Pattern SPEED_PATTERN_BONUS = Pattern.compile("^Speed: (?:\\+|-)[0-9]+(?:\\.[0-9]+)? \\([a-zA-Z]+ ((?:\\+|-)[0-9]+)"); - private static final Pattern CC_PATTERN_BONUS = Pattern.compile("^Crit Chance: (?:\\+|-)[0-9]+(?:\\.[0-9]+)? \\([a-zA-Z]+ ((?:\\+|-)[0-9]+)"); - private static final Pattern CD_PATTERN_BONUS = Pattern.compile("^Crit Damage: (?:\\+|-)[0-9]+(?:\\.[0-9]+)? \\([a-zA-Z]+ ((?:\\+|-)[0-9]+)"); - private static final Pattern ATKSPEED_PATTERN_BONUS = Pattern.compile("^Bonus Attack Speed: (?:\\+|-)[0-9]+(?:\\.[0-9]+)? \\([a-zA-Z]+ ((?:\\+|-)[0-9]+)"); - private static final Pattern INTELLIGENCE_PATTERN_BONUS = Pattern.compile("^Intelligence: (?:\\+|-)[0-9]+(?:\\.[0-9]+)? \\([a-zA-Z]+ ((?:\\+|-)[0-9]+)"); - private static final Pattern SCC_PATTERN_BONUS = Pattern.compile("^Sea Creature Chance: (?:\\+|-)[0-9]+(?:\\.[0-9]+)? \\([a-zA-Z]+ ((?:\\+|-)[0-9]+)"); - private static final Pattern FEROCITY_PATTERN_BONUS = Pattern.compile("^Ferocity: (?:\\+|-)[0-9]+(?:\\.[0-9]+)? \\([a-zA-Z]+ ((?:\\+|-)[0-9]+)"); - private static final Pattern MINING_FORTUNE_PATTERN_BONUS = Pattern.compile("^Mining Fortune: (?:\\+|-)[0-9]+(?:\\.[0-9]+)? \\([a-zA-Z]+ ((?:\\+|-)[0-9]+)"); - private static final Pattern MINING_SPEED_PATTERN_BONUS = Pattern.compile("^Mining Speed: (?:\\+|-)[0-9]+(?:\\.[0-9]+)? \\([a-zA-Z]+ ((?:\\+|-)[0-9]+)"); - private static final Pattern MAGIC_FIND_PATTERN_BONUS = Pattern.compile("^Magic Find: (?:\\+|-)[0-9]+(?:\\.[0-9]+)? \\([a-zA-Z]+ ((?:\\+|-)[0-9]+)"); + private static final String STAT_PATTERN_BONUS_END = ": (?:\\+|-)[0-9]+(?:\\.[0-9]+)?\\%? \\([a-zA-Z]+ ((?:\\+|-)[0-9]+)%?"; + + private static final Pattern HEALTH_PATTERN_BONUS = Pattern.compile("^Health"+STAT_PATTERN_BONUS_END); + private static final Pattern DEFENCE_PATTERN_BONUS = Pattern.compile("^Defense"+STAT_PATTERN_BONUS_END); + private static final Pattern STRENGTH_PATTERN_BONUS = Pattern.compile("^Strength"+STAT_PATTERN_BONUS_END); + private static final Pattern SPEED_PATTERN_BONUS = Pattern.compile("^Speed"+STAT_PATTERN_BONUS_END); + private static final Pattern CC_PATTERN_BONUS = Pattern.compile("^Crit Chance"+STAT_PATTERN_BONUS_END); + private static final Pattern CD_PATTERN_BONUS = Pattern.compile("^Crit Damage"+STAT_PATTERN_BONUS_END); + private static final Pattern ATKSPEED_PATTERN_BONUS = Pattern.compile("^Bonus Attack Speed"+STAT_PATTERN_BONUS_END); + private static final Pattern INTELLIGENCE_PATTERN_BONUS = Pattern.compile("^Intelligence"+STAT_PATTERN_BONUS_END); + private static final Pattern SCC_PATTERN_BONUS = Pattern.compile("^Sea Creature Chance"+STAT_PATTERN_BONUS_END); + private static final Pattern FEROCITY_PATTERN_BONUS = Pattern.compile("^Ferocity"+STAT_PATTERN_BONUS_END); + private static final Pattern MINING_FORTUNE_PATTERN_BONUS = Pattern.compile("^Mining Fortune"+STAT_PATTERN_BONUS_END); + private static final Pattern MINING_SPEED_PATTERN_BONUS = Pattern.compile("^Mining Speed"+STAT_PATTERN_BONUS_END); + private static final Pattern MAGIC_FIND_PATTERN_BONUS = Pattern.compile("^Magic Find"+STAT_PATTERN_BONUS_END); private static final HashMap STAT_PATTERN_MAP_BONUS = new HashMap<>(); static { STAT_PATTERN_MAP_BONUS.put("health", HEALTH_PATTERN_BONUS); @@ -782,19 +784,22 @@ public class AccessoryBagOverlay { STAT_PATTERN_MAP_BONUS.put("magic_find", MAGIC_FIND_PATTERN_BONUS); } - private static final Pattern HEALTH_PATTERN = Pattern.compile("^Health: ((?:\\+|-)([0-9]+(\\.[0-9]+)?))"); - private static final Pattern DEFENCE_PATTERN = Pattern.compile("^Defense: ((?:\\+|-)([0-9]+(\\.[0-9]+)?))"); - private static final Pattern STRENGTH_PATTERN = Pattern.compile("^Strength: ((?:\\+|-)([0-9]+(\\.[0-9]+)?))"); - private static final Pattern SPEED_PATTERN = Pattern.compile("^Speed: ((?:\\+|-)([0-9]+(\\.[0-9]+)?))"); - private static final Pattern CC_PATTERN = Pattern.compile("^Crit Chance: ((?:\\+|-)([0-9]+(\\.[0-9]+)?))"); - private static final Pattern CD_PATTERN = Pattern.compile("^Crit Damage: ((?:\\+|-)([0-9]+(\\.[0-9]+)?))"); - private static final Pattern ATKSPEED_PATTERN = Pattern.compile("^Bonus Attack Speed: ((?:\\+|-)([0-9]+(\\.[0-9]+)?))"); - private static final Pattern INTELLIGENCE_PATTERN = Pattern.compile("^Intelligence: ((?:\\+|-)([0-9]+(\\.[0-9]+)?))"); - private static final Pattern SCC_PATTERN = Pattern.compile("^Sea Creature Chance: ((?:\\+|-)([0-9]+(\\.[0-9]+)?))"); - private static final Pattern FEROCITY_PATTERN = Pattern.compile("^Ferocity: ((?:\\+|-)([0-9]+(\\.[0-9]+)?))"); - private static final Pattern MINING_FORTUNE_PATTERN = Pattern.compile("^Mining Fortune: ((?:\\+|-)([0-9]+(\\.[0-9]+)?))"); - private static final Pattern MINING_SPEED_PATTERN = Pattern.compile("^Mining Speed: ((?:\\+|-)([0-9]+(\\.[0-9]+)?))"); - private static final Pattern MAGIC_FIND_PATTERN = Pattern.compile("^Magic Find: ((?:\\+|-)([0-9]+(\\.[0-9]+)?))"); + + private static final String STAT_PATTERN_END = ": ((?:\\+|-)([0-9]+(\\.[0-9]+)?))%?"; + + private static final Pattern HEALTH_PATTERN = Pattern.compile("^Health"+STAT_PATTERN_END); + private static final Pattern DEFENCE_PATTERN = Pattern.compile("^Defense"+STAT_PATTERN_END); + private static final Pattern STRENGTH_PATTERN = Pattern.compile("^Strength"+STAT_PATTERN_END); + private static final Pattern SPEED_PATTERN = Pattern.compile("^Speed"+STAT_PATTERN_END); + private static final Pattern CC_PATTERN = Pattern.compile("^Crit Chance"+STAT_PATTERN_END); + private static final Pattern CD_PATTERN = Pattern.compile("^Crit Damage"+STAT_PATTERN_END); + private static final Pattern ATKSPEED_PATTERN = Pattern.compile("^Bonus Attack Speed"+STAT_PATTERN_END); + private static final Pattern INTELLIGENCE_PATTERN = Pattern.compile("^Intelligence"+STAT_PATTERN_END); + private static final Pattern SCC_PATTERN = Pattern.compile("^Sea Creature Chance"+STAT_PATTERN_END); + private static final Pattern FEROCITY_PATTERN = Pattern.compile("^Ferocity"+STAT_PATTERN_END); + private static final Pattern MINING_FORTUNE_PATTERN = Pattern.compile("^Mining Fortune"+STAT_PATTERN_END); + private static final Pattern MINING_SPEED_PATTERN = Pattern.compile("^Mining Speed"+STAT_PATTERN_END); + private static final Pattern MAGIC_FIND_PATTERN = Pattern.compile("^Magic Find"+STAT_PATTERN_END); private static final HashMap STAT_PATTERN_MAP = new HashMap<>(); static { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java index 8a4c697e..0beb8060 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java @@ -15,6 +15,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.gui.inventory.GuiChest; import net.minecraft.client.network.NetworkPlayerInfo; import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.init.Items; import net.minecraft.inventory.ContainerChest; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; @@ -606,6 +607,9 @@ public class MiningOverlay extends TextOverlay { case "Goblin Raid Slayer": icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("ENCHANTED_GOLD")); break; + case "Golden Goblin Slayer": + icon = new ItemStack(Items.golden_helmet, 1, 0); + break; case "2x Mithril Powder Collector": icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("ENCHANTED_GLOWSTONE_DUST")); break; -- cgit From 619129352be4a3aa4577060d49b2aa5cf162a432 Mon Sep 17 00:00:00 2001 From: DoKM Date: Fri, 3 Sep 2021 21:58:59 +0200 Subject: fix exp tweaks not working for the rat pet --- .../java/io/github/moulberry/notenoughupdates/NEUEventListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main/java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java index e0a36686..38775ee7 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java @@ -2406,7 +2406,7 @@ public class NEUEventListener { } //7 is just a random number i chose, prob no pets with less lines than 7 if (event.toolTip.size() > 7) { - if (Utils.cleanColour(event.toolTip.get(1)).matches("((Farming)|(Combat)|(Fishing)|(Mining)|(Foraging)|(Enchanting)|(Alchemy)) ((Mount)|(Pet)).*")) { + if (Utils.cleanColour(event.toolTip.get(1)).matches("((Farming)|(Combat)|(Fishing)|(Mining)|(Foraging)|(Enchanting)|(Alchemy)) ((Mount)|(Pet)|(Morph)).*")) { GuiProfileViewer.PetLevel petlevel = null; -- cgit From 32b6f0d803190b0584ab12a4e1e5043882132b8b Mon Sep 17 00:00:00 2001 From: DoKM Date: Tue, 7 Sep 2021 12:29:20 +0200 Subject: enable help button by default small change --- .../moulberry/notenoughupdates/options/seperateSections/Toolbar.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main/java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Toolbar.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Toolbar.java index d45f6406..51092bbe 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Toolbar.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Toolbar.java @@ -46,7 +46,7 @@ public class Toolbar { ) @ConfigEditorBoolean @ConfigAccordionId(id = 0) - public boolean enableHelpButton = false; + public boolean enableHelpButton = true; @Expose @ConfigOption( -- cgit From f47adcd23a55bc8e774d33f3725461599c3232c6 Mon Sep 17 00:00:00 2001 From: Lulonaut Date: Tue, 7 Sep 2021 18:37:11 +0200 Subject: add toggle to disable showing the treecap cooldown in item durability --- .../moulberry/notenoughupdates/miscfeatures/ItemCooldowns.java | 4 ++++ .../notenoughupdates/options/seperateSections/ItemOverlays.java | 9 +++++++++ 2 files changed, 13 insertions(+) (limited to 'src/main/java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemCooldowns.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemCooldowns.java index 053910bc..e18c28be 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemCooldowns.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemCooldowns.java @@ -65,6 +65,10 @@ public class ItemCooldowns { } public static long getTreecapCooldownWithPet(){ + if (!NotEnoughUpdates.INSTANCE.config.itemOverlays.enableCooldownInItemDurability){ + return 0; + } + PetInfoOverlay.Pet pet = PetInfoOverlay.getCurrentPet(); if (NotEnoughUpdates.INSTANCE.config.itemOverlays.enableMonkeyCheck && pet != null) { if (pet.petLevel != null && diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/ItemOverlays.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/ItemOverlays.java index 4e4524e2..c8515ad1 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/ItemOverlays.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/ItemOverlays.java @@ -25,6 +25,15 @@ public class ItemOverlays { @ConfigAccordionId(id = 0) public boolean enableTreecapOverlay = true; + @Expose + @ConfigOption( + name = "Show in Item durability", + desc = "Show the cooldown of the Treecapitator in the item durability" + ) + @ConfigEditorBoolean + @ConfigAccordionId(id = 0) + public boolean enableCooldownInItemDurability = true; + @Expose @ConfigOption( name = "Overlay Colour", -- cgit From 5dff658657c24581a6dc30f2b5a4785bde96b8ac Mon Sep 17 00:00:00 2001 From: Lulonaut Date: Tue, 7 Sep 2021 18:39:16 +0200 Subject: fix typo in config Description --- .../notenoughupdates/options/seperateSections/ItemOverlays.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main/java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/ItemOverlays.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/ItemOverlays.java index c8515ad1..9d0814d5 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/ItemOverlays.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/ItemOverlays.java @@ -46,7 +46,7 @@ public class ItemOverlays { @Expose @ConfigOption( name = "Enable Monkey Pet Check", - desc = "Will check use the API to check what pet you're using\nto determine the cooldown based off of if you have monkey pet." + desc = "Will check using the API to check what pet you're using\nto determine the cooldown based off of if you have a monkey pet." ) @ConfigEditorBoolean @ConfigAccordionId(id = 0) -- cgit From a373c31ba136020d088c569c76008ecdc7744c3d Mon Sep 17 00:00:00 2001 From: Lulonaut Date: Tue, 7 Sep 2021 21:19:58 +0200 Subject: ah search overlay tab completion --- .../notenoughupdates/overlays/AuctionSearchOverlay.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/main/java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/AuctionSearchOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/AuctionSearchOverlay.java index 816a6c63..2cfe176b 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/AuctionSearchOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/AuctionSearchOverlay.java @@ -20,6 +20,7 @@ import net.minecraft.tileentity.TileEntitySign; import net.minecraft.util.ChatComponentText; import net.minecraft.util.ResourceLocation; import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.text.WordUtils; import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; @@ -334,6 +335,17 @@ public class AuctionSearchOverlay { } else if(Keyboard.getEventKey() == Keyboard.KEY_RETURN) { searchStringExtra = ""; close(); + } else if(Keyboard.getEventKey() == Keyboard.KEY_TAB){ + searchString = autocompletedItems.iterator().next(); + JsonObject repoObject = NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(autocompletedItems.iterator().next()); + String displayname = repoObject.get("displayname").getAsString(); + if (displayname.contains("Enchanted Book")){ + String lore = repoObject.get("lore").getAsJsonArray().iterator().next().getAsString(); + String name = lore.substring(0, lore.lastIndexOf(" ")); + searchString = Utils.cleanColour(name); + } else { + searchString = Utils.cleanColour(displayname); + } } else if(Keyboard.getEventKeyState()) { textField.setFocus(true); textField.setText(searchString); -- cgit From 4886341cbc1009c1f6a67807f6ed24c28a124884 Mon Sep 17 00:00:00 2001 From: Lulonaut Date: Tue, 7 Sep 2021 21:21:31 +0200 Subject: unused import --- .../github/moulberry/notenoughupdates/overlays/AuctionSearchOverlay.java | 1 - 1 file changed, 1 deletion(-) (limited to 'src/main/java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/AuctionSearchOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/AuctionSearchOverlay.java index 2cfe176b..641f8a93 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/AuctionSearchOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/AuctionSearchOverlay.java @@ -20,7 +20,6 @@ import net.minecraft.tileentity.TileEntitySign; import net.minecraft.util.ChatComponentText; import net.minecraft.util.ResourceLocation; import org.apache.commons.lang3.StringUtils; -import org.apache.commons.lang3.text.WordUtils; import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; -- cgit From 818dc8f0d7711a4036d83db1304f7f776ce47f39 Mon Sep 17 00:00:00 2001 From: Lulonaut Date: Wed, 8 Sep 2021 14:17:55 +0200 Subject: make sure there are autocompleted items --- .../overlays/AuctionSearchOverlay.java | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/AuctionSearchOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/AuctionSearchOverlay.java index 641f8a93..8b3b21f0 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/AuctionSearchOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/AuctionSearchOverlay.java @@ -335,15 +335,17 @@ public class AuctionSearchOverlay { searchStringExtra = ""; close(); } else if(Keyboard.getEventKey() == Keyboard.KEY_TAB){ - searchString = autocompletedItems.iterator().next(); - JsonObject repoObject = NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(autocompletedItems.iterator().next()); - String displayname = repoObject.get("displayname").getAsString(); - if (displayname.contains("Enchanted Book")){ - String lore = repoObject.get("lore").getAsJsonArray().iterator().next().getAsString(); - String name = lore.substring(0, lore.lastIndexOf(" ")); - searchString = Utils.cleanColour(name); - } else { - searchString = Utils.cleanColour(displayname); + if (!autocompletedItems.isEmpty()) { + searchString = autocompletedItems.iterator().next(); + JsonObject repoObject = NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(autocompletedItems.iterator().next()); + String displayname = repoObject.get("displayname").getAsString(); + if (displayname.contains("Enchanted Book")){ + String lore = repoObject.get("lore").getAsJsonArray().iterator().next().getAsString(); + String name = lore.substring(0, lore.lastIndexOf(" ")); + searchString = Utils.cleanColour(name); + } else { + searchString = Utils.cleanColour(displayname); + } } } else if(Keyboard.getEventKeyState()) { textField.setFocus(true); -- cgit From fdd335dbf42c792e95cb3cafc1b91821fa2ca00f Mon Sep 17 00:00:00 2001 From: David Mills <85420839+Keebler408@users.noreply.github.com> Date: Thu, 9 Sep 2021 03:48:32 -0500 Subject: Metal detector solver updates - Move beacon beam rendering related code into RenderUtils - Show beacons and labels for metal detector locations - Replace code that Hypixel would likely ban as X-Ray with code based on eliminating duplicate Y values. The number of unique locations for the new code to work is still 2-3, but results in odd locations being treated as valid (mid-air, outside Mines, blocks not exposed to air). This could be made better by detecting the NPCs coordinates to filter valid coordinates. - Add a TODO in reset to add a delay after a chest is found --- .../notenoughupdates/NEUEventListener.java | 4 +- .../core/util/render/RenderUtils.java | 105 +++++++++++++++++++++ .../miscfeatures/CrystalMetalDetectorSolver.java | 104 ++++++++++++++------ .../notenoughupdates/miscfeatures/FairySouls.java | 103 ++------------------ 4 files changed, 188 insertions(+), 128 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java index 38775ee7..d2603651 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java @@ -166,7 +166,7 @@ public class NEUEventListener { @SubscribeEvent public void onWorldLoad(WorldEvent.Unload event) { NotEnoughUpdates.INSTANCE.saveConfig(); - CrystalMetalDetectorSolver.reset(); + CrystalMetalDetectorSolver.reset(false); } private static long notificationDisplayMillis = 0; @@ -862,7 +862,7 @@ public class NEUEventListener { } } if (unformatted.startsWith("You found ") && SBInfo.getInstance().getLocation() != null && SBInfo.getInstance().getLocation().equals("crystal_hollows")){ - CrystalMetalDetectorSolver.reset(); + CrystalMetalDetectorSolver.reset(true); } if(unformatted.startsWith("[NPC] Keeper of ") | unformatted.startsWith("[NPC] Professor Robot: ") || unformatted.startsWith(" ") || unformatted.startsWith("✦") || unformatted.equals(" You've earned a Crystal Loot Bundle!")) diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/util/render/RenderUtils.java b/src/main/java/io/github/moulberry/notenoughupdates/core/util/render/RenderUtils.java index b63831ac..75c4a35a 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/util/render/RenderUtils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/util/render/RenderUtils.java @@ -1,6 +1,7 @@ package io.github.moulberry.notenoughupdates.core.util.render; import io.github.moulberry.notenoughupdates.core.BackgroundBlur; +import io.github.moulberry.notenoughupdates.miscfeatures.CustomItemEffects; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.Gui; @@ -13,6 +14,8 @@ import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.entity.Entity; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL14; import org.lwjgl.util.vector.Vector3f; @@ -146,9 +149,111 @@ public class RenderUtils { GlStateManager.enableTexture2D(); } + public static BlockPos getCurrentViewer(float partialTicks) { + double viewerX; + double viewerY; + double viewerZ; + + Vector3f aoteInterpPos = CustomItemEffects.INSTANCE.getCurrentPosition(); + if(aoteInterpPos != null) { + viewerX = aoteInterpPos.x; + viewerY = aoteInterpPos.y; + viewerZ = aoteInterpPos.z; + } else { + Entity viewer = Minecraft.getMinecraft().getRenderViewEntity(); + viewerX = viewer.lastTickPosX + (viewer.posX - viewer.lastTickPosX) * partialTicks; + viewerY = viewer.lastTickPosY + (viewer.posY - viewer.lastTickPosY) * partialTicks; + viewerZ = viewer.lastTickPosZ + (viewer.posZ - viewer.lastTickPosZ) * partialTicks; + } + + return new BlockPos(viewerX, viewerY, viewerZ); + } + + private static final ResourceLocation beaconBeam = new ResourceLocation("textures/entity/beacon_beam.png"); + + public static void renderBeaconBeam(double x, double y, double z, int rgb, float alphaMult, float partialTicks) { + int height = 300; + int bottomOffset = 0; + int topOffset = bottomOffset + height; + + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldrenderer = tessellator.getWorldRenderer(); + + Minecraft.getMinecraft().getTextureManager().bindTexture(beaconBeam); + + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT); + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT); + GlStateManager.disableLighting(); + GlStateManager.enableCull(); + GlStateManager.enableTexture2D(); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE, GL11.GL_ZERO); + GlStateManager.enableBlend(); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO); + + double time = Minecraft.getMinecraft().theWorld.getTotalWorldTime() + (double)partialTicks; + double d1 = MathHelper.func_181162_h(-time * 0.2D - (double)MathHelper.floor_double(-time * 0.1D)); + + float r = ((rgb >> 16) & 0xFF) / 255f; + float g = ((rgb >> 8) & 0xFF) / 255f; + float b = (rgb & 0xFF) / 255f; + double d2 = time * 0.025D * -1.5D; + double d4 = 0.5D + Math.cos(d2 + 2.356194490192345D) * 0.2D; + double d5 = 0.5D + Math.sin(d2 + 2.356194490192345D) * 0.2D; + double d6 = 0.5D + Math.cos(d2 + (Math.PI / 4D)) * 0.2D; + double d7 = 0.5D + Math.sin(d2 + (Math.PI / 4D)) * 0.2D; + double d8 = 0.5D + Math.cos(d2 + 3.9269908169872414D) * 0.2D; + double d9 = 0.5D + Math.sin(d2 + 3.9269908169872414D) * 0.2D; + double d10 = 0.5D + Math.cos(d2 + 5.497787143782138D) * 0.2D; + double d11 = 0.5D + Math.sin(d2 + 5.497787143782138D) * 0.2D; + double d14 = -1.0D + d1; + double d15 = (double)(height) * 2.5D + d14; + worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR); + worldrenderer.pos(x + d4, y + topOffset, z + d5).tex(1.0D, d15).color(r, g, b, 1.0F*alphaMult).endVertex(); + worldrenderer.pos(x + d4, y + bottomOffset, z + d5).tex(1.0D, d14).color(r, g, b, 1.0F).endVertex(); + worldrenderer.pos(x + d6, y + bottomOffset, z + d7).tex(0.0D, d14).color(r, g, b, 1.0F).endVertex(); + worldrenderer.pos(x + d6, y + topOffset, z + d7).tex(0.0D, d15).color(r, g, b, 1.0F*alphaMult).endVertex(); + worldrenderer.pos(x + d10, y + topOffset, z + d11).tex(1.0D, d15).color(r, g, b, 1.0F*alphaMult).endVertex(); + worldrenderer.pos(x + d10, y + bottomOffset, z + d11).tex(1.0D, d14).color(r, g, b, 1.0F).endVertex(); + worldrenderer.pos(x + d8, y + bottomOffset, z + d9).tex(0.0D, d14).color(r, g, b, 1.0F).endVertex(); + worldrenderer.pos(x + d8, y + topOffset, z + d9).tex(0.0D, d15).color(r, g, b, 1.0F*alphaMult).endVertex(); + worldrenderer.pos(x + d6, y + topOffset, z + d7).tex(1.0D, d15).color(r, g, b, 1.0F*alphaMult).endVertex(); + worldrenderer.pos(x + d6, y + bottomOffset, z + d7).tex(1.0D, d14).color(r, g, b, 1.0F).endVertex(); + worldrenderer.pos(x + d10, y + bottomOffset, z + d11).tex(0.0D, d14).color(r, g, b, 1.0F).endVertex(); + worldrenderer.pos(x + d10, y + topOffset, z + d11).tex(0.0D, d15).color(r, g, b, 1.0F*alphaMult).endVertex(); + worldrenderer.pos(x + d8, y + topOffset, z + d9).tex(1.0D, d15).color(r, g, b, 1.0F*alphaMult).endVertex(); + worldrenderer.pos(x + d8, y + bottomOffset, z + d9).tex(1.0D, d14).color(r, g, b, 1.0F).endVertex(); + worldrenderer.pos(x + d4, y + bottomOffset, z + d5).tex(0.0D, d14).color(r, g, b, 1.0F).endVertex(); + worldrenderer.pos(x + d4, y + topOffset, z + d5).tex(0.0D, d15).color(r, g, b, 1.0F*alphaMult).endVertex(); + tessellator.draw(); + + GlStateManager.disableCull(); + double d12 = -1.0D + d1; + double d13 = height + d12; + + worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR); + worldrenderer.pos(x + 0.2D, y + topOffset, z + 0.2D).tex(1.0D, d13).color(r, g, b, 0.25F*alphaMult).endVertex(); + worldrenderer.pos(x + 0.2D, y + bottomOffset, z + 0.2D).tex(1.0D, d12).color(r, g, b, 0.25F).endVertex(); + worldrenderer.pos(x + 0.8D, y + bottomOffset, z + 0.2D).tex(0.0D, d12).color(r, g, b, 0.25F).endVertex(); + worldrenderer.pos(x + 0.8D, y + topOffset, z + 0.2D).tex(0.0D, d13).color(r, g, b, 0.25F*alphaMult).endVertex(); + worldrenderer.pos(x + 0.8D, y + topOffset, z + 0.8D).tex(1.0D, d13).color(r, g, b, 0.25F*alphaMult).endVertex(); + worldrenderer.pos(x + 0.8D, y + bottomOffset, z + 0.8D).tex(1.0D, d12).color(r, g, b, 0.25F).endVertex(); + worldrenderer.pos(x + 0.2D, y + bottomOffset, z + 0.8D).tex(0.0D, d12).color(r, g, b, 0.25F).endVertex(); + worldrenderer.pos(x + 0.2D, y + topOffset, z + 0.8D).tex(0.0D, d13).color(r, g, b, 0.25F*alphaMult).endVertex(); + worldrenderer.pos(x + 0.8D, y + topOffset, z + 0.2D).tex(1.0D, d13).color(r, g, b, 0.25F*alphaMult).endVertex(); + worldrenderer.pos(x + 0.8D, y + bottomOffset, z + 0.2D).tex(1.0D, d12).color(r, g, b, 0.25F).endVertex(); + worldrenderer.pos(x + 0.8D, y + bottomOffset, z + 0.8D).tex(0.0D, d12).color(r, g, b, 0.25F).endVertex(); + worldrenderer.pos(x + 0.8D, y + topOffset, z + 0.8D).tex(0.0D, d13).color(r, g, b, 0.25F*alphaMult).endVertex(); + worldrenderer.pos(x + 0.2D, y + topOffset, z + 0.8D).tex(1.0D, d13).color(r, g, b, 0.25F*alphaMult).endVertex(); + worldrenderer.pos(x + 0.2D, y + bottomOffset, z + 0.8D).tex(1.0D, d12).color(r, g, b, 0.25F).endVertex(); + worldrenderer.pos(x + 0.2D, y + bottomOffset, z + 0.2D).tex(0.0D, d12).color(r, g, b, 0.25F).endVertex(); + worldrenderer.pos(x + 0.2D, y + topOffset, z + 0.2D).tex(0.0D, d13).color(r, g, b, 0.25F*alphaMult).endVertex(); + tessellator.draw(); + } + public static void renderWayPoint(String str, BlockPos loc, float partialTicks) { renderWayPoint(str, new Vector3f(loc.getX(), loc.getY(), loc.getZ()), partialTicks); } + public static void renderWayPoint(String str, Vector3f loc, float partialTicks) { GlStateManager.alphaFunc(516, 0.1F); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalMetalDetectorSolver.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalMetalDetectorSolver.java index 73e2b412..3fbff9c8 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalMetalDetectorSolver.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalMetalDetectorSolver.java @@ -11,82 +11,106 @@ import java.util.List; public class CrystalMetalDetectorSolver { private static final Minecraft mc = Minecraft.getMinecraft(); - private static BlockPos prevPos; - private static double prevDist = 0; + private static BlockPos prevPlayerPos; + private static double prevDistToTreasure = 0; private static List possibleBlocks = new ArrayList<>(); private static final List locations = new ArrayList<>(); public static void process(IChatComponent message) { if (SBInfo.getInstance().getLocation() != null && SBInfo.getInstance().getLocation().equals("crystal_hollows") && message.getUnformattedText().contains("TREASURE: ")) { - double dist = Double.parseDouble(message.getUnformattedText().split("TREASURE: ")[1].split("m")[0].replaceAll("(?!\\.)\\D", "")); - if (NotEnoughUpdates.INSTANCE.config.mining.metalDetectorEnabled && prevDist == dist && prevPos.getX() == mc.thePlayer.getPosition().getX() && - prevPos.getY() == mc.thePlayer.getPosition().getY() && - prevPos.getZ() == mc.thePlayer.getPosition().getZ() && !locations.contains(mc.thePlayer.getPosition())) { + double distToTreasure = Double.parseDouble(message.getUnformattedText().split("TREASURE: ")[1].split("m")[0].replaceAll("(?!\\.)\\D", "")); + if (NotEnoughUpdates.INSTANCE.config.mining.metalDetectorEnabled && prevDistToTreasure == distToTreasure && + prevPlayerPos.getX() == mc.thePlayer.getPosition().getX() && + prevPlayerPos.getY() == mc.thePlayer.getPosition().getY() && + prevPlayerPos.getZ() == mc.thePlayer.getPosition().getZ() && !locations.contains(mc.thePlayer.getPosition())) { if (possibleBlocks.size() == 0) { locations.add(mc.thePlayer.getPosition()); - for (int zOffset = (int) Math.floor(-dist); zOffset <= Math.ceil(dist); zOffset++) { + for (int zOffset = (int) Math.floor(-distToTreasure); zOffset <= Math.ceil(distToTreasure); zOffset++) { for (int y = 65; y <= 75; y++) { double calculatedDist = 0; int xOffset = 0; - while (calculatedDist < dist) { + while (calculatedDist < distToTreasure) { BlockPos pos = new BlockPos(Math.floor(mc.thePlayer.posX) + xOffset, y, Math.floor(mc.thePlayer.posZ) + zOffset); - BlockPos above = new BlockPos(Math.floor(mc.thePlayer.posX) + xOffset, - y + 1, Math.floor(mc.thePlayer.posZ) + zOffset); calculatedDist = getPlayerPos().distanceTo(new Vec3(pos).addVector(0D, 1D, 0D)); - if (round(calculatedDist, 1) == dist && treasureAllowed(pos) && !possibleBlocks.contains(pos) && - mc.theWorld.getBlockState(above).getBlock().getRegistryName().equals("minecraft:air")) { + if (round(calculatedDist, 1) == distToTreasure && !possibleBlocks.contains(pos)) { possibleBlocks.add(pos); } xOffset++; } xOffset = 0; calculatedDist = 0; - while (calculatedDist < dist) { + while (calculatedDist < distToTreasure) { BlockPos pos = new BlockPos(Math.floor(mc.thePlayer.posX) - xOffset, y, Math.floor(mc.thePlayer.posZ) + zOffset); - BlockPos above = new BlockPos(Math.floor(mc.thePlayer.posX) - xOffset, - y + 1, Math.floor(mc.thePlayer.posZ) + zOffset); calculatedDist = getPlayerPos().distanceTo(new Vec3(pos).addVector(0D, 1D, 0D)); - if (round(calculatedDist, 1) == dist && treasureAllowed(pos) && !possibleBlocks.contains(pos) && - mc.theWorld.getBlockState(above).getBlock().getRegistryName().equals("minecraft:air")) { + if (round(calculatedDist, 1) == distToTreasure && !possibleBlocks.contains(pos)) { possibleBlocks.add(pos); } xOffset++; } } } + removeDuplicates(); sendMessage(); } else if (possibleBlocks.size() != 1) { locations.add(mc.thePlayer.getPosition()); List temp = new ArrayList<>(); for (BlockPos pos : possibleBlocks) { - if (round(getPlayerPos().distanceTo(new Vec3(pos).addVector(0D, 1D, 0D)), 1) == dist) { + if (round(getPlayerPos().distanceTo(new Vec3(pos).addVector(0D, 1D, 0D)), 1) == distToTreasure) { temp.add(pos); } } possibleBlocks = temp; + removeDuplicates(); sendMessage(); + } else if (possibleBlocks.size() == 1) { + BlockPos pos = possibleBlocks.get(0); + if (distToTreasure > (5 + getPlayerPos().distanceTo(new Vec3(pos)))) { + mc.thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "[NEU] Previous solution is invalid.")); + reset(false); + } } + } - prevPos = mc.thePlayer.getPosition(); - prevDist = dist; + + prevPlayerPos = mc.thePlayer.getPosition(); + prevDistToTreasure = distToTreasure; } } - public static void reset() { + public static void reset(Boolean chestFound) { + if (chestFound) { + // TODO: Add a delay to keep the old chest location from being treated as the new chest location + } + possibleBlocks.clear(); locations.clear(); } public static void render(float partialTicks) { + int beaconRGB = 0xa839ce; + if (SBInfo.getInstance().getLocation() != null && SBInfo.getInstance().getLocation().equals("crystal_hollows") && SBInfo.getInstance().location.equals("Mines of Divan")) { + BlockPos viewer = RenderUtils.getCurrentViewer(partialTicks); + if (possibleBlocks.size() == 1) { + BlockPos block = possibleBlocks.get(0); + double x = block.getX() - viewer.getX(); + double y = block.getY() - viewer.getY(); + double z = block.getZ() - viewer.getZ(); + + RenderUtils.renderBeaconBeam(x, y, z, beaconRGB, 1.0f, partialTicks); RenderUtils.renderWayPoint("Treasure", possibleBlocks.get(0).add(0, 2.5, 0), partialTicks); } else if (possibleBlocks.size() > 1 && NotEnoughUpdates.INSTANCE.config.mining.metalDetectorShowPossible) { for (BlockPos block : possibleBlocks) { + double x = block.getX() - viewer.getX(); + double y = block.getY() - viewer.getY();; + double z = block.getZ() - viewer.getZ();; + + RenderUtils.renderBeaconBeam(x, y, z, beaconRGB, 1.0f, partialTicks); RenderUtils.renderWayPoint("Possible Treasure Location", block.add(0, 2.5, 0), partialTicks); } } @@ -98,14 +122,34 @@ public class CrystalMetalDetectorSolver { return (double) Math.round(value * scale) / scale; } - private static boolean treasureAllowed(BlockPos pos) { - return mc.theWorld.getBlockState(pos).getBlock().getRegistryName().equals("minecraft:gold_block") || - mc.theWorld.getBlockState(pos).getBlock().getRegistryName().equals("minecraft:prismarine") || - mc.theWorld.getBlockState(pos).getBlock().getRegistryName().equals("minecraft:chest") || - mc.theWorld.getBlockState(pos).getBlock().getRegistryName().equals("minecraft:stained_glass") || - mc.theWorld.getBlockState(pos).getBlock().getRegistryName().equals("minecraft:stained_glass_pane") || - mc.theWorld.getBlockState(pos).getBlock().getRegistryName().equals("minecraft:wool") || - mc.theWorld.getBlockState(pos).getBlock().getRegistryName().equals("minecraft:stained_hardened_clay"); + private static void removeDuplicates() { + if (possibleBlocks.size() > 1 && possibleBlocks.size() < 7) { + double firstX = possibleBlocks.get(0).getX(); + double firstZ = possibleBlocks.get(0).getZ(); + Boolean yOnlyDiffers = true; + + double lowestY = possibleBlocks.get(0).getY(); + int lowestYIndex = 0; + + for (int i = 1; i < possibleBlocks.size(); i++) { + BlockPos block = possibleBlocks.get(i); + if (block.getX() != firstX || block.getZ() != firstZ) { + yOnlyDiffers = false; + break; + } + + if (block.getY() < lowestY) { + lowestY = block.getY(); + lowestYIndex = i; + } + } + + if (yOnlyDiffers) { + List temp = new ArrayList<>(); + temp.add(possibleBlocks.get(lowestYIndex)); + possibleBlocks = temp; + } + } } private static void sendMessage() { @@ -114,7 +158,7 @@ public class CrystalMetalDetectorSolver { + possibleBlocks.size())); } else if (possibleBlocks.size() == 0) { mc.thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "[NEU] Failed to find solution.")); - reset(); + reset(false); } else { mc.thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "[NEU] Found solution.")); } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FairySouls.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FairySouls.java index 05591e81..260b94ae 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FairySouls.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FairySouls.java @@ -5,6 +5,7 @@ import com.google.gson.JsonArray; import com.google.gson.JsonObject; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.commands.SimpleCommand; +import io.github.moulberry.notenoughupdates.core.util.render.RenderUtils; import io.github.moulberry.notenoughupdates.options.NEUConfig; import io.github.moulberry.notenoughupdates.util.Constants; import io.github.moulberry.notenoughupdates.util.SBInfo; @@ -166,86 +167,6 @@ public class FairySouls { } } - private static final ResourceLocation beaconBeam = new ResourceLocation("textures/entity/beacon_beam.png"); - - private static void renderBeaconBeam(double x, double y, double z, int rgb, float alphaMult, float partialTicks) { - int height = 300; - int bottomOffset = 0; - int topOffset = bottomOffset + height; - - Tessellator tessellator = Tessellator.getInstance(); - WorldRenderer worldrenderer = tessellator.getWorldRenderer(); - - Minecraft.getMinecraft().getTextureManager().bindTexture(beaconBeam); - GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, 10497.0F); - GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, 10497.0F); - GlStateManager.disableLighting(); - GlStateManager.enableCull(); - GlStateManager.enableTexture2D(); - GlStateManager.tryBlendFuncSeparate(770, 1, 1, 0); - GlStateManager.enableBlend(); - GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); - - double time = Minecraft.getMinecraft().theWorld.getTotalWorldTime() + (double)partialTicks; - double d1 = MathHelper.func_181162_h(-time * 0.2D - (double)MathHelper.floor_double(-time * 0.1D)); - - float r = ((rgb >> 16) & 0xFF) / 255f; - float g = ((rgb >> 8) & 0xFF) / 255f; - float b = (rgb & 0xFF) / 255f; - double d2 = time * 0.025D * -1.5D; - double d4 = 0.5D + Math.cos(d2 + 2.356194490192345D) * 0.2D; - double d5 = 0.5D + Math.sin(d2 + 2.356194490192345D) * 0.2D; - double d6 = 0.5D + Math.cos(d2 + (Math.PI / 4D)) * 0.2D; - double d7 = 0.5D + Math.sin(d2 + (Math.PI / 4D)) * 0.2D; - double d8 = 0.5D + Math.cos(d2 + 3.9269908169872414D) * 0.2D; - double d9 = 0.5D + Math.sin(d2 + 3.9269908169872414D) * 0.2D; - double d10 = 0.5D + Math.cos(d2 + 5.497787143782138D) * 0.2D; - double d11 = 0.5D + Math.sin(d2 + 5.497787143782138D) * 0.2D; - double d14 = -1.0D + d1; - double d15 = (double)(height) * 2.5D + d14; - worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR); - worldrenderer.pos(x + d4, y + topOffset, z + d5).tex(1.0D, d15).color(r, g, b, 1.0F*alphaMult).endVertex(); - worldrenderer.pos(x + d4, y + bottomOffset, z + d5).tex(1.0D, d14).color(r, g, b, 1.0F).endVertex(); - worldrenderer.pos(x + d6, y + bottomOffset, z + d7).tex(0.0D, d14).color(r, g, b, 1.0F).endVertex(); - worldrenderer.pos(x + d6, y + topOffset, z + d7).tex(0.0D, d15).color(r, g, b, 1.0F*alphaMult).endVertex(); - worldrenderer.pos(x + d10, y + topOffset, z + d11).tex(1.0D, d15).color(r, g, b, 1.0F*alphaMult).endVertex(); - worldrenderer.pos(x + d10, y + bottomOffset, z + d11).tex(1.0D, d14).color(r, g, b, 1.0F).endVertex(); - worldrenderer.pos(x + d8, y + bottomOffset, z + d9).tex(0.0D, d14).color(r, g, b, 1.0F).endVertex(); - worldrenderer.pos(x + d8, y + topOffset, z + d9).tex(0.0D, d15).color(r, g, b, 1.0F*alphaMult).endVertex(); - worldrenderer.pos(x + d6, y + topOffset, z + d7).tex(1.0D, d15).color(r, g, b, 1.0F*alphaMult).endVertex(); - worldrenderer.pos(x + d6, y + bottomOffset, z + d7).tex(1.0D, d14).color(r, g, b, 1.0F).endVertex(); - worldrenderer.pos(x + d10, y + bottomOffset, z + d11).tex(0.0D, d14).color(r, g, b, 1.0F).endVertex(); - worldrenderer.pos(x + d10, y + topOffset, z + d11).tex(0.0D, d15).color(r, g, b, 1.0F*alphaMult).endVertex(); - worldrenderer.pos(x + d8, y + topOffset, z + d9).tex(1.0D, d15).color(r, g, b, 1.0F*alphaMult).endVertex(); - worldrenderer.pos(x + d8, y + bottomOffset, z + d9).tex(1.0D, d14).color(r, g, b, 1.0F).endVertex(); - worldrenderer.pos(x + d4, y + bottomOffset, z + d5).tex(0.0D, d14).color(r, g, b, 1.0F).endVertex(); - worldrenderer.pos(x + d4, y + topOffset, z + d5).tex(0.0D, d15).color(r, g, b, 1.0F*alphaMult).endVertex(); - tessellator.draw(); - - GlStateManager.disableCull(); - double d12 = -1.0D + d1; - double d13 = height + d12; - - worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR); - worldrenderer.pos(x + 0.2D, y + topOffset, z + 0.2D).tex(1.0D, d13).color(r, g, b, 0.25F*alphaMult).endVertex(); - worldrenderer.pos(x + 0.2D, y + bottomOffset, z + 0.2D).tex(1.0D, d12).color(r, g, b, 0.25F).endVertex(); - worldrenderer.pos(x + 0.8D, y + bottomOffset, z + 0.2D).tex(0.0D, d12).color(r, g, b, 0.25F).endVertex(); - worldrenderer.pos(x + 0.8D, y + topOffset, z + 0.2D).tex(0.0D, d13).color(r, g, b, 0.25F*alphaMult).endVertex(); - worldrenderer.pos(x + 0.8D, y + topOffset, z + 0.8D).tex(1.0D, d13).color(r, g, b, 0.25F*alphaMult).endVertex(); - worldrenderer.pos(x + 0.8D, y + bottomOffset, z + 0.8D).tex(1.0D, d12).color(r, g, b, 0.25F).endVertex(); - worldrenderer.pos(x + 0.2D, y + bottomOffset, z + 0.8D).tex(0.0D, d12).color(r, g, b, 0.25F).endVertex(); - worldrenderer.pos(x + 0.2D, y + topOffset, z + 0.8D).tex(0.0D, d13).color(r, g, b, 0.25F*alphaMult).endVertex(); - worldrenderer.pos(x + 0.8D, y + topOffset, z + 0.2D).tex(1.0D, d13).color(r, g, b, 0.25F*alphaMult).endVertex(); - worldrenderer.pos(x + 0.8D, y + bottomOffset, z + 0.2D).tex(1.0D, d12).color(r, g, b, 0.25F).endVertex(); - worldrenderer.pos(x + 0.8D, y + bottomOffset, z + 0.8D).tex(0.0D, d12).color(r, g, b, 0.25F).endVertex(); - worldrenderer.pos(x + 0.8D, y + topOffset, z + 0.8D).tex(0.0D, d13).color(r, g, b, 0.25F*alphaMult).endVertex(); - worldrenderer.pos(x + 0.2D, y + topOffset, z + 0.8D).tex(1.0D, d13).color(r, g, b, 0.25F*alphaMult).endVertex(); - worldrenderer.pos(x + 0.2D, y + bottomOffset, z + 0.8D).tex(1.0D, d12).color(r, g, b, 0.25F).endVertex(); - worldrenderer.pos(x + 0.2D, y + bottomOffset, z + 0.2D).tex(0.0D, d12).color(r, g, b, 0.25F).endVertex(); - worldrenderer.pos(x + 0.2D, y + topOffset, z + 0.2D).tex(0.0D, d13).color(r, g, b, 0.25F*alphaMult).endVertex(); - tessellator.draw(); - } - @SubscribeEvent public void onRenderLast(RenderWorldLastEvent event) { if(!enabled) return; @@ -254,26 +175,16 @@ public class FairySouls { if(location == null) return; if(currentSoulList == null || currentSoulList.isEmpty()) return; - Entity viewer = Minecraft.getMinecraft().getRenderViewEntity(); - double viewerX = viewer.lastTickPosX + (viewer.posX - viewer.lastTickPosX) * event.partialTicks; - double viewerY = viewer.lastTickPosY + (viewer.posY - viewer.lastTickPosY) * event.partialTicks; - double viewerZ = viewer.lastTickPosZ + (viewer.posZ - viewer.lastTickPosZ) * event.partialTicks; - - Vector3f aoteInterpPos = CustomItemEffects.INSTANCE.getCurrentPosition(); - if(aoteInterpPos != null) { - viewerX = aoteInterpPos.x; - viewerY = aoteInterpPos.y; - viewerZ = aoteInterpPos.z; - } - Set found = foundSouls.computeIfAbsent(location, k -> new HashSet<>()); + BlockPos viewer = RenderUtils.getCurrentViewer(event.partialTicks); + int rgb = 0xa839ce; for(int i=0; i 10*10) { - renderBeaconBeam(x, y, z, rgb, 1.0f, event.partialTicks); + RenderUtils.renderBeaconBeam(x, y, z, rgb, 1.0f, event.partialTicks); } } -- cgit From 935ecebae26a2551ab330e0f0e28c8233df852e8 Mon Sep 17 00:00:00 2001 From: David Mills <85420839+Keebler408@users.noreply.github.com> Date: Thu, 9 Sep 2021 11:21:08 -0500 Subject: Use proximity for dupes, delay after finding chest --- .../miscfeatures/CrystalMetalDetectorSolver.java | 41 +++++++++++++++------- 1 file changed, 28 insertions(+), 13 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalMetalDetectorSolver.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalMetalDetectorSolver.java index 3fbff9c8..b457f274 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalMetalDetectorSolver.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalMetalDetectorSolver.java @@ -16,7 +16,24 @@ public class CrystalMetalDetectorSolver { private static List possibleBlocks = new ArrayList<>(); private static final List locations = new ArrayList<>(); + private static Boolean chestRecentlyFound = false; + private static long chestLastFoundMillis = 0; + public static void process(IChatComponent message) { + // Delay to keep old chest location from being treated as the new chest location + if (chestRecentlyFound) { + long currentTimeMillis = System.currentTimeMillis(); + if (chestLastFoundMillis == 0) { + chestLastFoundMillis = currentTimeMillis; + return; + } else if(currentTimeMillis - chestLastFoundMillis < 1000) { + return; + } + + chestLastFoundMillis = 0; + chestRecentlyFound = false; + } + if (SBInfo.getInstance().getLocation() != null && SBInfo.getInstance().getLocation().equals("crystal_hollows") && message.getUnformattedText().contains("TREASURE: ")) { double distToTreasure = Double.parseDouble(message.getUnformattedText().split("TREASURE: ")[1].split("m")[0].replaceAll("(?!\\.)\\D", "")); @@ -81,10 +98,7 @@ public class CrystalMetalDetectorSolver { } public static void reset(Boolean chestFound) { - if (chestFound) { - // TODO: Add a delay to keep the old chest location from being treated as the new chest location - } - + chestRecentlyFound = chestFound; possibleBlocks.clear(); locations.clear(); } @@ -124,27 +138,28 @@ public class CrystalMetalDetectorSolver { private static void removeDuplicates() { if (possibleBlocks.size() > 1 && possibleBlocks.size() < 7) { - double firstX = possibleBlocks.get(0).getX(); - double firstZ = possibleBlocks.get(0).getZ(); - Boolean yOnlyDiffers = true; + Vec3 firstBlockVec = new Vec3( possibleBlocks.get(0).getX(), 0, possibleBlocks.get(0).getZ()); + Boolean allBlocksAreClose = true; double lowestY = possibleBlocks.get(0).getY(); int lowestYIndex = 0; for (int i = 1; i < possibleBlocks.size(); i++) { - BlockPos block = possibleBlocks.get(i); - if (block.getX() != firstX || block.getZ() != firstZ) { - yOnlyDiffers = false; + BlockPos blockPos = possibleBlocks.get(i); + Vec3 blockVec = new Vec3(blockPos.getX(), 0, blockPos.getZ()); + + if (firstBlockVec.distanceTo(blockVec) > 3) { + allBlocksAreClose = false; break; } - if (block.getY() < lowestY) { - lowestY = block.getY(); + if (blockPos.getY() < lowestY) { + lowestY = blockPos.getY(); lowestYIndex = i; } } - if (yOnlyDiffers) { + if (allBlocksAreClose) { List temp = new ArrayList<>(); temp.add(possibleBlocks.get(lowestYIndex)); possibleBlocks = temp; -- cgit From 29cea4c4922443ae78c47cd49e4a74ab67eb15f2 Mon Sep 17 00:00:00 2001 From: David Mills <85420839+Keebler408@users.noreply.github.com> Date: Fri, 10 Sep 2021 08:11:15 -0500 Subject: Small tweaks based on more testing --- .../notenoughupdates/miscfeatures/CrystalMetalDetectorSolver.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalMetalDetectorSolver.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalMetalDetectorSolver.java index b457f274..1172f1c5 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalMetalDetectorSolver.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalMetalDetectorSolver.java @@ -118,7 +118,8 @@ public class CrystalMetalDetectorSolver { RenderUtils.renderBeaconBeam(x, y, z, beaconRGB, 1.0f, partialTicks); RenderUtils.renderWayPoint("Treasure", possibleBlocks.get(0).add(0, 2.5, 0), partialTicks); - } else if (possibleBlocks.size() > 1 && NotEnoughUpdates.INSTANCE.config.mining.metalDetectorShowPossible) { + } else if (possibleBlocks.size() > 1 && (locations.size() > 1 || possibleBlocks.size() < 10) && + NotEnoughUpdates.INSTANCE.config.mining.metalDetectorShowPossible) { for (BlockPos block : possibleBlocks) { double x = block.getX() - viewer.getX(); double y = block.getY() - viewer.getY();; @@ -137,7 +138,7 @@ public class CrystalMetalDetectorSolver { } private static void removeDuplicates() { - if (possibleBlocks.size() > 1 && possibleBlocks.size() < 7) { + if (possibleBlocks.size() > 1 && possibleBlocks.size() < 10) { Vec3 firstBlockVec = new Vec3( possibleBlocks.get(0).getX(), 0, possibleBlocks.get(0).getZ()); Boolean allBlocksAreClose = true; -- cgit From e0a71fdc7a1bf466992fc6db96a15b778909cc18 Mon Sep 17 00:00:00 2001 From: David Mills <85420839+Keebler408@users.noreply.github.com> Date: Sat, 11 Sep 2021 10:35:55 -0500 Subject: Fix jitter, improve metal detector beacon - Fix jitter caused by location coord truncation from double to int - Move remaining fairy souls beacon rendering into RenderUtils.java - Add beacon option to enable depth testing when player is close by - Use new rendering for metal detector to make beacons more visible --- .../core/util/render/RenderUtils.java | 112 ++++++++++++++++----- .../miscfeatures/CrystalMetalDetectorSolver.java | 12 +-- .../notenoughupdates/miscfeatures/FairySouls.java | 32 +----- 3 files changed, 89 insertions(+), 67 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/util/render/RenderUtils.java b/src/main/java/io/github/moulberry/notenoughupdates/core/util/render/RenderUtils.java index 75c4a35a..5f0ad94f 100644 --- a/src/main/java/io/github/m