aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java2
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/listener/ChatListener.java9
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/EnderNodes.java6
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/world/EnderNodeHighlighter.java97
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/world/GenericBlockHighlighter.java61
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/world/GlowingMushroomHighlighter.java4
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Notifications.java2
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/WorldConfig.java39
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/MathUtil.java6
9 files changed, 201 insertions, 25 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java
index 8ea94615..14ee656a 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java
@@ -67,6 +67,7 @@ import io.github.moulberry.notenoughupdates.miscfeatures.customblockzones.Custom
import io.github.moulberry.notenoughupdates.miscfeatures.customblockzones.CustomBlockSounds;
import io.github.moulberry.notenoughupdates.miscfeatures.customblockzones.DwarvenMinesTextures;
import io.github.moulberry.notenoughupdates.miscfeatures.updater.AutoUpdater;
+import io.github.moulberry.notenoughupdates.miscfeatures.world.EnderNodeHighlighter;
import io.github.moulberry.notenoughupdates.miscfeatures.world.GlowingMushroomHighlighter;
import io.github.moulberry.notenoughupdates.miscgui.CalendarOverlay;
import io.github.moulberry.notenoughupdates.miscgui.InventoryStorageSelector;
@@ -339,6 +340,7 @@ public class NotEnoughUpdates {
MinecraftForge.EVENT_BUS.register(new GlowingMushroomHighlighter());
MinecraftForge.EVENT_BUS.register(new WorldListener(this));
MinecraftForge.EVENT_BUS.register(TitleUtil.getInstance());
+ MinecraftForge.EVENT_BUS.register(EnderNodeHighlighter.getInstance());
MinecraftForge.EVENT_BUS.register(AbiphoneFavourites.getInstance());
if (Minecraft.getMinecraft().getResourceManager() instanceof IReloadableResourceManager) {
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/listener/ChatListener.java b/src/main/java/io/github/moulberry/notenoughupdates/listener/ChatListener.java
index 6dd6b6b7..54c378ec 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/listener/ChatListener.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/listener/ChatListener.java
@@ -25,6 +25,7 @@ import io.github.moulberry.notenoughupdates.miscfeatures.CookieWarning;
import io.github.moulberry.notenoughupdates.miscfeatures.CrystalMetalDetectorSolver;
import io.github.moulberry.notenoughupdates.miscfeatures.EnderNodes;
import io.github.moulberry.notenoughupdates.miscfeatures.StreamerMode;
+import io.github.moulberry.notenoughupdates.miscfeatures.world.EnderNodeHighlighter;
import io.github.moulberry.notenoughupdates.overlays.OverlayManager;
import io.github.moulberry.notenoughupdates.overlays.SlayerOverlay;
import io.github.moulberry.notenoughupdates.overlays.TimersOverlay;
@@ -310,8 +311,10 @@ public class ChatListener {
|| (unformatted.startsWith("You received +") && unformatted.endsWith(" Powder")))
OverlayManager.powderGrindingOverlay.message(unformatted);
- if (unformatted.equals("ENDER NODE! You found Endermite Nest!")) {
- EnderNodes.dispalyEndermiteNotif();
- }
+ if (unformatted.startsWith("ENDER NODE!"))
+ EnderNodeHighlighter.getInstance().highlightedBlocks.clear();
+
+ if (unformatted.equals("ENDER NODE! You found Endermite Nest!"))
+ EnderNodes.displayEndermiteNotif();
}
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/EnderNodes.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/EnderNodes.java
index b0823a7d..874c0a93 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/EnderNodes.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/EnderNodes.java
@@ -24,13 +24,9 @@ import io.github.moulberry.notenoughupdates.util.SBInfo;
import io.github.moulberry.notenoughupdates.util.SpecialColour;
import io.github.moulberry.notenoughupdates.util.TitleUtil;
import net.minecraft.client.Minecraft;
-import net.minecraft.util.ChatComponentText;
public class EnderNodes {
- // TODO Add ender node highliter
- // TODO Add ender node counter ( maybe money estimation )
-
- public static void dispalyEndermiteNotif() {
+ public static void displayEndermiteNotif() {
if (NotEnoughUpdates.INSTANCE.config.notifications.endermiteAlert && SBInfo.getInstance().getLocation() != null &&
SBInfo.getInstance().getLocation().equals("combat_3")) {
TitleUtil.getInstance().createTitle("Nested Endermite",
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/world/EnderNodeHighlighter.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/world/EnderNodeHighlighter.java
new file mode 100644
index 00000000..ce0e6a25
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/world/EnderNodeHighlighter.java
@@ -0,0 +1,97 @@
+/*
+ * Copyright (C) 2022 NotEnoughUpdates contributors
+ *
+ * This file is part of NotEnoughUpdates.
+ *
+ * NotEnoughUpdates is free software: you can redistribute it
+ * and/or modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation, either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * NotEnoughUpdates is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package io.github.moulberry.notenoughupdates.miscfeatures.world;
+
+import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
+import io.github.moulberry.notenoughupdates.events.SpawnParticleEvent;
+import io.github.moulberry.notenoughupdates.util.SBInfo;
+import io.github.moulberry.notenoughupdates.util.SpecialColour;
+import net.minecraft.block.Block;
+import net.minecraft.client.Minecraft;
+import net.minecraft.init.Blocks;
+import net.minecraft.util.BlockPos;
+import net.minecraft.util.EnumParticleTypes;
+import net.minecraft.world.World;
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
+
+import static io.github.moulberry.notenoughupdates.util.MathUtil.basicallyEqual;
+
+public class EnderNodeHighlighter extends GenericBlockHighlighter {
+
+ private static final EnderNodeHighlighter INSTANCE = new EnderNodeHighlighter();
+
+ public static EnderNodeHighlighter getInstance()
+ {
+ return INSTANCE;
+ }
+
+
+ @SubscribeEvent
+ public void onParticleSpawn(SpawnParticleEvent event) {
+ if (!isEnabled()) return;
+ if (event.getParticleTypes() == EnumParticleTypes.PORTAL) {
+ double x = event.getXCoord();
+ double y = event.getYCoord();
+ double z = event.getZCoord();
+
+ boolean xZero = basicallyEqual((x - 0.5) % 1, 0, 0.2);
+ boolean yZero = basicallyEqual((y - 0.5) % 1, 0, 0.2);
+ boolean zZero = basicallyEqual((z - 0.5) % 1, 0, 0.2);
+
+ if (Math.abs(y % 1) == 0.25 && xZero && zZero) {
+ if (tryRegisterInterest(x, y - 1, z)) return;
+ }
+ if (Math.abs(y % 1) == 0.75 && xZero && zZero) {
+ if (tryRegisterInterest(x, y + 1, z)) return;
+ }
+ if (Math.abs(x % 1) == 0.25 && yZero && zZero) {
+ if (tryRegisterInterest(x + 1, y, z)) return;
+ }
+ if (Math.abs(x % 1) == 0.75 && yZero && zZero) {
+ if (tryRegisterInterest(x - 1, y, z)) return;
+ }
+ if (Math.abs(z % 1) == 0.25 && yZero && xZero) {
+ if (tryRegisterInterest(x, y, z + 1)) return;
+ }
+ if (Math.abs(z % 1) == 0.75 && yZero && xZero) {
+ tryRegisterInterest(x, y, z - 1);
+ }
+ }
+ }
+
+ @Override
+ protected boolean isEnabled() {
+ return "combat_3".equals(SBInfo.getInstance().getLocation())
+ && NotEnoughUpdates.INSTANCE.config.world.highlightEnderNodes;
+ }
+
+ @Override
+ protected boolean isValidHighlightSpot(BlockPos key) {
+ World w = Minecraft.getMinecraft().theWorld;
+ if (w == null) return false;
+ Block b = w.getBlockState(key).getBlock();
+ return b == Blocks.end_stone || b == Blocks.obsidian;
+ }
+
+ @Override
+ protected int getColor(BlockPos blockPos) {
+ return SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.config.world.enderNodeColor);
+ }
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/world/GenericBlockHighlighter.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/world/GenericBlockHighlighter.java
index 0e71c7a9..67d6f46e 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/world/GenericBlockHighlighter.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/world/GenericBlockHighlighter.java
@@ -56,34 +56,69 @@ public abstract class GenericBlockHighlighter {
@SubscribeEvent
public void onTick(TickEvent.ClientTickEvent ev) {
if (ev.phase != TickEvent.Phase.END) return;
- highlightedBlocks.removeIf(it -> !isValidHighlightSpot(it) || !canPlayerSeeBlock(it.getX(), it.getY(), it.getZ()));
+ highlightedBlocks.removeIf(it -> !isValidHighlightSpot(it) ||
+ !canPlayerSeeNearBlocks(it.getX(), it.getY(), it.getZ()));
}
protected boolean canPlayerSeeBlock(double xCoord, double yCoord, double zCoord) {
EntityPlayerSP p = Minecraft.getMinecraft().thePlayer;
if (p == null) return false;
- World w = p.worldObj;
- MovingObjectPosition hitResult = w.rayTraceBlocks(
- new Vec3(p.posX, p.posY + p.eyeHeight, p.posZ),
- new Vec3(xCoord, yCoord, zCoord),
- false,
- true,
- true
- );
- BlockPos bp = new BlockPos(xCoord, yCoord, zCoord);
+ Vec3 playerPosition = new Vec3(p.posX, p.posY + p.eyeHeight, p.posZ);
+ MovingObjectPosition hitResult = rayTraceBlocks(p.worldObj, playerPosition, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5);
+ return canSee(hitResult, new BlockPos(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5));
+ }
+
+ protected boolean canPlayerSeeNearBlocks(double x, double y, double z) {
+ EntityPlayerSP p = Minecraft.getMinecraft().thePlayer;
+ if (p == null) return false;
+ World world = p.worldObj;
+ Vec3 playerPosition = new Vec3(p.posX, p.posY + p.eyeHeight, p.posZ);
+ BlockPos blockPos = new BlockPos(x, y, z);
+ MovingObjectPosition hitResult1 = rayTraceBlocks(world, playerPosition, x, y, z);
+ if (canSee(hitResult1, blockPos)) return true;
+ MovingObjectPosition hitResult2 = rayTraceBlocks(world, playerPosition, x + 1, y, z);
+ if (canSee(hitResult2, blockPos.add(1, 0, 1))) return true;
+ MovingObjectPosition hitResult3 = rayTraceBlocks(world, playerPosition, x + 1, y + 1, z);
+ if (canSee(hitResult3, blockPos.add(1, 1, 0))) return true;
+ MovingObjectPosition hitResult4 = rayTraceBlocks(world, playerPosition, x + 1, y + 1, z + 1);
+ if (canSee(hitResult4, blockPos.add(1, 1, 1))) return true;
+
+ MovingObjectPosition hitResult5 = rayTraceBlocks(world, playerPosition, x, y + 1, z + 1);
+ if (canSee(hitResult5, blockPos.add(0, 1, 1))) return true;
+ MovingObjectPosition hitResult6 = rayTraceBlocks(world, playerPosition, x, y + 1, z);
+ if (canSee(hitResult6, blockPos.add(0, 1, 0))) return true;
+ MovingObjectPosition hitResult7 = rayTraceBlocks(world, playerPosition, x + 1, y, z + 1);
+ if (canSee(hitResult7, blockPos.add(1, 0, 1))) return true;
+ MovingObjectPosition hitResult8 = rayTraceBlocks(world, playerPosition, x, y + 1, z);
+ if (canSee(hitResult8, blockPos.add(0, 1, 0))) return true;
+
+ return false;
+ }
+
+ private static boolean canSee(MovingObjectPosition hitResult, BlockPos bp) {
return hitResult == null
|| hitResult.typeOfHit != MovingObjectPosition.MovingObjectType.BLOCK
|| bp.equals(hitResult.getBlockPos());
}
+ private static MovingObjectPosition rayTraceBlocks(World world, Vec3 playerPosition, double x, double y, double z) {
+ return world.rayTraceBlocks(playerPosition, new Vec3(x, y, z), false, true, true);
+ }
+
@SubscribeEvent
public void onWorldChange(WorldEvent.Load event) {
highlightedBlocks.clear();
}
- public void registerInterest(BlockPos pos) {
- if (isValidHighlightSpot(pos) && canPlayerSeeBlock(pos.getX(), pos.getY(), pos.getZ())) {
- highlightedBlocks.add(pos);
+ public boolean tryRegisterInterest(double x, double y, double z) {
+ BlockPos blockPos = new BlockPos(x, y, z);
+ boolean contains = highlightedBlocks.contains(blockPos);
+ if (!contains) {
+ boolean canSee = canPlayerSeeNearBlocks(blockPos.getX(), blockPos.getY(), blockPos.getZ());
+ if (isValidHighlightSpot(blockPos) && canSee) {
+ highlightedBlocks.add(blockPos);
+ }
}
+ return contains;
}
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/world/GlowingMushroomHighlighter.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/world/GlowingMushroomHighlighter.java
index 9857f84b..fa5794ea 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/world/GlowingMushroomHighlighter.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/world/GlowingMushroomHighlighter.java
@@ -39,14 +39,12 @@ public class GlowingMushroomHighlighter extends GenericBlockHighlighter {
public void onParticleSpawn(SpawnParticleEvent event) {
if (!isEnabled()) return;
if (event.getParticleTypes() == EnumParticleTypes.SPELL_MOB) {
- BlockPos blockPos = new BlockPos(event.getXCoord(), event.getYCoord(), event.getZCoord());
- if (highlightedBlocks.contains(blockPos)) return;
if (
isDecimalPartApproximately(event.getXCoord(), 0.5)
&& isDecimalPartApproximately(event.getYCoord(), 0.1)
&& isDecimalPartApproximately(event.getZCoord(), 0.5)
) {
- registerInterest(blockPos);
+ tryRegisterInterest(event.getXCoord(), event.getYCoord(), event.getZCoord());
}
}
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Notifications.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Notifications.java
index 3541860d..543ace07 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Notifications.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Notifications.java
@@ -96,7 +96,7 @@ public class Notifications {
desc = ""
)
@ConfigEditorAccordion(id = 1)
- public boolean enderNodeAccordion = false;
+ public boolean enderNodeAccordion = true;
@Expose
@ConfigOption(
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/WorldConfig.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/WorldConfig.java
index 1484cb87..e8c822b2 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/WorldConfig.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/WorldConfig.java
@@ -20,17 +20,29 @@
package io.github.moulberry.notenoughupdates.options.seperateSections;
import com.google.gson.annotations.Expose;
+import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigAccordionId;
+import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorAccordion;
import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorBoolean;
import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorColour;
import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigOption;
public class WorldConfig {
+
+ @Expose
+ @ConfigOption(
+ name = "Glowing Mushrooms",
+ desc = ""
+ )
+ @ConfigEditorAccordion(id = 1)
+ public boolean glowingMushroomAccordion = true;
+
@Expose
@ConfigOption(
name = "Highlight Glowing Mushrooms",
desc = "Highlight glowing mushrooms in the mushroom gorge"
)
@ConfigEditorBoolean
+ @ConfigAccordionId(id = 1)
public boolean highlightGlowingMushrooms = false;
@Expose
@@ -39,5 +51,32 @@ public class WorldConfig {
desc = "In which colour should glowing mushrooms be highlighted"
)
@ConfigEditorColour
+ @ConfigAccordionId(id = 1)
public String glowingMushroomColor = "0:255:142:88:36";
+
+ @Expose
+ @ConfigOption(
+ name = "Ender Nodes",
+ desc = ""
+ )
+ @ConfigEditorAccordion(id = 2)
+ public boolean enderNodeAccordion = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Highlight Ender Nodes",
+ desc = "Highlight ender nodes in the end"
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 2)
+ public boolean highlightEnderNodes = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Ender Nodes Color",
+ desc = "In which color should ender nodes be highlighted"
+ )
+ @ConfigEditorColour
+ @ConfigAccordionId(id = 2)
+ public String enderNodeColor = "0:255:0:255:0";
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/MathUtil.java b/src/main/java/io/github/moulberry/notenoughupdates/util/MathUtil.java
index f358f37f..c440e637 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/MathUtil.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/MathUtil.java
@@ -23,4 +23,10 @@ public class MathUtil {
public static boolean isDecimalPartApproximately(double fullValue, double expectedDecimalPart) {
return Math.abs(Math.abs(fullValue % 1) - expectedDecimalPart) < 0.01;
}
+ public static boolean basicallyEqual(double num1, double num2, double dist) {
+ return Math.abs(num1 - num2) < dist;
+ }
+ public static boolean basicallyEqual(double num1, double num2) {
+ return Math.abs(num1 - num2) < 0.01;
+ }
}