From 27b4bdb40ecf0d2e95616b6bf431b7948bc5bdc7 Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Sun, 24 Sep 2023 00:13:12 -0400 Subject: [PATCH 01/11] Add MythologicalRitual --- .../de/hysky/skyblocker/SkyblockerMod.java | 2 + .../mixin/ClientPlayNetworkHandlerMixin.java | 9 ++- .../java/de/hysky/skyblocker/utils/Utils.java | 11 +++ .../skyblock/diana/MythologicalRitual.java | 75 +++++++++++++++++++ 4 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 src/main/java/me/xmrvizzy/skyblocker/skyblock/diana/MythologicalRitual.java diff --git a/src/main/java/de/hysky/skyblocker/SkyblockerMod.java b/src/main/java/de/hysky/skyblocker/SkyblockerMod.java index 115f90eca1..6cdb507fb3 100644 --- a/src/main/java/de/hysky/skyblocker/SkyblockerMod.java +++ b/src/main/java/de/hysky/skyblocker/SkyblockerMod.java @@ -3,6 +3,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import de.hysky.skyblocker.skyblock.*; +import de.hysky.skyblocker.skyblock.diana.MythologicalRitual; import de.hysky.skyblocker.skyblock.dungeon.*; import de.hysky.skyblocker.skyblock.dungeon.secrets.DungeonSecrets; import de.hysky.skyblocker.skyblock.item.*; @@ -76,6 +77,7 @@ public void onInitializeClient() { WikiLookup.init(); FairySouls.init(); Relics.init(); + MythologicalRitual.init(); BackpackPreview.init(); QuickNav.init(); ItemCooldowns.init(); diff --git a/src/main/java/de/hysky/skyblocker/mixin/ClientPlayNetworkHandlerMixin.java b/src/main/java/de/hysky/skyblocker/mixin/ClientPlayNetworkHandlerMixin.java index fff534b219..f8f7151280 100644 --- a/src/main/java/de/hysky/skyblocker/mixin/ClientPlayNetworkHandlerMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixin/ClientPlayNetworkHandlerMixin.java @@ -2,14 +2,16 @@ import com.llamalad7.mixinextras.injector.WrapWithCondition; import com.llamalad7.mixinextras.sugar.Local; -import de.hysky.skyblocker.skyblock.dungeon.secrets.DungeonSecrets; import dev.cbyrne.betterinject.annotations.Inject; import de.hysky.skyblocker.skyblock.FishingHelper; +import de.hysky.skyblocker.skyblock.diana.MythologicalRitual; +import de.hysky.skyblocker.skyblock.dungeon.secrets.DungeonSecrets; import de.hysky.skyblocker.utils.Utils; import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.ClientPlayNetworkHandler; import net.minecraft.entity.ItemEntity; import net.minecraft.entity.LivingEntity; +import net.minecraft.network.packet.s2c.play.ParticleS2CPacket; import net.minecraft.network.packet.s2c.play.PlaySoundS2CPacket; import org.slf4j.Logger; import org.spongepowered.asm.mixin.Mixin; @@ -45,4 +47,9 @@ public abstract class ClientPlayNetworkHandlerMixin { private boolean skyblocker$cancelTeamWarning(Logger instance, String format, Object... arg) { return !Utils.isOnHypixel(); } + + @Inject(method = "onParticle", at = @At("RETURN")) + private void skyblocker$onParticle(ParticleS2CPacket packet) { + MythologicalRitual.onParticle(packet); + } } diff --git a/src/main/java/de/hysky/skyblocker/utils/Utils.java b/src/main/java/de/hysky/skyblocker/utils/Utils.java index c1b4223fc2..bbfd11018d 100644 --- a/src/main/java/de/hysky/skyblocker/utils/Utils.java +++ b/src/main/java/de/hysky/skyblocker/utils/Utils.java @@ -19,6 +19,7 @@ import net.minecraft.scoreboard.*; import net.minecraft.text.Text; import net.minecraft.util.Formatting; +import org.jetbrains.annotations.NotNull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -40,10 +41,15 @@ public class Utils { * The following fields store data returned from /locraw: {@link #profile}, {@link #server}, {@link #gameType}, {@link #locationRaw}, and {@link #map}. */ @SuppressWarnings("JavadocDeclaration") + @NotNull private static String profile = ""; + @NotNull private static String server = ""; + @NotNull private static String gameType = ""; + @NotNull private static String locationRaw = ""; + @NotNull private static String map = ""; private static long clientWorldJoinTime = 0; private static boolean sentLocRaw = false; @@ -78,6 +84,7 @@ public static boolean isInjected() { /** * @return the profile parsed from the player list. */ + @NotNull public static String getProfile() { return profile; } @@ -85,6 +92,7 @@ public static String getProfile() { /** * @return the server parsed from /locraw. */ + @NotNull public static String getServer() { return server; } @@ -92,6 +100,7 @@ public static String getServer() { /** * @return the game type parsed from /locraw. */ + @NotNull public static String getGameType() { return gameType; } @@ -99,6 +108,7 @@ public static String getGameType() { /** * @return the location raw parsed from /locraw. */ + @NotNull public static String getLocationRaw() { return locationRaw; } @@ -106,6 +116,7 @@ public static String getLocationRaw() { /** * @return the map parsed from /locraw. */ + @NotNull public static String getMap() { return map; } diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/diana/MythologicalRitual.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/diana/MythologicalRitual.java new file mode 100644 index 0000000000..a70fa17299 --- /dev/null +++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/diana/MythologicalRitual.java @@ -0,0 +1,75 @@ +package me.xmrvizzy.skyblocker.skyblock.diana; + +import com.mojang.brigadier.Command; +import it.unimi.dsi.fastutil.booleans.BooleanBooleanMutablePair; +import me.xmrvizzy.skyblocker.SkyblockerMod; +import me.xmrvizzy.skyblocker.config.SkyblockerConfig; +import me.xmrvizzy.skyblocker.utils.Utils; +import me.xmrvizzy.skyblocker.utils.render.RenderHelper; +import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback; +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.entity.player.PlayerEntity; +import net.minecraft.network.packet.s2c.play.ParticleS2CPacket; +import net.minecraft.particle.ParticleTypes; +import net.minecraft.util.ActionResult; +import net.minecraft.util.DyeColor; +import net.minecraft.util.Hand; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Direction; +import net.minecraft.world.World; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.literal; + +public class MythologicalRitual { + private static final Map particlesMap = new HashMap<>(); + private static final Set griffinBurrows = new HashSet<>(); + + public static void init() { + WorldRenderEvents.AFTER_TRANSLUCENT.register(MythologicalRitual::render); + AttackBlockCallback.EVENT.register(MythologicalRitual::onAttackBlock); + ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> dispatcher.register( + literal(SkyblockerMod.NAMESPACE).then(literal("diana").then(literal("clearGriffinBurrows").executes(context -> { + griffinBurrows.clear(); + return Command.SINGLE_SUCCESS; + })))) + ); + } + + public static void onParticle(ParticleS2CPacket packet) { + if (isActive()&& ParticleTypes.CRIT.equals(packet.getParameters().getType()) || ParticleTypes.ENCHANT.equals(packet.getParameters().getType())) { + BlockPos pos = BlockPos.ofFloored(packet.getX(), packet.getY(), packet.getZ()); + BooleanBooleanMutablePair particlesAtPos = particlesMap.computeIfAbsent(pos, pos1 -> BooleanBooleanMutablePair.of(false, false)); + particlesAtPos.left(particlesAtPos.leftBoolean() || ParticleTypes.CRIT.equals(packet.getParameters().getType())); + particlesAtPos.right(particlesAtPos.rightBoolean() || ParticleTypes.ENCHANT.equals(packet.getParameters().getType())); + if (particlesAtPos.leftBoolean() && particlesAtPos.rightBoolean()) { + griffinBurrows.add(pos); + } + } + } + + public static void render(WorldRenderContext context) { + if (isActive()) { + for (BlockPos griffinBorrow : griffinBurrows) { + RenderHelper.renderFilledThroughWallsWithBeaconBeam(context, griffinBorrow, DyeColor.GREEN.getColorComponents(), 0.5F); + } + } + } + + public static ActionResult onAttackBlock(PlayerEntity player, World world, Hand hand, BlockPos pos, Direction direction) { + if (isActive()) { + griffinBurrows.remove(pos); + } + return ActionResult.PASS; + } + + private static boolean isActive() { + return SkyblockerConfig.get().general.fairySouls.enableFairySoulsHelper && Utils.getLocationRaw().equals("hub") ; // TODO Change to actual config option + } +} From 3d59588b658c0c9e4cb90960b7390b27077ea516 Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Sun, 24 Sep 2023 21:57:35 -0400 Subject: [PATCH 02/11] Fix warnings --- src/main/java/de/hysky/skyblocker/SkyblockerMod.java | 2 +- .../hysky/skyblocker/mixin/ClientPlayNetworkHandlerMixin.java | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/SkyblockerMod.java b/src/main/java/de/hysky/skyblocker/SkyblockerMod.java index 6cdb507fb3..e18a8c83cd 100644 --- a/src/main/java/de/hysky/skyblocker/SkyblockerMod.java +++ b/src/main/java/de/hysky/skyblocker/SkyblockerMod.java @@ -40,7 +40,7 @@ * this class. */ public class SkyblockerMod implements ClientModInitializer { - public static final String VERSION = FabricLoader.getInstance().getModContainer("skyblocker").get().getMetadata().getVersion().getFriendlyString(); + public static final String VERSION = FabricLoader.getInstance().getModContainer("skyblocker").orElseThrow().getMetadata().getVersion().getFriendlyString(); public static final String NAMESPACE = "skyblocker"; public static final Path CONFIG_DIR = FabricLoader.getInstance().getConfigDir().resolve(NAMESPACE); public static final Gson GSON = new GsonBuilder().setPrettyPrinting().create(); diff --git a/src/main/java/de/hysky/skyblocker/mixin/ClientPlayNetworkHandlerMixin.java b/src/main/java/de/hysky/skyblocker/mixin/ClientPlayNetworkHandlerMixin.java index f8f7151280..7615a8e1a6 100644 --- a/src/main/java/de/hysky/skyblocker/mixin/ClientPlayNetworkHandlerMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixin/ClientPlayNetworkHandlerMixin.java @@ -26,7 +26,6 @@ public abstract class ClientPlayNetworkHandlerMixin { FishingHelper.onSound(packet); } - @SuppressWarnings("resource") @ModifyVariable(method = "onItemPickupAnimation", at = @At(value = "STORE", ordinal = 0)) private ItemEntity skyblocker$onItemPickup(ItemEntity itemEntity, @Local LivingEntity collector) { DungeonSecrets.onItemPickup(itemEntity, collector, collector == MinecraftClient.getInstance().player); From 0314c406d18d49ac00998c4a33bfdeea4e10280f Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Wed, 27 Sep 2023 00:58:08 -0400 Subject: [PATCH 03/11] Update burrow finish detection --- .../skyblock/diana/MythologicalRitual.java | 71 ++++++++++++++----- 1 file changed, 55 insertions(+), 16 deletions(-) diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/diana/MythologicalRitual.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/diana/MythologicalRitual.java index a70fa17299..c74d5e779f 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/diana/MythologicalRitual.java +++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/diana/MythologicalRitual.java @@ -2,74 +2,113 @@ import com.mojang.brigadier.Command; import it.unimi.dsi.fastutil.booleans.BooleanBooleanMutablePair; +import it.unimi.dsi.fastutil.objects.Object2LongMap; +import it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap; import me.xmrvizzy.skyblocker.SkyblockerMod; import me.xmrvizzy.skyblocker.config.SkyblockerConfig; import me.xmrvizzy.skyblocker.utils.Utils; import me.xmrvizzy.skyblocker.utils.render.RenderHelper; import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback; +import net.fabricmc.fabric.api.client.message.v1.ClientReceiveMessageEvents; 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.fabricmc.fabric.api.event.player.UseBlockCallback; +import net.minecraft.block.Blocks; +import net.minecraft.client.MinecraftClient; +import net.minecraft.command.argument.BlockPosArgumentType; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.network.packet.s2c.play.ParticleS2CPacket; import net.minecraft.particle.ParticleTypes; +import net.minecraft.text.Text; import net.minecraft.util.ActionResult; import net.minecraft.util.DyeColor; import net.minecraft.util.Hand; +import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; import net.minecraft.world.World; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.util.HashMap; -import java.util.HashSet; import java.util.Map; -import java.util.Set; +import java.util.regex.Pattern; +import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.argument; import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.literal; public class MythologicalRitual { + private static final Pattern GRIFFIN_BURROW_DUG = Pattern.compile("(?You dug out a Griffin Burrow!|You finished the Griffin burrow chain!) \\((?\\d)/4\\)"); private static final Map particlesMap = new HashMap<>(); - private static final Set griffinBurrows = new HashSet<>(); + private static final Object2LongMap griffinBurrows = new Object2LongOpenHashMap<>(); + @Nullable + private static BlockPos lastDugBurrowPos; public static void init() { WorldRenderEvents.AFTER_TRANSLUCENT.register(MythologicalRitual::render); AttackBlockCallback.EVENT.register(MythologicalRitual::onAttackBlock); - ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> dispatcher.register( - literal(SkyblockerMod.NAMESPACE).then(literal("diana").then(literal("clearGriffinBurrows").executes(context -> { + UseBlockCallback.EVENT.register(MythologicalRitual::onUseBlock); + ClientReceiveMessageEvents.GAME.register(MythologicalRitual::onChatMessage); + ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> dispatcher.register(literal(SkyblockerMod.NAMESPACE).then(literal("diana") + .then(literal("clearGriffinBurrows").executes(context -> { griffinBurrows.clear(); return Command.SINGLE_SUCCESS; - })))) - ); + })) + .then(literal("clearGriffinBurrow").then(argument("pos", BlockPosArgumentType.blockPos()).executes(context -> { + griffinBurrows.removeLong(context.getArgument("pos", BlockPos.class)); + return Command.SINGLE_SUCCESS; + })))))); } public static void onParticle(ParticleS2CPacket packet) { - if (isActive()&& ParticleTypes.CRIT.equals(packet.getParameters().getType()) || ParticleTypes.ENCHANT.equals(packet.getParameters().getType())) { - BlockPos pos = BlockPos.ofFloored(packet.getX(), packet.getY(), packet.getZ()); + if (isActive() && ParticleTypes.CRIT.equals(packet.getParameters().getType()) || ParticleTypes.ENCHANT.equals(packet.getParameters().getType())) { + BlockPos pos = BlockPos.ofFloored(packet.getX(), packet.getY(), packet.getZ()).down(); + if (MinecraftClient.getInstance().world == null || !MinecraftClient.getInstance().world.getBlockState(pos).isOf(Blocks.GRASS_BLOCK)) { + return; + } BooleanBooleanMutablePair particlesAtPos = particlesMap.computeIfAbsent(pos, pos1 -> BooleanBooleanMutablePair.of(false, false)); particlesAtPos.left(particlesAtPos.leftBoolean() || ParticleTypes.CRIT.equals(packet.getParameters().getType())); particlesAtPos.right(particlesAtPos.rightBoolean() || ParticleTypes.ENCHANT.equals(packet.getParameters().getType())); - if (particlesAtPos.leftBoolean() && particlesAtPos.rightBoolean()) { - griffinBurrows.add(pos); + if (particlesAtPos.leftBoolean() && particlesAtPos.rightBoolean() && griffinBurrows.getLong(pos) + 1000 < System.currentTimeMillis()) { + griffinBurrows.put(pos, 0); } } } public static void render(WorldRenderContext context) { if (isActive()) { - for (BlockPos griffinBorrow : griffinBurrows) { - RenderHelper.renderFilledThroughWallsWithBeaconBeam(context, griffinBorrow, DyeColor.GREEN.getColorComponents(), 0.5F); + for (Object2LongMap.Entry griffinBorrow : griffinBurrows.object2LongEntrySet()) { + if (griffinBorrow.getLongValue() <= 0) { + RenderHelper.renderFilledThroughWallsWithBeaconBeam(context, griffinBorrow.getKey(), DyeColor.GREEN.getColorComponents(), 0.5F); + } } } } public static ActionResult onAttackBlock(PlayerEntity player, World world, Hand hand, BlockPos pos, Direction direction) { - if (isActive()) { - griffinBurrows.remove(pos); + return onInteractBlock(pos); + } + + public static ActionResult onUseBlock(PlayerEntity player, World world, Hand hand, BlockHitResult hitResult) { + return onInteractBlock(hitResult.getBlockPos()); + } + + @NotNull + private static ActionResult onInteractBlock(BlockPos pos) { + if (isActive() && griffinBurrows.containsKey(pos)) { + lastDugBurrowPos = pos; } return ActionResult.PASS; } + public static void onChatMessage(Text message, boolean overlay) { + if (isActive() && GRIFFIN_BURROW_DUG.matcher(message.getString()).matches()) { + griffinBurrows.put(lastDugBurrowPos, System.currentTimeMillis()); + } + } + private static boolean isActive() { - return SkyblockerConfig.get().general.fairySouls.enableFairySoulsHelper && Utils.getLocationRaw().equals("hub") ; // TODO Change to actual config option + return SkyblockerConfig.get().general.fairySouls.enableFairySoulsHelper && Utils.getLocationRaw().equals("hub"); // TODO Change to actual config option } } From 58e43eee5c02efbe6144bfd6e4b1a95101d24576 Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Thu, 28 Sep 2023 15:40:22 -0400 Subject: [PATCH 04/11] Add next burrow direction detection --- build.gradle | 9 +- gradle.properties | 9 +- .../skyblock/diana/MythologicalRitual.java | 89 ++++++++++++++----- 3 files changed, 80 insertions(+), 27 deletions(-) diff --git a/build.gradle b/build.gradle index 66c56e2119..fde768d504 100644 --- a/build.gradle +++ b/build.gradle @@ -72,14 +72,17 @@ dependencies { // BetterInject (https://github.com/caoimhebyrne/BetterInject) include implementation(annotationProcessor("com.github.cbyrneee:BetterInject:${project.betterinject_version}")) - // https://mvnrepository.com/artifact/org.eclipse.jgit/org.eclipse.jgit used pull data from the NEU item repo - include implementation("org.eclipse.jgit:org.eclipse.jgit:6.4.0.202211300538-r") - // Occlusion Culling (https://github.com/LogisticsCraft/OcclusionCulling) include implementation("com.logisticscraft:occlusionculling:${project.occlusionculling_version}") // NEU RepoParser include implementation("moe.nea:neurepoparser:${project.repoparser_version}") + + // JGit used pull data from the NEU item repo + include implementation("org.eclipse.jgit:org.eclipse.jgit:${project.jgit_version}") + + // Apache Commons Math + include implementation("org.apache.commons:commons-math3:${project.commons_math_version}") } loom { diff --git a/gradle.properties b/gradle.properties index c5794079fd..4252926133 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,7 +11,7 @@ loader_version=0.14.22 ## 1.20 fabric_api_version=0.89.1+1.20.2 -# Dependencies +# Minecraft Mods ## YACL (https://github.com/isXander/YetAnotherConfigLib) yacl_version=3.2.1+1.20.2 ## Mod Menu (https://modrinth.com/mod/modmenu/versions) @@ -23,6 +23,7 @@ emi_version = 1.0.22+1.20.2 ## Renderer (https://github.com/0x3C50/Renderer) renderer_version = master-SNAPSHOT +# Minecraft and Related Libraries ## Mixin Extras (https://github.com/LlamaLad7/MixinExtras) mixin_extras_version = 0.2.0 ## Better Inject (https://github.com/caoimhebyrne/BetterInject) @@ -32,6 +33,12 @@ occlusionculling_version = 0.0.7-SNAPSHOT ## neu repoparser (https://repo.nea.moe/#/releases/moe/nea/neurepoparser/) repoparser_version = 1.4.0 +# Other Libraries +## JGit (https://mvnrepository.com/artifact/org.eclipse.jgit/org.eclipse.jgit) +jgit_version = 6.7.0.202309050840-r +## Apache Commons Math (https://mvnrepository.com/artifact/org.apache.commons/commons-math3) +commons_math_version = 3.6.1 + # Mod Properties mod_version = 1.15.0 maven_group = de.hysky diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/diana/MythologicalRitual.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/diana/MythologicalRitual.java index c74d5e779f..ba27845a99 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/diana/MythologicalRitual.java +++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/diana/MythologicalRitual.java @@ -1,9 +1,6 @@ package me.xmrvizzy.skyblocker.skyblock.diana; import com.mojang.brigadier.Command; -import it.unimi.dsi.fastutil.booleans.BooleanBooleanMutablePair; -import it.unimi.dsi.fastutil.objects.Object2LongMap; -import it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap; import me.xmrvizzy.skyblocker.SkyblockerMod; import me.xmrvizzy.skyblocker.config.SkyblockerConfig; import me.xmrvizzy.skyblocker.utils.Utils; @@ -14,6 +11,7 @@ import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents; import net.fabricmc.fabric.api.event.player.AttackBlockCallback; import net.fabricmc.fabric.api.event.player.UseBlockCallback; +import net.fabricmc.fabric.api.util.TriState; import net.minecraft.block.Blocks; import net.minecraft.client.MinecraftClient; import net.minecraft.command.argument.BlockPosArgumentType; @@ -27,7 +25,9 @@ import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; +import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; +import org.apache.commons.math3.stat.regression.SimpleRegression; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -40,10 +40,11 @@ public class MythologicalRitual { private static final Pattern GRIFFIN_BURROW_DUG = Pattern.compile("(?You dug out a Griffin Burrow!|You finished the Griffin burrow chain!) \\((?\\d)/4\\)"); - private static final Map particlesMap = new HashMap<>(); - private static final Object2LongMap griffinBurrows = new Object2LongOpenHashMap<>(); + private static final float[] WHITE_COLOR_COMPONENTS = {1.0f, 1.0f, 1.0f}; + private static final Map griffinBurrows = new HashMap<>(); @Nullable private static BlockPos lastDugBurrowPos; + private static GriffinBurrow previousBurrow; public static void init() { WorldRenderEvents.AFTER_TRANSLUCENT.register(MythologicalRitual::render); @@ -55,32 +56,57 @@ public static void init() { griffinBurrows.clear(); return Command.SINGLE_SUCCESS; })) - .then(literal("clearGriffinBurrow").then(argument("pos", BlockPosArgumentType.blockPos()).executes(context -> { - griffinBurrows.removeLong(context.getArgument("pos", BlockPos.class)); - return Command.SINGLE_SUCCESS; - })))))); + .then(literal("clearGriffinBurrow") + .then(argument("pos", BlockPosArgumentType.blockPos()).executes(context -> { + griffinBurrows.remove(context.getArgument("pos", BlockPos.class)); + return Command.SINGLE_SUCCESS; + })) + ) + ))); } public static void onParticle(ParticleS2CPacket packet) { - if (isActive() && ParticleTypes.CRIT.equals(packet.getParameters().getType()) || ParticleTypes.ENCHANT.equals(packet.getParameters().getType())) { - BlockPos pos = BlockPos.ofFloored(packet.getX(), packet.getY(), packet.getZ()).down(); - if (MinecraftClient.getInstance().world == null || !MinecraftClient.getInstance().world.getBlockState(pos).isOf(Blocks.GRASS_BLOCK)) { - return; - } - BooleanBooleanMutablePair particlesAtPos = particlesMap.computeIfAbsent(pos, pos1 -> BooleanBooleanMutablePair.of(false, false)); - particlesAtPos.left(particlesAtPos.leftBoolean() || ParticleTypes.CRIT.equals(packet.getParameters().getType())); - particlesAtPos.right(particlesAtPos.rightBoolean() || ParticleTypes.ENCHANT.equals(packet.getParameters().getType())); - if (particlesAtPos.leftBoolean() && particlesAtPos.rightBoolean() && griffinBurrows.getLong(pos) + 1000 < System.currentTimeMillis()) { - griffinBurrows.put(pos, 0); + if (isActive()) { + if (ParticleTypes.CRIT.equals(packet.getParameters().getType()) || ParticleTypes.ENCHANT.equals(packet.getParameters().getType())) { + BlockPos pos = BlockPos.ofFloored(packet.getX(), packet.getY(), packet.getZ()).down(); + if (MinecraftClient.getInstance().world == null || !MinecraftClient.getInstance().world.getBlockState(pos).isOf(Blocks.GRASS_BLOCK)) { + return; + } + GriffinBurrow burrow = griffinBurrows.computeIfAbsent(pos, pos1 -> new GriffinBurrow()); + if (ParticleTypes.CRIT.equals(packet.getParameters().getType())) burrow.critParticle++; + if (ParticleTypes.ENCHANT.equals(packet.getParameters().getType())) burrow.enchantParticle++; + if (burrow.critParticle >= 5 && burrow.enchantParticle >= 5 && burrow.confirmed == TriState.FALSE) { + griffinBurrows.get(pos).init(); + } + } else if (ParticleTypes.DUST.equals(packet.getParameters().getType())) { + BlockPos pos = BlockPos.ofFloored(packet.getX(), packet.getY(), packet.getZ()).down(2); + GriffinBurrow burrow = griffinBurrows.get(pos); + if (burrow == null) { + return; + } + burrow.regression.addData(packet.getX(), packet.getZ()); + double slope = burrow.regression.getSlope(); + if (Double.isNaN(slope)) { + return; + } + Vec3d nextBurrowDirection = new Vec3d(100, 2, slope * 100).normalize().multiply(500); + burrow.nextBurrowPlane = new Vec3d[]{ + Vec3d.of(pos).add(nextBurrowDirection), + Vec3d.of(pos).subtract(nextBurrowDirection) + }; } } } public static void render(WorldRenderContext context) { if (isActive()) { - for (Object2LongMap.Entry griffinBorrow : griffinBurrows.object2LongEntrySet()) { - if (griffinBorrow.getLongValue() <= 0) { - RenderHelper.renderFilledThroughWallsWithBeaconBeam(context, griffinBorrow.getKey(), DyeColor.GREEN.getColorComponents(), 0.5F); + for (Map.Entry burrowEntry : griffinBurrows.entrySet()) { + GriffinBurrow burrow = burrowEntry.getValue(); + if (burrow.confirmed == TriState.TRUE) { + RenderHelper.renderFilledThroughWallsWithBeaconBeam(context, burrowEntry.getKey(), DyeColor.GREEN.getColorComponents(), 0.5F); + } + if (burrow.confirmed != TriState.FALSE && burrow.nextBurrowPlane != null) { // TODO try before debug render? + RenderHelper.renderLinesFromPoints(context, burrow.nextBurrowPlane, WHITE_COLOR_COMPONENTS, 1, 5); } } } @@ -104,11 +130,28 @@ private static ActionResult onInteractBlock(BlockPos pos) { public static void onChatMessage(Text message, boolean overlay) { if (isActive() && GRIFFIN_BURROW_DUG.matcher(message.getString()).matches()) { - griffinBurrows.put(lastDugBurrowPos, System.currentTimeMillis()); + if (previousBurrow != null) { + previousBurrow.confirmed = TriState.FALSE; + } + previousBurrow = griffinBurrows.get(lastDugBurrowPos); + previousBurrow.confirmed = TriState.DEFAULT; } } private static boolean isActive() { return SkyblockerConfig.get().general.fairySouls.enableFairySoulsHelper && Utils.getLocationRaw().equals("hub"); // TODO Change to actual config option } + + private static class GriffinBurrow { + private int critParticle; + private int enchantParticle; + private TriState confirmed = TriState.FALSE; + private final SimpleRegression regression = new SimpleRegression(); + private Vec3d[] nextBurrowPlane; + + private void init() { + confirmed = TriState.TRUE; + regression.clear(); + } + } } From 5ff7319a944232c643a3641c759902256e12584d Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Sat, 30 Sep 2023 13:15:55 -0400 Subject: [PATCH 05/11] Add echo detection --- .../skyblocker/utils/render/RenderHelper.java | 58 +++++++++++++------ .../skyblock/diana/MythologicalRitual.java | 58 ++++++++++++++----- 2 files changed, 86 insertions(+), 30 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/utils/render/RenderHelper.java b/src/main/java/de/hysky/skyblocker/utils/render/RenderHelper.java index 5ab698a77c..14e6d10348 100644 --- a/src/main/java/de/hysky/skyblocker/utils/render/RenderHelper.java +++ b/src/main/java/de/hysky/skyblocker/utils/render/RenderHelper.java @@ -22,7 +22,6 @@ import net.minecraft.util.math.Vec3d; import org.joml.Matrix3f; import org.joml.Matrix4f; -import org.joml.Vector3f; import org.lwjgl.opengl.GL11; import java.awt.*; @@ -111,6 +110,8 @@ public static void renderOutline(WorldRenderContext context, Box box, float[] co * Draws lines from point to point.

*

* Tip: To draw lines from the center of a block, offset the X, Y and Z each by 0.5 + *

+ * Note: This is super messed up when drawing long lines. Tried different normals and {@link DrawMode#LINES} but nothing worked. * * @param context The WorldRenderContext which supplies the matrices and tick delta * @param points The points from which to draw lines between @@ -127,7 +128,7 @@ public static void renderLinesFromPoints(WorldRenderContext context, Vec3d[] poi Tessellator tessellator = RenderSystem.renderThreadTesselator(); BufferBuilder buffer = tessellator.getBuffer(); - Matrix4f projectionMatrix = matrices.peek().getPositionMatrix(); + Matrix4f positionMatrix = matrices.peek().getPositionMatrix(); Matrix3f normalMatrix = matrices.peek().getNormalMatrix(); GL11.glEnable(GL11.GL_LINE_SMOOTH); @@ -144,14 +145,11 @@ public static void renderLinesFromPoints(WorldRenderContext context, Vec3d[] poi buffer.begin(DrawMode.LINE_STRIP, VertexFormats.LINES); for (int i = 0; i < points.length; i++) { - Vec3d point = points[i]; - Vec3d nextPoint = (i + 1 == points.length) ? points[i - 1] : points[i + 1]; - Vector3f normalVec = new Vector3f((float) nextPoint.getX(), (float) nextPoint.getY(), (float) nextPoint.getZ()).sub((float) point.getX(), (float) point.getY(), (float) point.getZ()).normalize(); - + Vec3d normalVec = points[(i + 1) % points.length].subtract(points[i]).normalize(); buffer - .vertex(projectionMatrix, (float) point.getX(), (float) point.getY(), (float) point.getZ()) + .vertex(positionMatrix, (float) points[i].getX(), (float) points[i].getY(), (float) points[i].getZ()) .color(colorComponents[0], colorComponents[1], colorComponents[2], alpha) - .normal(normalMatrix, normalVec.x, normalVec.y, normalVec.z) + .normal(normalMatrix, (float) normalVec.x, (float) normalVec.y, (float) normalVec.z) .next(); } @@ -166,24 +164,50 @@ public static void renderLinesFromPoints(WorldRenderContext context, Vec3d[] poi RenderSystem.disableDepthTest(); } - public static void renderText(WorldRenderContext context, Text text, Vec3d pos, boolean seeThrough) { - renderText(context, text, pos, 1, seeThrough); + public static void renderQuad(WorldRenderContext context, Vec3d[] points, float[] colorComponents, float alpha, boolean throughWalls) { + Vec3d camera = context.camera().getPos(); + MatrixStack matrices = context.matrixStack(); + + matrices.push(); + matrices.translate(-camera.x, -camera.y, -camera.z); + + Tessellator tessellator = RenderSystem.renderThreadTesselator(); + BufferBuilder buffer = tessellator.getBuffer(); + Matrix4f positionMatrix = matrices.peek().getPositionMatrix(); + + RenderSystem.setShader(GameRenderer::getPositionColorProgram); + RenderSystem.setShaderColor(1f, 1f, 1f, 1f); + RenderSystem.depthFunc(throughWalls ? GL11.GL_ALWAYS : GL11.GL_LEQUAL); + + buffer.begin(DrawMode.QUADS, VertexFormats.POSITION_COLOR); + for (int i = 0; i < 4; i++) { + buffer.vertex(positionMatrix, (float) points[i].getX(), (float) points[i].getY(), (float) points[i].getZ()).color(colorComponents[0], colorComponents[1], colorComponents[2], alpha).next(); + } + tessellator.draw(); + + RenderSystem.depthFunc(GL11.GL_LEQUAL); + + matrices.pop(); + } + + public static void renderText(WorldRenderContext context, Text text, Vec3d pos, boolean throughWalls) { + renderText(context, text, pos, 1, throughWalls); } - public static void renderText(WorldRenderContext context, Text text, Vec3d pos, float scale, boolean seeThrough) { - renderText(context, text, pos, scale, 0, seeThrough); + public static void renderText(WorldRenderContext context, Text text, Vec3d pos, float scale, boolean throughWalls) { + renderText(context, text, pos, scale, 0, throughWalls); } - public static void renderText(WorldRenderContext context, Text text, Vec3d pos, float scale, float yOffset, boolean seeThrough) { - renderText(context, text.asOrderedText(), pos, scale, yOffset, seeThrough); + public static void renderText(WorldRenderContext context, Text text, Vec3d pos, float scale, float yOffset, boolean throughWalls) { + renderText(context, text.asOrderedText(), pos, scale, yOffset, throughWalls); } /** * Renders text in the world space. * - * @param seeThrough Whether the text should be able to be seen through walls or not. + * @param throughWalls whether the text should be able to be seen through walls or not. */ - public static void renderText(WorldRenderContext context, OrderedText text, Vec3d pos, float scale, float yOffset, boolean seeThrough) { + public static void renderText(WorldRenderContext context, OrderedText text, Vec3d pos, float scale, float yOffset, boolean throughWalls) { MatrixStack matrices = context.matrixStack(); Vec3d camera = context.camera().getPos(); TextRenderer textRenderer = client.textRenderer; @@ -203,7 +227,7 @@ public static void renderText(WorldRenderContext context, OrderedText text, Vec3 BufferBuilder buffer = tessellator.getBuffer(); VertexConsumerProvider.Immediate consumers = VertexConsumerProvider.immediate(buffer); - RenderSystem.depthFunc(seeThrough ? GL11.GL_ALWAYS : GL11.GL_LEQUAL); + RenderSystem.depthFunc(throughWalls ? GL11.GL_ALWAYS : GL11.GL_LEQUAL); textRenderer.draw(text, xOffset, yOffset, 0xFFFFFFFF, false, positionMatrix, consumers, TextRenderer.TextLayerType.SEE_THROUGH, 0, LightmapTextureManager.MAX_LIGHT_COORDINATE); consumers.draw(); diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/diana/MythologicalRitual.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/diana/MythologicalRitual.java index ba27845a99..62462f56fb 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/diana/MythologicalRitual.java +++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/diana/MythologicalRitual.java @@ -40,11 +40,11 @@ public class MythologicalRitual { private static final Pattern GRIFFIN_BURROW_DUG = Pattern.compile("(?You dug out a Griffin Burrow!|You finished the Griffin burrow chain!) \\((?\\d)/4\\)"); - private static final float[] WHITE_COLOR_COMPONENTS = {1.0f, 1.0f, 1.0f}; + private static final float[] ORANGE_COLOR_COMPONENTS = DyeColor.ORANGE.getColorComponents(); private static final Map griffinBurrows = new HashMap<>(); @Nullable private static BlockPos lastDugBurrowPos; - private static GriffinBurrow previousBurrow; + private static GriffinBurrow previousBurrow = new GriffinBurrow(); public static void init() { WorldRenderEvents.AFTER_TRANSLUCENT.register(MythologicalRitual::render); @@ -63,6 +63,10 @@ public static void init() { })) ) ))); + + // Put a root burrow so echo detection works without a previous burrow + previousBurrow.confirmed = TriState.DEFAULT; + griffinBurrows.put(BlockPos.ORIGIN, previousBurrow); } public static void onParticle(ParticleS2CPacket packet) { @@ -89,24 +93,51 @@ public static void onParticle(ParticleS2CPacket packet) { if (Double.isNaN(slope)) { return; } - Vec3d nextBurrowDirection = new Vec3d(100, 2, slope * 100).normalize().multiply(500); - burrow.nextBurrowPlane = new Vec3d[]{ - Vec3d.of(pos).add(nextBurrowDirection), - Vec3d.of(pos).subtract(nextBurrowDirection) - }; + Vec3d nextBurrowDirection = new Vec3d(100, 0, slope * 100).normalize().multiply(100); + if (burrow.nextBurrowPlane == null) { + burrow.nextBurrowPlane = new Vec3d[4]; + } + burrow.nextBurrowPlane[0] = Vec3d.of(pos).add(nextBurrowDirection).subtract(0, 50, 0); + burrow.nextBurrowPlane[1] = Vec3d.of(pos).subtract(nextBurrowDirection).subtract(0, 50, 0); + burrow.nextBurrowPlane[2] = burrow.nextBurrowPlane[1].add(0, 100, 0); + burrow.nextBurrowPlane[3] = burrow.nextBurrowPlane[0].add(0, 100, 0); + } else if (ParticleTypes.DRIPPING_LAVA.equals(packet.getParameters().getType())) { + if (previousBurrow.echoBurrowDirection == null) { + previousBurrow.echoBurrowDirection = new Vec3d[2]; + } + previousBurrow.echoBurrowDirection[0] = previousBurrow.echoBurrowDirection[1]; + previousBurrow.echoBurrowDirection[1] = new Vec3d(packet.getX(), packet.getY(), packet.getZ()); + if (previousBurrow.echoBurrowDirection[0] == null || previousBurrow.echoBurrowDirection[1] == null) { + return; + } + Vec3d echoBurrowDirection = previousBurrow.echoBurrowDirection[1].subtract(previousBurrow.echoBurrowDirection[0]).normalize().multiply(100); + if (previousBurrow.echoBurrowPlane == null) { + previousBurrow.echoBurrowPlane = new Vec3d[4]; + } + previousBurrow.echoBurrowPlane[0] = previousBurrow.echoBurrowDirection[0].add(echoBurrowDirection).subtract(0, 50, 0); + previousBurrow.echoBurrowPlane[1] = previousBurrow.echoBurrowDirection[0].subtract(echoBurrowDirection).subtract(0, 50, 0); + previousBurrow.echoBurrowPlane[2] = previousBurrow.echoBurrowPlane[0].add(0, 100, 0); + previousBurrow.echoBurrowPlane[3] = previousBurrow.echoBurrowPlane[1].add(0, 100, 0); } } } public static void render(WorldRenderContext context) { + RenderHelper.renderLinesFromPoints(context, new Vec3d[]{new Vec3d(0, 96, -100), new Vec3d(0, 96, 100)}, ORANGE_COLOR_COMPONENTS, 0.25F, 5); // TODO debug + RenderHelper.renderQuad(context, new Vec3d[]{new Vec3d(0, 100, -100), new Vec3d(0, 100, 100), new Vec3d(0, 200, 100), new Vec3d(0, 200, -100)}, ORANGE_COLOR_COMPONENTS, 0.25F, true); // TODO debug if (isActive()) { for (Map.Entry burrowEntry : griffinBurrows.entrySet()) { GriffinBurrow burrow = burrowEntry.getValue(); if (burrow.confirmed == TriState.TRUE) { - RenderHelper.renderFilledThroughWallsWithBeaconBeam(context, burrowEntry.getKey(), DyeColor.GREEN.getColorComponents(), 0.5F); + RenderHelper.renderFilledThroughWallsWithBeaconBeam(context, burrowEntry.getKey(), ORANGE_COLOR_COMPONENTS, 0.25F); } - if (burrow.confirmed != TriState.FALSE && burrow.nextBurrowPlane != null) { // TODO try before debug render? - RenderHelper.renderLinesFromPoints(context, burrow.nextBurrowPlane, WHITE_COLOR_COMPONENTS, 1, 5); + if (burrow.confirmed != TriState.FALSE) { + if (burrow.nextBurrowPlane != null) { + RenderHelper.renderLinesFromPoints(context, burrow.nextBurrowPlane, ORANGE_COLOR_COMPONENTS, 0.25F, 5); + } + if (burrow.echoBurrowPlane != null) { + RenderHelper.renderLinesFromPoints(context, burrow.echoBurrowPlane, ORANGE_COLOR_COMPONENTS, 0.25F, 5); + } } } } @@ -130,9 +161,7 @@ private static ActionResult onInteractBlock(BlockPos pos) { public static void onChatMessage(Text message, boolean overlay) { if (isActive() && GRIFFIN_BURROW_DUG.matcher(message.getString()).matches()) { - if (previousBurrow != null) { - previousBurrow.confirmed = TriState.FALSE; - } + previousBurrow.confirmed = TriState.FALSE; previousBurrow = griffinBurrows.get(lastDugBurrowPos); previousBurrow.confirmed = TriState.DEFAULT; } @@ -148,6 +177,9 @@ private static class GriffinBurrow { private TriState confirmed = TriState.FALSE; private final SimpleRegression regression = new SimpleRegression(); private Vec3d[] nextBurrowPlane; + @Nullable + private Vec3d[] echoBurrowDirection; + private Vec3d[] echoBurrowPlane; private void init() { confirmed = TriState.TRUE; From 594f1d34b51cc49cea90003262f77e0974e5b62d Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Sun, 1 Oct 2023 00:17:04 -0400 Subject: [PATCH 06/11] Add config option --- .../hysky/skyblocker/config/SkyblockerConfig.java | 9 ++++++++- .../config/categories/GeneralCategory.java | 13 +++++++++++++ .../skyblock/diana/MythologicalRitual.java | 4 ++-- .../resources/assets/skyblocker/lang/en_us.json | 2 ++ 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java b/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java index d7279bc8af..5f8f47d024 100644 --- a/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java +++ b/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java @@ -176,6 +176,9 @@ public static class General { @SerialEntry public FairySouls fairySouls = new FairySouls(); + @SerialEntry + public MythologicalRitual mythologicalRitual = new MythologicalRitual(); + @SerialEntry public ItemCooldown itemCooldown = new ItemCooldown(); @@ -322,6 +325,11 @@ public static class FairySouls { public boolean highlightOnlyNearbySouls = false; } + public static class MythologicalRitual { + @SerialEntry + public boolean enableMythologicalRitualHelper = true; + } + public static class ItemCooldown { @SerialEntry public boolean enableItemCooldowns = true; @@ -653,7 +661,6 @@ public static class DungeonChestProfit { @SerialEntry public Formatting incompleteColor = Formatting.BLUE; - } public static class LividColor { diff --git a/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java b/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java index 30bdbd3fca..60deedd299 100644 --- a/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java +++ b/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java @@ -200,6 +200,19 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .build()) .build()) + //Mythological Ritual + .group(OptionGroup.createBuilder() + .name(Text.translatable("text.autoconfig.skyblocker.option.general.mythologicalRitual")) + .collapsed(true) + .option(Option.createBuilder() + .name(Text.translatable("text.autoconfig.skyblocker.option.general.mythologicalRitual.enableMythologicalRitualHelper")) + .binding(defaults.general.mythologicalRitual.enableMythologicalRitualHelper, + () -> config.general.mythologicalRitual.enableMythologicalRitualHelper, + newValue -> config.general.mythologicalRitual.enableMythologicalRitualHelper = newValue) + .controller(BooleanControllerBuilder::create) + .build()) + .build()) + //Item Cooldown .group(OptionGroup.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.general.itemCooldown")) diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/diana/MythologicalRitual.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/diana/MythologicalRitual.java index 62462f56fb..7260703708 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/diana/MythologicalRitual.java +++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/diana/MythologicalRitual.java @@ -2,7 +2,7 @@ import com.mojang.brigadier.Command; import me.xmrvizzy.skyblocker.SkyblockerMod; -import me.xmrvizzy.skyblocker.config.SkyblockerConfig; +import me.xmrvizzy.skyblocker.config.SkyblockerConfigManager; import me.xmrvizzy.skyblocker.utils.Utils; import me.xmrvizzy.skyblocker.utils.render.RenderHelper; import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback; @@ -168,7 +168,7 @@ public static void onChatMessage(Text message, boolean overlay) { } private static boolean isActive() { - return SkyblockerConfig.get().general.fairySouls.enableFairySoulsHelper && Utils.getLocationRaw().equals("hub"); // TODO Change to actual config option + return SkyblockerConfigManager.get().general.mythologicalRitual.enableMythologicalRitualHelper && Utils.getLocationRaw().equals("hub"); } private static class GriffinBurrow { diff --git a/src/main/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json index f02eb31927..aaa21814af 100644 --- a/src/main/resources/assets/skyblocker/lang/en_us.json +++ b/src/main/resources/assets/skyblocker/lang/en_us.json @@ -38,6 +38,8 @@ "text.autoconfig.skyblocker.option.general.fairySouls.highlightFoundSouls": "Highlight found fairy souls", "text.autoconfig.skyblocker.option.general.fairySouls.highlightOnlyNearbySouls": "Only highlight nearby fairy souls", "text.autoconfig.skyblocker.option.general.fairySouls.highlightOnlyNearbySouls.@Tooltip": "When enabled only fairy souls in a radius of 50 blocks are highlighted", + "text.autoconfig.skyblocker.option.general.mythologicalRitual": "Mythological Ritual Helper", + "text.autoconfig.skyblocker.option.general.mythologicalRitual.enableMythologicalRitualHelper": "Enable Mythological Ritual Helper", "text.autoconfig.skyblocker.option.general.itemCooldown": "Item Cooldown", "text.autoconfig.skyblocker.option.general.itemCooldown.enableItemCooldowns": "Enable Item Cooldown", "text.autoconfig.skyblocker.option.general.shortcuts": "Shortcuts", From cd3ebd6e9411bdd909bcd68ab6c33aad5b52f07e Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Thu, 5 Oct 2023 10:53:26 -0400 Subject: [PATCH 07/11] Fix RenderHelper#renderQuad --- .../hysky/skyblocker/utils/render/RenderHelper.java | 11 +++++------ .../skyblocker/skyblock/diana/MythologicalRitual.java | 6 ++---- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/utils/render/RenderHelper.java b/src/main/java/de/hysky/skyblocker/utils/render/RenderHelper.java index 14e6d10348..ec03b05fe4 100644 --- a/src/main/java/de/hysky/skyblocker/utils/render/RenderHelper.java +++ b/src/main/java/de/hysky/skyblocker/utils/render/RenderHelper.java @@ -1,7 +1,5 @@ package de.hysky.skyblocker.utils.render; -import com.mojang.blaze3d.platform.GlStateManager.DstFactor; -import com.mojang.blaze3d.platform.GlStateManager.SrcFactor; import com.mojang.blaze3d.systems.RenderSystem; import de.hysky.skyblocker.mixin.accessor.BeaconBlockEntityRendererInvoker; import me.x150.renderer.render.Renderer3d; @@ -138,7 +136,7 @@ public static void renderLinesFromPoints(WorldRenderContext context, Vec3d[] poi RenderSystem.setShaderColor(1f, 1f, 1f, 1f); RenderSystem.lineWidth(lineWidth); RenderSystem.enableBlend(); - RenderSystem.blendFunc(SrcFactor.SRC_ALPHA, DstFactor.ONE_MINUS_SRC_ALPHA); + RenderSystem.defaultBlendFunc(); RenderSystem.disableCull(); RenderSystem.enableDepthTest(); @@ -158,10 +156,7 @@ public static void renderLinesFromPoints(WorldRenderContext context, Vec3d[] poi matrices.pop(); GL11.glDisable(GL11.GL_LINE_SMOOTH); RenderSystem.lineWidth(1f); - RenderSystem.disableBlend(); - RenderSystem.defaultBlendFunc(); RenderSystem.enableCull(); - RenderSystem.disableDepthTest(); } public static void renderQuad(WorldRenderContext context, Vec3d[] points, float[] colorComponents, float alpha, boolean throughWalls) { @@ -177,6 +172,9 @@ public static void renderQuad(WorldRenderContext context, Vec3d[] points, float[ RenderSystem.setShader(GameRenderer::getPositionColorProgram); RenderSystem.setShaderColor(1f, 1f, 1f, 1f); + RenderSystem.enableBlend(); + RenderSystem.defaultBlendFunc(); + RenderSystem.disableCull(); RenderSystem.depthFunc(throughWalls ? GL11.GL_ALWAYS : GL11.GL_LEQUAL); buffer.begin(DrawMode.QUADS, VertexFormats.POSITION_COLOR); @@ -185,6 +183,7 @@ public static void renderQuad(WorldRenderContext context, Vec3d[] points, float[ } tessellator.draw(); + RenderSystem.enableCull(); RenderSystem.depthFunc(GL11.GL_LEQUAL); matrices.pop(); diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/diana/MythologicalRitual.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/diana/MythologicalRitual.java index 7260703708..f17d4195c9 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/diana/MythologicalRitual.java +++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/diana/MythologicalRitual.java @@ -123,8 +123,6 @@ public static void onParticle(ParticleS2CPacket packet) { } public static void render(WorldRenderContext context) { - RenderHelper.renderLinesFromPoints(context, new Vec3d[]{new Vec3d(0, 96, -100), new Vec3d(0, 96, 100)}, ORANGE_COLOR_COMPONENTS, 0.25F, 5); // TODO debug - RenderHelper.renderQuad(context, new Vec3d[]{new Vec3d(0, 100, -100), new Vec3d(0, 100, 100), new Vec3d(0, 200, 100), new Vec3d(0, 200, -100)}, ORANGE_COLOR_COMPONENTS, 0.25F, true); // TODO debug if (isActive()) { for (Map.Entry burrowEntry : griffinBurrows.entrySet()) { GriffinBurrow burrow = burrowEntry.getValue(); @@ -133,10 +131,10 @@ public static void render(WorldRenderContext context) { } if (burrow.confirmed != TriState.FALSE) { if (burrow.nextBurrowPlane != null) { - RenderHelper.renderLinesFromPoints(context, burrow.nextBurrowPlane, ORANGE_COLOR_COMPONENTS, 0.25F, 5); + RenderHelper.renderQuad(context, burrow.nextBurrowPlane, ORANGE_COLOR_COMPONENTS, 0.25F, true); } if (burrow.echoBurrowPlane != null) { - RenderHelper.renderLinesFromPoints(context, burrow.echoBurrowPlane, ORANGE_COLOR_COMPONENTS, 0.25F, 5); + RenderHelper.renderQuad(context, burrow.echoBurrowPlane, ORANGE_COLOR_COMPONENTS, 0.25F, true); } } } From fe3d568ae318f608e28ca29df6d028768c545e0a Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Thu, 5 Oct 2023 11:13:30 -0400 Subject: [PATCH 08/11] Update boolean controller --- .../de/hysky/skyblocker/config/categories/GeneralCategory.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java b/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java index 60deedd299..f1f64130d9 100644 --- a/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java +++ b/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java @@ -209,7 +209,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .binding(defaults.general.mythologicalRitual.enableMythologicalRitualHelper, () -> config.general.mythologicalRitual.enableMythologicalRitualHelper, newValue -> config.general.mythologicalRitual.enableMythologicalRitualHelper = newValue) - .controller(BooleanControllerBuilder::create) + .controller(ConfigUtils::createBooleanController) .build()) .build()) From b7a13ad892135540a4512afbadf9d5233a329e74 Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Tue, 10 Oct 2023 10:46:59 -0400 Subject: [PATCH 09/11] Update group name --- src/main/java/de/hysky/skyblocker/SkyblockerMod.java | 6 +++--- .../skyblocker/skyblock/diana/MythologicalRitual.java | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) rename src/main/java/{me/xmrvizzy => de/hysky}/skyblocker/skyblock/diana/MythologicalRitual.java (97%) diff --git a/src/main/java/de/hysky/skyblocker/SkyblockerMod.java b/src/main/java/de/hysky/skyblocker/SkyblockerMod.java index e18a8c83cd..dc8896cf56 100644 --- a/src/main/java/de/hysky/skyblocker/SkyblockerMod.java +++ b/src/main/java/de/hysky/skyblocker/SkyblockerMod.java @@ -2,14 +2,13 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import de.hysky.skyblocker.config.SkyblockerConfigManager; import de.hysky.skyblocker.skyblock.*; import de.hysky.skyblocker.skyblock.diana.MythologicalRitual; import de.hysky.skyblocker.skyblock.dungeon.*; import de.hysky.skyblocker.skyblock.dungeon.secrets.DungeonSecrets; -import de.hysky.skyblocker.skyblock.item.*; -import de.hysky.skyblocker.skyblock.tabhud.screenbuilder.ScreenMaster; -import de.hysky.skyblocker.config.SkyblockerConfigManager; import de.hysky.skyblocker.skyblock.dwarven.DwarvenHud; +import de.hysky.skyblocker.skyblock.item.*; import de.hysky.skyblocker.skyblock.itemlist.ItemRepository; import de.hysky.skyblocker.skyblock.quicknav.QuickNav; import de.hysky.skyblocker.skyblock.rift.TheRift; @@ -17,6 +16,7 @@ import de.hysky.skyblocker.skyblock.special.SpecialEffects; import de.hysky.skyblocker.skyblock.spidersden.Relics; import de.hysky.skyblocker.skyblock.tabhud.TabHud; +import de.hysky.skyblocker.skyblock.tabhud.screenbuilder.ScreenMaster; import de.hysky.skyblocker.skyblock.tabhud.util.PlayerListMgr; import de.hysky.skyblocker.utils.NEURepoManager; import de.hysky.skyblocker.utils.Utils; diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/diana/MythologicalRitual.java b/src/main/java/de/hysky/skyblocker/skyblock/diana/MythologicalRitual.java similarity index 97% rename from src/main/java/me/xmrvizzy/skyblocker/skyblock/diana/MythologicalRitual.java rename to src/main/java/de/hysky/skyblocker/skyblock/diana/MythologicalRitual.java index f17d4195c9..ea7b39cfef 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/diana/MythologicalRitual.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/diana/MythologicalRitual.java @@ -1,10 +1,10 @@ -package me.xmrvizzy.skyblocker.skyblock.diana; +package de.hysky.skyblocker.skyblock.diana; import com.mojang.brigadier.Command; -import me.xmrvizzy.skyblocker.SkyblockerMod; -import me.xmrvizzy.skyblocker.config.SkyblockerConfigManager; -import me.xmrvizzy.skyblocker.utils.Utils; -import me.xmrvizzy.skyblocker.utils.render.RenderHelper; +import de.hysky.skyblocker.SkyblockerMod; +import de.hysky.skyblocker.config.SkyblockerConfigManager; +import de.hysky.skyblocker.utils.Utils; +import de.hysky.skyblocker.utils.render.RenderHelper; import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback; import net.fabricmc.fabric.api.client.message.v1.ClientReceiveMessageEvents; import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext; From 99a4bbc07ad8d916476ba87304aec9015cdcbbdb Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Tue, 10 Oct 2023 10:56:58 -0400 Subject: [PATCH 10/11] Refactor imports --- .../java/de/hysky/skyblocker/config/SkyblockerConfig.java | 4 ++-- .../hysky/skyblocker/config/categories/GeneralCategory.java | 4 ++-- .../hysky/skyblocker/mixin/ClientPlayNetworkHandlerMixin.java | 2 +- .../java/de/hysky/skyblocker/utils/render/RenderHelper.java | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java b/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java index 5f8f47d024..9d5e95f5e3 100644 --- a/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java +++ b/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java @@ -1,11 +1,11 @@ package de.hysky.skyblocker.config; +import de.hysky.skyblocker.skyblock.item.CustomArmorTrims; +import de.hysky.skyblocker.utils.chat.ChatFilterResult; import dev.isxander.yacl3.config.v2.api.SerialEntry; import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; -import de.hysky.skyblocker.skyblock.item.CustomArmorTrims; -import de.hysky.skyblocker.utils.chat.ChatFilterResult; import net.minecraft.client.resource.language.I18n; import net.minecraft.text.Text; import net.minecraft.util.Formatting; diff --git a/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java b/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java index f1f64130d9..a20f962d76 100644 --- a/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java +++ b/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java @@ -2,12 +2,12 @@ import de.hysky.skyblocker.config.ConfigUtils; import de.hysky.skyblocker.config.SkyblockerConfig; +import de.hysky.skyblocker.skyblock.shortcut.ShortcutsConfigScreen; +import de.hysky.skyblocker.utils.render.title.TitleContainerConfigScreen; import dev.isxander.yacl3.api.*; import dev.isxander.yacl3.api.controller.FloatFieldControllerBuilder; import dev.isxander.yacl3.api.controller.FloatSliderControllerBuilder; import dev.isxander.yacl3.api.controller.IntegerSliderControllerBuilder; -import de.hysky.skyblocker.skyblock.shortcut.ShortcutsConfigScreen; -import de.hysky.skyblocker.utils.render.title.TitleContainerConfigScreen; import net.minecraft.client.MinecraftClient; import net.minecraft.text.Text; diff --git a/src/main/java/de/hysky/skyblocker/mixin/ClientPlayNetworkHandlerMixin.java b/src/main/java/de/hysky/skyblocker/mixin/ClientPlayNetworkHandlerMixin.java index 7615a8e1a6..f68a4e9453 100644 --- a/src/main/java/de/hysky/skyblocker/mixin/ClientPlayNetworkHandlerMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixin/ClientPlayNetworkHandlerMixin.java @@ -2,11 +2,11 @@ import com.llamalad7.mixinextras.injector.WrapWithCondition; import com.llamalad7.mixinextras.sugar.Local; -import dev.cbyrne.betterinject.annotations.Inject; import de.hysky.skyblocker.skyblock.FishingHelper; import de.hysky.skyblocker.skyblock.diana.MythologicalRitual; import de.hysky.skyblocker.skyblock.dungeon.secrets.DungeonSecrets; import de.hysky.skyblocker.utils.Utils; +import dev.cbyrne.betterinject.annotations.Inject; import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.ClientPlayNetworkHandler; import net.minecraft.entity.ItemEntity; diff --git a/src/main/java/de/hysky/skyblocker/utils/render/RenderHelper.java b/src/main/java/de/hysky/skyblocker/utils/render/RenderHelper.java index ec03b05fe4..4cfaef8f38 100644 --- a/src/main/java/de/hysky/skyblocker/utils/render/RenderHelper.java +++ b/src/main/java/de/hysky/skyblocker/utils/render/RenderHelper.java @@ -2,10 +2,10 @@ import com.mojang.blaze3d.systems.RenderSystem; import de.hysky.skyblocker.mixin.accessor.BeaconBlockEntityRendererInvoker; -import me.x150.renderer.render.Renderer3d; import de.hysky.skyblocker.utils.render.culling.OcclusionCulling; import de.hysky.skyblocker.utils.render.title.Title; import de.hysky.skyblocker.utils.render.title.TitleContainer; +import me.x150.renderer.render.Renderer3d; import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; From 993e8fd81ab90042b921e597353eb57d67ee56ff Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Sun, 22 Oct 2023 23:20:43 -0400 Subject: [PATCH 11/11] Fix indents --- .../config/categories/GeneralCategory.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java b/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java index a20f962d76..10b21891b8 100644 --- a/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java +++ b/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java @@ -200,18 +200,18 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .build()) .build()) - //Mythological Ritual - .group(OptionGroup.createBuilder() - .name(Text.translatable("text.autoconfig.skyblocker.option.general.mythologicalRitual")) - .collapsed(true) - .option(Option.createBuilder() - .name(Text.translatable("text.autoconfig.skyblocker.option.general.mythologicalRitual.enableMythologicalRitualHelper")) - .binding(defaults.general.mythologicalRitual.enableMythologicalRitualHelper, - () -> config.general.mythologicalRitual.enableMythologicalRitualHelper, - newValue -> config.general.mythologicalRitual.enableMythologicalRitualHelper = newValue) - .controller(ConfigUtils::createBooleanController) - .build()) - .build()) + //Mythological Ritual + .group(OptionGroup.createBuilder() + .name(Text.translatable("text.autoconfig.skyblocker.option.general.mythologicalRitual")) + .collapsed(true) + .option(Option.createBuilder() + .name(Text.translatable("text.autoconfig.skyblocker.option.general.mythologicalRitual.enableMythologicalRitualHelper")) + .binding(defaults.general.mythologicalRitual.enableMythologicalRitualHelper, + () -> config.general.mythologicalRitual.enableMythologicalRitualHelper, + newValue -> config.general.mythologicalRitual.enableMythologicalRitualHelper = newValue) + .controller(ConfigUtils::createBooleanController) + .build()) + .build()) //Item Cooldown .group(OptionGroup.createBuilder()