aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKevin <92656833+kevinthegreat1@users.noreply.github.com>2024-04-12 10:25:59 -0400
committerGitHub <noreply@github.com>2024-04-12 10:25:59 -0400
commit8de8c711946c32f091660253f47f96c506fb33d7 (patch)
tree7a6e65bb296e05c0f273531913af2c9373523b6c /src
parentfa978596931a020cca07ac5d19ed39807d0704e4 (diff)
downloadSkyblocker-8de8c711946c32f091660253f47f96c506fb33d7.tar.gz
Skyblocker-8de8c711946c32f091660253f47f96c506fb33d7.tar.bz2
Skyblocker-8de8c711946c32f091660253f47f96c506fb33d7.zip
Add Ender Nodes Helper (#629)
Diffstat (limited to 'src')
-rw-r--r--src/main/java/de/hysky/skyblocker/SkyblockerMod.java2
-rw-r--r--src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java2
-rw-r--r--src/main/java/de/hysky/skyblocker/config/categories/LocationsCategory.java7
-rw-r--r--src/main/java/de/hysky/skyblocker/mixin/ClientPlayNetworkHandlerMixin.java2
-rw-r--r--src/main/java/de/hysky/skyblocker/skyblock/end/EnderNodes.java138
-rw-r--r--src/main/resources/assets/skyblocker/lang/en_us.json1
6 files changed, 152 insertions, 0 deletions
diff --git a/src/main/java/de/hysky/skyblocker/SkyblockerMod.java b/src/main/java/de/hysky/skyblocker/SkyblockerMod.java
index 485a2103..d60eee73 100644
--- a/src/main/java/de/hysky/skyblocker/SkyblockerMod.java
+++ b/src/main/java/de/hysky/skyblocker/SkyblockerMod.java
@@ -21,6 +21,7 @@ import de.hysky.skyblocker.skyblock.dwarven.CrystalsHud;
import de.hysky.skyblocker.skyblock.dwarven.CrystalsLocationsManager;
import de.hysky.skyblocker.skyblock.dwarven.DwarvenHud;
import de.hysky.skyblocker.skyblock.end.BeaconHighlighter;
+import de.hysky.skyblocker.skyblock.end.EnderNodes;
import de.hysky.skyblocker.skyblock.end.TheEnd;
import de.hysky.skyblocker.skyblock.garden.FarmingHud;
import de.hysky.skyblocker.skyblock.garden.LowerSensitivity;
@@ -110,6 +111,7 @@ public class SkyblockerMod implements ClientModInitializer {
FairySouls.init();
Relics.init();
MythologicalRitual.init();
+ EnderNodes.init();
OrderedWaypoints.init();
BackpackPreview.init();
QuickNav.init();
diff --git a/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java b/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java
index 418cc4d1..bf98ac1f 100644
--- a/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java
+++ b/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java
@@ -1071,6 +1071,8 @@ public class SkyblockerConfig {
}
public static class TheEnd {
+ @SerialEntry
+ public boolean enableEnderNodeHelper = true;
@SerialEntry
public boolean hudEnabled = true;
diff --git a/src/main/java/de/hysky/skyblocker/config/categories/LocationsCategory.java b/src/main/java/de/hysky/skyblocker/config/categories/LocationsCategory.java
index 67512b78..46f3067c 100644
--- a/src/main/java/de/hysky/skyblocker/config/categories/LocationsCategory.java
+++ b/src/main/java/de/hysky/skyblocker/config/categories/LocationsCategory.java
@@ -85,6 +85,13 @@ public class LocationsCategory {
.name(Text.translatable("text.autoconfig.skyblocker.option.locations.end"))
.collapsed(false)
.option(Option.<Boolean>createBuilder()
+ .name(Text.translatable("text.autoconfig.skyblocker.option.locations.end.enableEnderNodeHelper"))
+ .binding(defaults.locations.end.enableEnderNodeHelper,
+ () -> config.locations.end.enableEnderNodeHelper,
+ newValue -> config.locations.end.enableEnderNodeHelper = newValue)
+ .controller(ConfigUtils::createBooleanController)
+ .build())
+ .option(Option.<Boolean>createBuilder()
.name(Text.translatable("text.autoconfig.skyblocker.option.locations.end.hudEnabled"))
.binding(defaults.locations.end.hudEnabled,
() -> config.locations.end.hudEnabled,
diff --git a/src/main/java/de/hysky/skyblocker/mixin/ClientPlayNetworkHandlerMixin.java b/src/main/java/de/hysky/skyblocker/mixin/ClientPlayNetworkHandlerMixin.java
index 8397292b..743f949f 100644
--- a/src/main/java/de/hysky/skyblocker/mixin/ClientPlayNetworkHandlerMixin.java
+++ b/src/main/java/de/hysky/skyblocker/mixin/ClientPlayNetworkHandlerMixin.java
@@ -7,6 +7,7 @@ import de.hysky.skyblocker.skyblock.FishingHelper;
import de.hysky.skyblocker.skyblock.dungeon.DungeonScore;
import de.hysky.skyblocker.skyblock.dungeon.secrets.DungeonManager;
import de.hysky.skyblocker.skyblock.end.BeaconHighlighter;
+import de.hysky.skyblocker.skyblock.end.EnderNodes;
import de.hysky.skyblocker.skyblock.end.TheEnd;
import de.hysky.skyblocker.skyblock.waypoint.MythologicalRitual;
import de.hysky.skyblocker.utils.SlayerUtils;
@@ -91,6 +92,7 @@ public abstract class ClientPlayNetworkHandlerMixin {
@Inject(method = "onParticle", at = @At("RETURN"))
private void skyblocker$onParticle(ParticleS2CPacket packet, CallbackInfo ci) {
MythologicalRitual.onParticle(packet);
+ EnderNodes.onParticle(packet);
}
@ModifyExpressionValue(method = "onEntityStatus", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/packet/s2c/play/EntityStatusS2CPacket;getEntity(Lnet/minecraft/world/World;)Lnet/minecraft/entity/Entity;"))
diff --git a/src/main/java/de/hysky/skyblocker/skyblock/end/EnderNodes.java b/src/main/java/de/hysky/skyblocker/skyblock/end/EnderNodes.java
new file mode 100644
index 00000000..b4af7256
--- /dev/null
+++ b/src/main/java/de/hysky/skyblocker/skyblock/end/EnderNodes.java
@@ -0,0 +1,138 @@
+package de.hysky.skyblocker.skyblock.end;
+
+import de.hysky.skyblocker.config.SkyblockerConfigManager;
+import de.hysky.skyblocker.utils.Utils;
+import de.hysky.skyblocker.utils.scheduler.Scheduler;
+import de.hysky.skyblocker.utils.waypoint.Waypoint;
+import it.unimi.dsi.fastutil.ints.IntIntMutablePair;
+import it.unimi.dsi.fastutil.ints.IntIntPair;
+import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents;
+import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext;
+import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents;
+import net.fabricmc.fabric.api.event.player.AttackBlockCallback;
+import net.minecraft.client.MinecraftClient;
+import net.minecraft.network.packet.s2c.play.ParticleS2CPacket;
+import net.minecraft.particle.ParticleType;
+import net.minecraft.particle.ParticleTypes;
+import net.minecraft.util.ActionResult;
+import net.minecraft.util.DyeColor;
+import net.minecraft.util.math.BlockPos;
+import net.minecraft.util.math.Direction;
+import net.minecraft.util.math.MathHelper;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class EnderNodes {
+ private static final MinecraftClient client = MinecraftClient.getInstance();
+ private static final Map<BlockPos, EnderNode> enderNodes = new HashMap<>();
+
+ public static void init() {
+ Scheduler.INSTANCE.scheduleCyclic(EnderNodes::update, 20);
+ WorldRenderEvents.AFTER_TRANSLUCENT.register(EnderNodes::render);
+ AttackBlockCallback.EVENT.register((player, world, hand, pos, direction) -> {
+ enderNodes.remove(pos);
+ return ActionResult.PASS;
+ });
+ ClientPlayConnectionEvents.JOIN.register((handler, sender, client) -> reset());
+ }
+
+ public static void onParticle(ParticleS2CPacket packet) {
+ if (!shouldProcess()) return;
+ ParticleType<?> particleType = packet.getParameters().getType();
+ if (!ParticleTypes.PORTAL.getType().equals(particleType) && !ParticleTypes.WITCH.getType().equals(particleType))
+ return;
+
+ double x = packet.getX();
+ double y = packet.getY();
+ double z = packet.getZ();
+ double xFrac = MathHelper.floorMod(x, 1);
+ double yFrac = MathHelper.floorMod(y, 1);
+ double zFrac = MathHelper.floorMod(z, 1);
+ BlockPos pos;
+ Direction direction;
+ if (yFrac == 0.25) {
+ pos = BlockPos.ofFloored(x, y - 1, z);
+ direction = Direction.UP;
+ } else if (yFrac == 0.75) {
+ pos = BlockPos.ofFloored(x, y + 1, z);
+ direction = Direction.DOWN;
+ } else if (xFrac == 0.25) {
+ pos = BlockPos.ofFloored(x - 1, y, z);
+ direction = Direction.EAST;
+ } else if (xFrac == 0.75) {
+ pos = BlockPos.ofFloored(x + 1, y, z);
+ direction = Direction.WEST;
+ } else if (zFrac == 0.25) {
+ pos = BlockPos.ofFloored(x, y, z - 1);
+ direction = Direction.SOUTH;
+ } else if (zFrac == 0.75) {
+ pos = BlockPos.ofFloored(x, y, z + 1);
+ direction = Direction.NORTH;
+ } else {
+ return;
+ }
+
+ EnderNode enderNode = enderNodes.computeIfAbsent(pos, EnderNode::new);
+ IntIntPair particles = enderNode.particles.get(direction);
+ particles.left(particles.leftInt() + 1);
+ particles.right(particles.rightInt() + 1);
+ }
+
+ private static void update() {
+ if (shouldProcess()) {
+ for (EnderNode enderNode : enderNodes.values()) {
+ enderNode.updateParticles();
+ }
+ }
+ }
+
+ private static void render(WorldRenderContext context) {
+ if (shouldProcess()) {
+ for (EnderNode enderNode : enderNodes.values()) {
+ if (enderNode.shouldRender()) {
+ enderNode.render(context);
+ }
+ }
+ }
+ }
+
+ private static boolean shouldProcess() {
+ return SkyblockerConfigManager.get().locations.end.enableEnderNodeHelper && Utils.isInTheEnd();
+ }
+
+ private static void reset() {
+ enderNodes.clear();
+ }
+
+ public static class EnderNode extends Waypoint {
+ private final Map<Direction, IntIntPair> particles = Map.of(
+ Direction.UP, new IntIntMutablePair(0, 0),
+ Direction.DOWN, new IntIntMutablePair(0, 0),
+ Direction.EAST, new IntIntMutablePair(0, 0),
+ Direction.WEST, new IntIntMutablePair(0, 0),
+ Direction.SOUTH, new IntIntMutablePair(0, 0),
+ Direction.NORTH, new IntIntMutablePair(0, 0)
+ );
+ private long lastConfirmed;
+
+ private EnderNode(BlockPos pos) {
+ super(pos, () -> SkyblockerConfigManager.get().general.waypoints.waypointType, DyeColor.CYAN.getColorComponents(), false);
+ }
+
+ private void updateParticles() {
+ long currentTimeMillis = System.currentTimeMillis();
+ if (lastConfirmed + 2000 > currentTimeMillis || client.world == null || !particles.entrySet().stream().allMatch(entry -> entry.getValue().leftInt() >= 5 && entry.getValue().rightInt() >= 5 || !client.world.getBlockState(pos.offset(entry.getKey())).isAir())) return;
+ lastConfirmed = currentTimeMillis;
+ for (Map.Entry<Direction, IntIntPair> entry : particles.entrySet()) {
+ entry.getValue().left(0);
+ entry.getValue().right(0);
+ }
+ }
+
+ @Override
+ public boolean shouldRender() {
+ return super.shouldRender() && lastConfirmed + 5000 > System.currentTimeMillis();
+ }
+ }
+}
diff --git a/src/main/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json
index aee38317..d4d6dd85 100644
--- a/src/main/resources/assets/skyblocker/lang/en_us.json
+++ b/src/main/resources/assets/skyblocker/lang/en_us.json
@@ -357,6 +357,7 @@
"text.autoconfig.skyblocker.option.locations.rift.mcGrubberStacks.@Tooltip": "Used for calculating Motes sell prices.",
"text.autoconfig.skyblocker.option.locations.end": "The End",
+ "text.autoconfig.skyblocker.option.locations.end.enableEnderNodeHelper": "Enable Ender Node Helper",
"text.autoconfig.skyblocker.option.locations.end.hudEnabled": "HUD Enabled",
"text.autoconfig.skyblocker.option.locations.end.screen": "End HUD Config...",
"text.autoconfig.skyblocker.option.locations.end.waypoint": "End Protector Waypoint",