-
-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #519 from AzureAaron/kuudra
Kuudra Features
- Loading branch information
Showing
15 changed files
with
558 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
src/main/java/de/hysky/skyblocker/config/categories/CrimsonIsleCategory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
21
src/main/java/de/hysky/skyblocker/mixin/PlayerInventoryMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
src/main/java/de/hysky/skyblocker/skyblock/crimson/kuudra/ArrowPoisonWarning.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
src/main/java/de/hysky/skyblocker/skyblock/crimson/kuudra/Kuudra.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
Oops, something went wrong.