diff options
author | Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> | 2023-09-28 15:40:22 -0400 |
---|---|---|
committer | Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> | 2023-10-22 23:20:33 -0400 |
commit | 58e43eee5c02efbe6144bfd6e4b1a95101d24576 (patch) | |
tree | d27e0594430405078d053702fe57bbe4a50cbe51 | |
parent | 0314c406d18d49ac00998c4a33bfdeea4e10280f (diff) | |
download | Skyblocker-58e43eee5c02efbe6144bfd6e4b1a95101d24576.tar.gz Skyblocker-58e43eee5c02efbe6144bfd6e4b1a95101d24576.tar.bz2 Skyblocker-58e43eee5c02efbe6144bfd6e4b1a95101d24576.zip |
Add next burrow direction detection
-rw-r--r-- | build.gradle | 9 | ||||
-rw-r--r-- | gradle.properties | 9 | ||||
-rw-r--r-- | src/main/java/me/xmrvizzy/skyblocker/skyblock/diana/MythologicalRitual.java | 89 |
3 files changed, 80 insertions, 27 deletions
diff --git a/build.gradle b/build.gradle index 66c56e21..fde768d5 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 c5794079..42529261 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 c74d5e77..ba27845a 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.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.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.Hand; 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 @@ import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.lit public class MythologicalRitual { private static final Pattern GRIFFIN_BURROW_DUG = Pattern.compile("(?<message>You dug out a Griffin Burrow!|You finished the Griffin burrow chain!) \\((?<index>\\d)/4\\)"); - private static final Map<BlockPos, BooleanBooleanMutablePair> particlesMap = new HashMap<>(); - private static final Object2LongMap<BlockPos> griffinBurrows = new Object2LongOpenHashMap<>(); + private static final float[] WHITE_COLOR_COMPONENTS = {1.0f, 1.0f, 1.0f}; + private static final Map<BlockPos, GriffinBurrow> 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 class MythologicalRitual { 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<BlockPos> griffinBorrow : griffinBurrows.object2LongEntrySet()) { - if (griffinBorrow.getLongValue() <= 0) { - RenderHelper.renderFilledThroughWallsWithBeaconBeam(context, griffinBorrow.getKey(), DyeColor.GREEN.getColorComponents(), 0.5F); + for (Map.Entry<BlockPos, GriffinBurrow> 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 @@ public class MythologicalRitual { 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(); + } + } } |