Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -412,11 +412,11 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig
.name(Component.translatable("skyblocker.config.general.specialEffects"))
.collapsed(true)
.option(Option.<Boolean>createBuilder()
.name(Component.translatable("skyblocker.config.general.specialEffects.rareDungeonDropEffects"))
.description(Component.translatable("skyblocker.config.general.specialEffects.rareDungeonDropEffects.@Tooltip"))
.binding(defaults.general.specialEffects.rareDungeonDropEffects,
() -> config.general.specialEffects.rareDungeonDropEffects,
newValue -> config.general.specialEffects.rareDungeonDropEffects = newValue)
.name(Component.translatable("skyblocker.config.general.specialEffects.rareDropEffects"))
.description(Component.translatable("skyblocker.config.general.specialEffects.rareDropEffects.@Tooltip"))
.binding(defaults.general.specialEffects.rareDropEffects,
() -> config.general.specialEffects.rareDropEffects,
newValue -> config.general.specialEffects.rareDropEffects = newValue)
.controller(ConfigUtils.createBooleanController())
.build())
.option(Option.<Boolean>createBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ public static class WikiLookup {
}

public static class SpecialEffects {
public boolean rareDungeonDropEffects = true;
public boolean rareDropEffects = true;

public boolean rareDyeDropEffects = true;
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
package de.hysky.skyblocker.skyblock.special;

import de.hysky.skyblocker.annotations.Init;
import de.hysky.skyblocker.config.SkyblockerConfigManager;
import de.hysky.skyblocker.skyblock.itemlist.ItemRepository;
import de.hysky.skyblocker.utils.Utils;
import net.fabricmc.fabric.api.client.message.v1.ClientReceiveMessageEvents;
import net.minecraft.client.Minecraft;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.ItemStack;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class RareDropSpecialEffects {
private static final Logger LOGGER = LoggerFactory.getLogger(RareDropSpecialEffects.class);
private static final Minecraft CLIENT = Minecraft.getInstance();
private static final Pattern DUNGEON_CHEST_PATTERN = Pattern.compile("^\\s{3,}(?!.*:)(?:RARE REWARD!\\s+)?(?<item>.+)$");
private static final Pattern MAGIC_FIND_PATTERN = Pattern.compile("^(?!.*:)(?:RARE|VERY RARE|CRAZY RARE|INSANE) DROP!\\s+(?<item>.+?)(?:\\s+\\(\\+\\d+%? ✯ Magic Find\\))?$");

@Init
public static void init() {
ClientReceiveMessageEvents.ALLOW_GAME.register(RareDropSpecialEffects::displayRareDropEffect);
}

private static boolean displayRareDropEffect(Component message, boolean overlay) {
if (Utils.isOnSkyblock() && SkyblockerConfigManager.get().general.specialEffects.rareDropEffects && !overlay) {

try {
String stringForm = message.getString();
Matcher dungeonMatcher = DUNGEON_CHEST_PATTERN.matcher(stringForm);
Matcher magicFindMatcher = MAGIC_FIND_PATTERN.matcher(stringForm);

if (dungeonMatcher.matches()) {
triggerDropEffect(dungeonMatcher.group("item"));
}

else if (magicFindMatcher.matches()) {
triggerDropEffect(magicFindMatcher.group("item"));
}
} catch (Exception e) { //In case there's a regex failure or something else bad happens
LOGGER.error("[Skyblocker Special Effects] An unexpected exception was encountered: ", e);
}
}

return true;
}

private static void triggerDropEffect(String itemName) {
ItemStack stack = getStackFromName(itemName);
if (stack != null && !stack.isEmpty()) {
CLIENT.particleEngine.createTrackingEmitter(CLIENT.player, ParticleTypes.PORTAL, 30);
CLIENT.gameRenderer.displayItemActivation(stack);
}
}

private static ItemStack getStackFromName(String itemName) {
String itemId = switch (itemName) {
//Dungeon
case "Recombobulator 3000" -> "RECOMBOBULATOR_3000";
//M3
case "First Master Star" -> "FIRST_MASTER_STAR";
//M4
case "Second Master Star" -> "SECOND_MASTER_STAR";
//M5
case "Third Master Star" -> "THIRD_MASTER_STAR";
case "Shadow Fury" -> "SHADOW_FURY";
//M6
case "Giant's Sword" -> "GIANTS_SWORD";
case "Fourth Master Star" -> "FOURTH_MASTER_STAR";
//M7
case "Necron Dye" -> "NECRON_DYE";
case "Dark Claymore" -> "DARK_CLAYMORE";
case "Necron's Handle", "Shiny Necron's Handle" -> "NECRON_HANDLE";
case "Master Skull - Tier 5" -> "MASTER_SKULL_TIER_5";
case "Shadow Warp" -> "SHADOW_WARP_SCROLL";
case "Wither Shield" -> "WITHER_SHIELD_SCROLL";
case "Implosion" -> "IMPLOSION_SCROLL";
case "Fifth Master Star" -> "FIFTH_MASTER_STAR";

//Slayer
//Zombie
case "Scythe Blade" -> "SCYTHE_BLADE";
case "Shard Of The Shredded" -> "SHARD_OF_THE_SHREDDED";
case "Severed Hand" -> "SEVERED_HAND";
case "Warden Heart" -> "WARDEN_HEART";
//Spider
case "Shriveled Wasp" -> "SHRIVELED_WASP";
case "Digested Mosquito" -> "DIGESTED_MOSQUITO";
case "Ensnared Snail" -> "ENSNARED_SNAIL";
case "Primordial Eye" -> "PRIMORDIAL_EYE";
//Wolf
case "Overflux Capacitor" -> "OVERFLUX_CAPACITOR";
//Enderman
case "End Stone Idol" -> "END_STONE_IDOL";
case "Judgement Core" -> "JUDGEMENT_CORE";
//Blaze
case "High Class Archfiend Dice" -> "HIGH_CLASS_ARCHFIEND_DICE";

//Fishing
case "Radioactive Vial" -> "RADIOACTIVE_VIAL";
case "Tiki Mask" -> "TIKI_MASK";
case "Titanoboa Shed" -> "TITANOBOA_SHED";

default -> "NONE";
};

return ItemRepository.getItemStack(itemId);
}
}
4 changes: 2 additions & 2 deletions src/main/resources/assets/skyblocker/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -572,8 +572,8 @@
"skyblocker.config.general.shortcuts.enableShortcuts.@Tooltip": "Works anywhere, even in vanilla! Edit shortcuts with \"/skyblocker shortcuts\". At least one of the following options must be enabled for this to take effect.",

"skyblocker.config.general.specialEffects": "Special Effects",
"skyblocker.config.general.specialEffects.rareDungeonDropEffects": "Rare Dungeon Drop Effects",
"skyblocker.config.general.specialEffects.rareDungeonDropEffects.@Tooltip": "Adds a special visual effect triggered upon obtaining rare dungeon loot!",
"skyblocker.config.general.specialEffects.rareDropEffects": "Rare Drop Effects",
"skyblocker.config.general.specialEffects.rareDropEffects.@Tooltip": "Adds a special visual effect triggered upon obtaining rare loot!",
"skyblocker.config.general.specialEffects.rareDyeDropEffects": "Rare Dye Drop Effects",
"skyblocker.config.general.specialEffects.rareDyeDropEffects.@Tooltip": "Adds a special visual effect triggered upon dropping a rare dye!",

Expand Down