Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mythological Ritual Helper #330

Merged
merged 11 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
9 changes: 8 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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
Expand Down
10 changes: 6 additions & 4 deletions src/main/java/de/hysky/skyblocker/SkyblockerMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,21 @@

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;
import de.hysky.skyblocker.skyblock.shortcut.Shortcuts;
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;
Expand All @@ -39,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();
Expand Down Expand Up @@ -76,6 +77,7 @@ public void onInitializeClient() {
WikiLookup.init();
FairySouls.init();
Relics.init();
MythologicalRitual.init();
BackpackPreview.init();
QuickNav.init();
ItemCooldowns.init();
Expand Down
13 changes: 10 additions & 3 deletions src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -653,7 +661,6 @@ public static class DungeonChestProfit {

@SerialEntry
public Formatting incompleteColor = Formatting.BLUE;

}

public static class LividColor {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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.<Boolean>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()
.name(Text.translatable("text.autoconfig.skyblocker.option.general.itemCooldown"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 dev.cbyrne.betterinject.annotations.Inject;
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;
Expand All @@ -24,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);
Expand All @@ -45,4 +46,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);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
package de.hysky.skyblocker.skyblock.diana;

import com.mojang.brigadier.Command;
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;
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;
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.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;

import java.util.HashMap;
import java.util.Map;
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("(?<message>You dug out a Griffin Burrow!|You finished the Griffin burrow chain!) \\((?<index>\\d)/4\\)");
private static final float[] ORANGE_COLOR_COMPONENTS = DyeColor.ORANGE.getColorComponents();
private static final Map<BlockPos, GriffinBurrow> griffinBurrows = new HashMap<>();
@Nullable
private static BlockPos lastDugBurrowPos;
private static GriffinBurrow previousBurrow = new GriffinBurrow();

public static void init() {
WorldRenderEvents.AFTER_TRANSLUCENT.register(MythologicalRitual::render);
AttackBlockCallback.EVENT.register(MythologicalRitual::onAttackBlock);
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.remove(context.getArgument("pos", BlockPos.class));
return Command.SINGLE_SUCCESS;
}))
)
)));

// 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) {
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, 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) {
if (isActive()) {
for (Map.Entry<BlockPos, GriffinBurrow> burrowEntry : griffinBurrows.entrySet()) {
GriffinBurrow burrow = burrowEntry.getValue();
if (burrow.confirmed == TriState.TRUE) {
RenderHelper.renderFilledThroughWallsWithBeaconBeam(context, burrowEntry.getKey(), ORANGE_COLOR_COMPONENTS, 0.25F);
}
if (burrow.confirmed != TriState.FALSE) {
if (burrow.nextBurrowPlane != null) {
RenderHelper.renderQuad(context, burrow.nextBurrowPlane, ORANGE_COLOR_COMPONENTS, 0.25F, true);
}
if (burrow.echoBurrowPlane != null) {
RenderHelper.renderQuad(context, burrow.echoBurrowPlane, ORANGE_COLOR_COMPONENTS, 0.25F, true);
}
}
}
}
}

public static ActionResult onAttackBlock(PlayerEntity player, World world, Hand hand, BlockPos pos, Direction direction) {
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()) {
previousBurrow.confirmed = TriState.FALSE;
previousBurrow = griffinBurrows.get(lastDugBurrowPos);
previousBurrow.confirmed = TriState.DEFAULT;
}
}

private static boolean isActive() {
return SkyblockerConfigManager.get().general.mythologicalRitual.enableMythologicalRitualHelper && Utils.getLocationRaw().equals("hub");
}

private static class GriffinBurrow {
private int critParticle;
private int enchantParticle;
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;
regression.clear();
}
}
}
Loading