-
-
Notifications
You must be signed in to change notification settings - Fork 169
Add option for Stereo Harmony to color pests differently #2125
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
Open
LJNeon
wants to merge
8
commits into
SkyblockerMod:master
Choose a base branch
from
LJNeon:pest-vinyls-glow
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
1865310
Add option for Stereo Harmony to color pests differently
LJNeon b241cf8
Fix issues & simplify code
LJNeon e007aec
Clean up imports
LJNeon ffe7d81
Use empty string instead of null to represent no vinyl selected
LJNeon 8bfd765
Avoid re-ordering GardenConstants imports
LJNeon 6ea807f
Change highlight color from aqua to dark aqua
LJNeon 518dad3
Move to garden package & minor improvements
LJNeon dc9566e
Fix merge issue
LJNeon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
69 changes: 69 additions & 0 deletions
69
src/main/java/de/hysky/skyblocker/skyblock/garden/VacuumCache.java
This file contains hidden or 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,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() : ""; | ||
| } | ||
| } | ||
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.