Skip to content

Commit

Permalink
Merge pull request #519 from AzureAaron/kuudra
Browse files Browse the repository at this point in the history
Kuudra Features
  • Loading branch information
kevinthegreat1 authored Feb 14, 2024
2 parents 5e52750 + 16e94a9 commit 1486efa
Show file tree
Hide file tree
Showing 15 changed files with 558 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/main/java/de/hysky/skyblocker/SkyblockerMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import de.hysky.skyblocker.config.SkyblockerConfigManager;
import de.hysky.skyblocker.debug.Debug;
import de.hysky.skyblocker.skyblock.*;
import de.hysky.skyblocker.skyblock.crimson.kuudra.Kuudra;
import de.hysky.skyblocker.skyblock.dungeon.*;
import de.hysky.skyblocker.skyblock.dungeon.partyfinder.PartyFinderScreen;
import de.hysky.skyblocker.skyblock.dungeon.puzzle.CreeperBeams;
Expand Down Expand Up @@ -137,6 +138,7 @@ public void onInitializeClient() {
SecretsTracker.init();
ApiUtils.init();
Debug.init();
Kuudra.init();
RenderHelper.init();
containerSolverManager.init();
statusBarTracker.init();
Expand Down
34 changes: 34 additions & 0 deletions src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,9 @@ public static class Locations {
@SerialEntry
public Barn barn = new Barn();

@SerialEntry
public CrimsonIsle crimsonIsle = new CrimsonIsle();

@SerialEntry
public Dungeons dungeons = new Dungeons();

Expand Down Expand Up @@ -956,6 +959,37 @@ public static class Barn {
public boolean solveTreasureHunter = true;
}

public static class CrimsonIsle {
@SerialEntry
public Kuudra kuudra = new Kuudra();
}

public static class Kuudra {
@SerialEntry
public boolean supplyWaypoints = true;

@SerialEntry
public boolean fuelWaypoints = true;

@SerialEntry
public Waypoint.Type suppliesAndFuelWaypointType = Waypoint.Type.WAYPOINT;

@SerialEntry
public boolean ballistaBuildWaypoints = true;

@SerialEntry
public boolean safeSpotWaypoints = true;

@SerialEntry
public boolean pearlWaypoints = true;

@SerialEntry
public boolean noArrowPoisonWarning = true;

@SerialEntry
public int arrowPoisonThreshold = 16;
}

public static class Rift {
@SerialEntry
public boolean mirrorverseWaypoints = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public static Screen createGUI(Screen parent) {
.category(GeneralCategory.create(defaults, config))
.category(DungeonsCategory.create(defaults, config))
.category(DwarvenMinesCategory.create(defaults, config))
.category(CrimsonIsleCategory.create(defaults, config))
.category(LocationsCategory.create(defaults, config))
.category(SlayersCategory.create(defaults, config))
.category(QuickNavigationCategory.create(defaults, config))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package de.hysky.skyblocker.config.categories;

import de.hysky.skyblocker.config.ConfigUtils;
import de.hysky.skyblocker.config.SkyblockerConfig;
import de.hysky.skyblocker.utils.waypoint.Waypoint;
import dev.isxander.yacl3.api.ConfigCategory;
import dev.isxander.yacl3.api.Option;
import dev.isxander.yacl3.api.OptionDescription;
import dev.isxander.yacl3.api.OptionGroup;
import dev.isxander.yacl3.api.controller.IntegerFieldControllerBuilder;
import net.minecraft.text.Text;

public class CrimsonIsleCategory {

public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig config) {
return ConfigCategory.createBuilder()
.name(Text.translatable("text.autoconfig.skyblocker.category.crimsonIsle"))

//Kuudra
.group(OptionGroup.createBuilder()
.name(Text.translatable("text.autoconfig.skyblocker.option.locations.crimsonIsle.kuudra"))
.collapsed(false)
.option(Option.<Boolean>createBuilder()
.name(Text.translatable("text.autoconfig.skyblocker.option.locations.crimsonIsle.kuudra.supplyWaypoints"))
.binding(defaults.locations.crimsonIsle.kuudra.supplyWaypoints,
() -> config.locations.crimsonIsle.kuudra.supplyWaypoints,
newValue -> config.locations.crimsonIsle.kuudra.supplyWaypoints = newValue)
.controller(ConfigUtils::createBooleanController)
.build())
.option(Option.<Boolean>createBuilder()
.name(Text.translatable("text.autoconfig.skyblocker.option.locations.crimsonIsle.kuudra.fuelWaypoints"))
.binding(defaults.locations.crimsonIsle.kuudra.fuelWaypoints,
() -> config.locations.crimsonIsle.kuudra.fuelWaypoints,
newValue -> config.locations.crimsonIsle.kuudra.fuelWaypoints = newValue)
.controller(ConfigUtils::createBooleanController)
.build())
.option(Option.<Waypoint.Type>createBuilder()
.name(Text.translatable("text.autoconfig.skyblocker.option.locations.crimsonIsle.kuudra.suppliesAndFuelWaypointType"))
.description(OptionDescription.of(Text.translatable("text.autoconfig.skyblocker.option.general.waypoints.waypointType.@Tooltip")))
.binding(defaults.locations.crimsonIsle.kuudra.suppliesAndFuelWaypointType,
() -> config.locations.crimsonIsle.kuudra.suppliesAndFuelWaypointType,
newValue -> config.locations.crimsonIsle.kuudra.suppliesAndFuelWaypointType = newValue)
.controller(ConfigUtils::createEnumCyclingListController)
.build())
.option(Option.<Boolean>createBuilder()
.name(Text.translatable("text.autoconfig.skyblocker.option.locations.crimsonIsle.kuudra.ballistaBuildWaypoints"))
.binding(defaults.locations.crimsonIsle.kuudra.ballistaBuildWaypoints,
() -> config.locations.crimsonIsle.kuudra.ballistaBuildWaypoints,
newValue -> config.locations.crimsonIsle.kuudra.ballistaBuildWaypoints = newValue)
.controller(ConfigUtils::createBooleanController)
.build())
.option(Option.<Boolean>createBuilder()
.name(Text.translatable("text.autoconfig.skyblocker.option.locations.crimsonIsle.kuudra.safeSpotWaypoints"))
.binding(defaults.locations.crimsonIsle.kuudra.safeSpotWaypoints,
() -> config.locations.crimsonIsle.kuudra.safeSpotWaypoints,
newValue -> config.locations.crimsonIsle.kuudra.safeSpotWaypoints = newValue)
.controller(ConfigUtils::createBooleanController)
.build())
.option(Option.<Boolean>createBuilder()
.name(Text.translatable("text.autoconfig.skyblocker.option.locations.crimsonIsle.kuudra.pearlWaypoints"))
.binding(defaults.locations.crimsonIsle.kuudra.pearlWaypoints,
() -> config.locations.crimsonIsle.kuudra.pearlWaypoints,
newValue -> config.locations.crimsonIsle.kuudra.pearlWaypoints = newValue)
.controller(ConfigUtils::createBooleanController)
.build())
.option(Option.<Boolean>createBuilder()
.name(Text.translatable("text.autoconfig.skyblocker.option.locations.crimsonIsle.kuudra.noArrowPoisonWarning"))
.description(OptionDescription.of(Text.translatable("text.autoconfig.skyblocker.option.locations.crimsonIsle.kuudra.noArrowPoisonWarning.@Tooltip")))
.binding(defaults.locations.crimsonIsle.kuudra.noArrowPoisonWarning,
() -> config.locations.crimsonIsle.kuudra.noArrowPoisonWarning,
newValue -> config.locations.crimsonIsle.kuudra.noArrowPoisonWarning = newValue)
.controller(ConfigUtils::createBooleanController)
.build())
.option(Option.<Integer>createBuilder()
.name(Text.translatable("text.autoconfig.skyblocker.option.locations.crimsonIsle.kuudra.arrowPoisonThreshold"))
.description(OptionDescription.of(Text.translatable("text.autoconfig.skyblocker.option.locations.crimsonIsle.kuudra.arrowPoisonThreshold.@Tooltip")))
.binding(defaults.locations.crimsonIsle.kuudra.arrowPoisonThreshold,
() -> config.locations.crimsonIsle.kuudra.arrowPoisonThreshold,
newValue -> config.locations.crimsonIsle.kuudra.arrowPoisonThreshold = newValue)
.controller(IntegerFieldControllerBuilder::create)
.build())
.build())
.build();
}
}
21 changes: 21 additions & 0 deletions src/main/java/de/hysky/skyblocker/mixin/PlayerInventoryMixin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package de.hysky.skyblocker.mixin;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import de.hysky.skyblocker.skyblock.crimson.kuudra.ArrowPoisonWarning;
import net.minecraft.entity.player.PlayerInventory;

@Mixin(PlayerInventory.class)
public class PlayerInventoryMixin {
@Shadow
public int selectedSlot;

@Inject(method = "scrollInHotbar", at = @At("TAIL"))
private void skyblocker$onHotbarScroll(CallbackInfo ci) {
ArrowPoisonWarning.tryWarn(selectedSlot);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package de.hysky.skyblocker.skyblock.crimson.kuudra;

import java.util.function.Supplier;

import de.hysky.skyblocker.config.SkyblockerConfig;
import de.hysky.skyblocker.config.SkyblockerConfigManager;
import de.hysky.skyblocker.skyblock.crimson.kuudra.Kuudra.KuudraPhase;
import de.hysky.skyblocker.utils.ItemUtils;
import de.hysky.skyblocker.utils.Utils;
import de.hysky.skyblocker.utils.render.RenderHelper;
import de.hysky.skyblocker.utils.render.title.Title;
import net.minecraft.client.MinecraftClient;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.item.BowItem;
import net.minecraft.item.ItemStack;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;

public class ArrowPoisonWarning {
private static final Supplier<SkyblockerConfig.Kuudra> CONFIG = () -> SkyblockerConfigManager.get().locations.crimsonIsle.kuudra;
private static final int THREE_SECONDS = 20 * 3;
private static final Title NONE_TITLE = new Title(Text.translatable("skyblocker.crimson.kuudra.noArrowPoison").formatted(Formatting.GREEN));
private static final Title LOW_TITLE = new Title(Text.translatable("skyblocker.crimson.kuudra.lowArrowPoison").formatted(Formatting.GREEN));

public static void tryWarn(int newSlot) {
//Exclude skyblock menu
if (Utils.isInKuudra() && CONFIG.get().noArrowPoisonWarning && Kuudra.phase == KuudraPhase.DPS && newSlot != 8) {
MinecraftClient client = MinecraftClient.getInstance();
PlayerInventory inventory = client.player.getInventory();
ItemStack heldItem = inventory.getStack(newSlot);

if (heldItem.getItem() instanceof BowItem) {
boolean hasToxicArrowPoison = false;
int arrowPoisonAmount = 0;

for (int i = 0; i < inventory.size(); ++i) {
ItemStack stack = inventory.getStack(i);
String itemId = ItemUtils.getItemId(stack);

if (itemId.equals("TOXIC_ARROW_POISON")) {
hasToxicArrowPoison = true;
arrowPoisonAmount += stack.getCount();
}
}

if (!hasToxicArrowPoison) {
RenderHelper.displayInTitleContainerAndPlaySound(NONE_TITLE, THREE_SECONDS);
} else if (arrowPoisonAmount < CONFIG.get().arrowPoisonThreshold) {
RenderHelper.displayInTitleContainerAndPlaySound(LOW_TITLE, THREE_SECONDS);
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package de.hysky.skyblocker.skyblock.crimson.kuudra;

import de.hysky.skyblocker.utils.Utils;
import de.hysky.skyblocker.utils.scheduler.Scheduler;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents;
import net.fabricmc.fabric.api.client.message.v1.ClientReceiveMessageEvents;
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents;
import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;

public class Kuudra {
public static final String LOCATION = "kuudra";
static KuudraPhase phase = KuudraPhase.OTHER;

public static void init() {
WorldRenderEvents.AFTER_TRANSLUCENT.register(KuudraWaypoints::render);
ClientLifecycleEvents.CLIENT_STARTED.register(KuudraWaypoints::load);
ClientPlayConnectionEvents.JOIN.register((_handler, _sender, _client) -> reset());
ClientReceiveMessageEvents.GAME.register(Kuudra::onMessage);
Scheduler.INSTANCE.scheduleCyclic(KuudraWaypoints::tick, 20);
}

private static void onMessage(Text text, boolean overlay) {
if (Utils.isInKuudra() && !overlay) {
String message = Formatting.strip(text.getString());

if (message.equals("[NPC] Elle: ARGH! All of the supplies fell into the lava! You need to retrieve them quickly!")) {
phase = KuudraPhase.RETRIEVE_SUPPLIES;
}

if (message.equals("[NPC] Elle: Phew! The Ballista is finally ready! It should be strong enough to tank Kuudra's blows now!")) {
phase = KuudraPhase.DPS;
}

if (message.equals("[NPC] Elle: POW! SURELY THAT'S IT! I don't think he has any more in him!")) {
phase = KuudraPhase.OTHER;
}
}
}

private static void reset() {
phase = KuudraPhase.OTHER;
}

enum KuudraPhase {
OTHER,
RETRIEVE_SUPPLIES,
DPS;
}
}
Loading

0 comments on commit 1486efa

Please sign in to comment.