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 @@ -60,6 +60,14 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig
newValue -> config.farming.garden.pestHighlighter = newValue)
.controller(ConfigUtils.createBooleanController())
.build())
.option(Option.<Boolean>createBuilder()
.name(Component.translatable("skyblocker.config.farming.garden.vinylHighlighter"))
.description(Component.translatable("skyblocker.config.farming.garden.vinylHighlighter.@Tooltip"))
.binding(defaults.farming.garden.vinylHighlighter,
() -> config.farming.garden.vinylHighlighter,
newValue -> config.farming.garden.vinylHighlighter = newValue)
.controller(ConfigUtils.createBooleanController())
.build())
.option(Option.<Boolean>createBuilder()
.name(Component.translatable("skyblocker.config.farming.garden.lockMouseTool"))
.binding(defaults.farming.garden.lockMouseTool,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ public static class Garden {

public boolean pestHighlighter = true;

public boolean vinylHighlighter = true;

public boolean lockMouseTool = false;

public boolean lockMouseGroundOnly = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import de.hysky.skyblocker.skyblock.entity.MobGlowAdder;
import de.hysky.skyblocker.skyblock.garden.CurrentJacobCrop;
import de.hysky.skyblocker.skyblock.garden.GardenConstants;
import de.hysky.skyblocker.skyblock.garden.VacuumCache;
import de.hysky.skyblocker.skyblock.item.HeadTextures;
import de.hysky.skyblocker.utils.ItemUtils;
import de.hysky.skyblocker.utils.Utils;
Expand All @@ -36,8 +37,11 @@ case ArmorStand as when isPestHead(as) ->
doesPestMatchCurrentContest(as) ?
// Pests but during Jacob's Contest
ChatFormatting.GREEN.getColor() :
// Default color
PEST_COLOUR;
// Pests from currently playing vinyl
doesPestMatchCurrentVinyl(as) ?
ChatFormatting.DARK_AQUA.getColor() :
// Default color
PEST_COLOUR;
default -> NO_GLOW;
};
}
Expand Down Expand Up @@ -85,8 +89,28 @@ public static boolean doesPestMatchCurrentContest(ArmorStand entity) {
}

// Filter only pest head that matches by crop
return entity.hasItemInSlot(EquipmentSlot.HEAD) && GardenConstants.PEST_HEAD_BY_CROP
return GardenConstants.PEST_HEAD_BY_CROP
.get(CurrentJacobCrop.CURRENT_CROP_CONTEST)
.contains(ItemUtils.getHeadTexture(entity.getItemBySlot(EquipmentSlot.HEAD)));
}

/**
* Matches the armor stand head with currently playing vinyl outside of Jacob's Contest.
*/
public static boolean doesPestMatchCurrentVinyl(ArmorStand entity) {
if (!SkyblockerConfigManager.get().farming.garden.vinylHighlighter)
return false;

String vinyl = VacuumCache.getVinyl();

// Only applies outside of Jacob's Contests
if (!StringUtils.isEmpty(CurrentJacobCrop.CURRENT_CROP_CONTEST) || vinyl.isEmpty()) {
return false;
}

// Filter only pest head that matches by name
return GardenConstants.PEST_HEAD_BY_CROP
.get(GardenConstants.CROP_BY_VINYL.get(vinyl))
.contains(ItemUtils.getHeadTexture(entity.getItemBySlot(EquipmentSlot.HEAD)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,20 @@ public interface GardenConstants {
map.put("Sunflower", HeadTextures.DRAGONFLY_PEST);
map.put("Wild Rose", HeadTextures.PRAYING_MANTIS_PEST);
});

Map<String, String> CROP_BY_VINYL = Map.ofEntries(
entry("VINYL_PRETTY_FLY", "Wheat"),
entry("VINYL_BUZZIN_BEATS", "Sugar Cane"),
entry("VINYL_CRICKET_CHOIR", "Carrot"),
entry("VINYL_CICADA_SYMPHONY", "Potato"),
entry("VINYL_EARTHWORM_ENSEMBLE", "Melon Slice"),
entry("VINYL_RODENT_REVOLUTION", "Pumpkin"),
entry("VINYL_WINGS_OF_HARMONY", "Cocoa Beans"),
entry("VINYL_BEETLE", "Nether Wart"),
entry("VINYL_DYNAMITES", "Cactus"),
entry("VINYL_SLOW_AND_GROOVY", "Mushroom"),
entry("VINYL_FIREFLY", "Moonflower"),
entry("VINYL_IMAGINE_DRAGONFLIES", "Sunflower"),
entry("VINYL_PRAY_FOR_ME", "Wild Rose")
);
}
69 changes: 69 additions & 0 deletions src/main/java/de/hysky/skyblocker/skyblock/garden/VacuumCache.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package de.hysky.skyblocker.skyblock.garden;

import com.mojang.serialization.Codec;

import de.hysky.skyblocker.SkyblockerMod;
import de.hysky.skyblocker.annotations.Init;
import de.hysky.skyblocker.utils.ItemUtils;
import de.hysky.skyblocker.utils.Utils;
import de.hysky.skyblocker.utils.data.ProfiledData;
import net.fabricmc.fabric.api.client.screen.v1.ScreenEvents;
import net.minecraft.client.gui.screens.inventory.ContainerScreen;
import net.minecraft.world.inventory.Slot;
import net.minecraft.world.item.ItemStack;

import java.nio.file.Path;

public class VacuumCache {
private static final Path FILE = SkyblockerMod.CONFIG_DIR.resolve("vacuum_cache.json");
private static final ProfiledData<String> CACHED_VINYL = new ProfiledData<>(FILE, Codec.STRING);

private VacuumCache() {}

@Init
public static void init() {
CACHED_VINYL.load();

ScreenEvents.BEFORE_INIT.register((_client, screen, _scaledWidth, _scaledHeight) -> {
if (Utils.isOnSkyblock() && screen instanceof ContainerScreen genericContainerScreen) {
if (genericContainerScreen.getTitle().getString().startsWith("Stereo Harmony")) {
ScreenEvents.afterTick(screen).register(screen1 -> {
for (Slot slot : genericContainerScreen.getMenu().slots) {
ItemStack stack = slot.getItem();

if (!stack.isEmpty() && ItemUtils.getLoreLineIf(stack, line -> line.equals("Click to stop playing!")) != null) {
setVinyl(stack.getSkyblockId());

return;
}
}

setVinyl("");
});
}
}
});
}

private static void setVinyl(String skyblockId) {
if (Utils.getProfileId().isEmpty()) return;

if (skyblockId.isEmpty()) {
if (!getVinyl().isEmpty()) {
CACHED_VINYL.remove();
CACHED_VINYL.save();
}
} else {
String current = getVinyl();

if (!current.equals(skyblockId)) {
CACHED_VINYL.put(skyblockId);
CACHED_VINYL.save();
}
}
}

public static String getVinyl() {
return CACHED_VINYL.containsKey() ? CACHED_VINYL.get() : "";
}
}
2 changes: 2 additions & 0 deletions src/main/resources/assets/skyblocker/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,8 @@
"skyblocker.config.farming.garden.lockMouseTool": "Lock camera when holding a farming tool",
"skyblocker.config.farming.garden.pestHighlighter": "Pest Highlighter",
"skyblocker.config.farming.garden.pestHighlighter.@Tooltip": "Makes all pests on your island glow so you can see them easier :D",
"skyblocker.config.farming.garden.vinylHighlighter": "Stereo Harmony Vinyl Highlighter",
"skyblocker.config.farming.garden.vinylHighlighter.@Tooltip": "Pests from Stereo Harmony vinyls glow blue outside of Jacob's Contests. Only enabled if Pest Highlighter is also enabled.",

"skyblocker.config.farming.general.blocksPerSec": "Blocks/s: %s",
"skyblocker.config.farming.general.coinsPerHour": "Coins/h: %s",
Expand Down