-
-
Notifications
You must be signed in to change notification settings - Fork 209
Added power Orb and Lantern Deploy Range indicators #2613
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
Toosiii
wants to merge
2
commits into
SkyblockerMod:main
Choose a base branch
from
Toosiii:power-Orb-Lantern-Range
base: main
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
2 commits
Select commit
Hold shift + click to select a range
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
78 changes: 78 additions & 0 deletions
78
src/main/java/de/hysky/skyblocker/skyblock/LanternDeployable.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,78 @@ | ||
| package de.hysky.skyblocker.skyblock; | ||
|
|
||
| import de.hysky.skyblocker.annotations.Init; | ||
| import de.hysky.skyblocker.config.SkyblockerConfigManager; | ||
| import de.hysky.skyblocker.utils.render.LevelRenderExtractionCallback; | ||
| import de.hysky.skyblocker.utils.render.Renderable; | ||
| import de.hysky.skyblocker.utils.render.primitive.PrimitiveCollector; | ||
|
|
||
| import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; | ||
| import net.minecraft.client.Minecraft; | ||
| import net.minecraft.world.entity.Entity; | ||
| import net.minecraft.world.entity.decoration.ArmorStand; | ||
| import net.minecraft.world.phys.Vec3; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
| import java.util.Locale; | ||
|
|
||
| public final class LanternDeployable implements Renderable { | ||
|
|
||
| public static final LanternDeployable INSTANCE = new LanternDeployable(); | ||
|
|
||
| private static final float RANGE = 30f; | ||
| private static final int SEGMENTS = 128; | ||
| private static final int COLOR = 0x5500FFFF; | ||
| private static final float CIRCLE_HEIGHT = 3f; | ||
|
|
||
| private final List<Vec3> lanternPositions = new ArrayList<>(); | ||
|
|
||
| @Init | ||
| public static void init() { | ||
|
|
||
| LevelRenderExtractionCallback.EVENT.register(INSTANCE::extractRendering); | ||
| ClientTickEvents.END_CLIENT_TICK.register(client -> { | ||
|
|
||
| if (client.level == null || client.player == null) { | ||
| INSTANCE.lanternPositions.clear(); | ||
| return; | ||
| } | ||
| INSTANCE.findLantern(); | ||
| }); | ||
| } | ||
|
|
||
| @Override | ||
| public void extractRendering(PrimitiveCollector collector) { | ||
| if (lanternPositions.isEmpty()) return; | ||
|
|
||
| if (!SkyblockerConfigManager.get().mining.lanternDeployable.showDeployableRange) return; | ||
|
|
||
| for (Vec3 position : lanternPositions) { | ||
|
|
||
| Vec3 circlePosition = position.add(0, CIRCLE_HEIGHT, 0); | ||
|
|
||
| collector.submitCylinder(circlePosition, RANGE, 0.5f, SEGMENTS, COLOR); | ||
| } | ||
| } | ||
|
|
||
| private void findLantern() { | ||
| Minecraft mc = Minecraft.getInstance(); | ||
| lanternPositions.clear(); | ||
|
|
||
| for (Entity entity : mc.level.entitiesForRendering()) { | ||
| if (!(entity instanceof ArmorStand armorStand)) continue; | ||
|
|
||
| if (isLantern(armorStand)) { | ||
| lanternPositions.add(Vec3.atCenterOf(armorStand.blockPosition().below())); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private boolean isLantern(ArmorStand armorStand) { | ||
| if (!armorStand.hasCustomName()) return false; | ||
|
|
||
| String name = armorStand.getName().getString().replaceAll("§.", "").toLowerCase(Locale.ENGLISH); | ||
|
|
||
| return name.contains("lantern") || name.contains("wisp"); | ||
| } | ||
| } |
97 changes: 97 additions & 0 deletions
97
src/main/java/de/hysky/skyblocker/skyblock/PowerOrbRange.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,97 @@ | ||
| package de.hysky.skyblocker.skyblock; | ||
|
|
||
| import de.hysky.skyblocker.annotations.Init; | ||
| import de.hysky.skyblocker.utils.render.LevelRenderExtractionCallback; | ||
| import de.hysky.skyblocker.utils.render.Renderable; | ||
| import de.hysky.skyblocker.utils.render.primitive.PrimitiveCollector; | ||
| import de.hysky.skyblocker.config.SkyblockerConfigManager; | ||
|
|
||
| import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; | ||
| import net.minecraft.client.Minecraft; | ||
| import net.minecraft.world.entity.Entity; | ||
| import net.minecraft.world.entity.decoration.ArmorStand; | ||
| import net.minecraft.world.phys.Vec3; | ||
|
|
||
| import java.util.Locale; | ||
|
|
||
| public final class PowerOrbRange implements Renderable { | ||
|
|
||
| public static final PowerOrbRange INSTANCE = new PowerOrbRange(); | ||
|
|
||
| private static final float RANGE = 18f; | ||
| private static final float CIRCLE_HEIGHT = 2f; | ||
| private static final int SEGMENTS = 128; | ||
| private static final int COLOR = 0x5500FFFF; | ||
|
|
||
| private Vec3 orbPosition; | ||
|
|
||
| @Init | ||
| public static void init() { | ||
|
|
||
| LevelRenderExtractionCallback.EVENT.register(INSTANCE::extractRendering); | ||
|
|
||
| ClientTickEvents.END_CLIENT_TICK.register(client -> { | ||
|
|
||
| if (client.level == null || client.player == null) { | ||
|
|
||
| INSTANCE.clearPosition(); | ||
| return; | ||
| } | ||
|
|
||
| INSTANCE.findOrb(); | ||
| }); | ||
| } | ||
|
|
||
| private void updatePosition(Vec3 pos) { | ||
| this.orbPosition = pos; | ||
| } | ||
|
|
||
| private void clearPosition() { | ||
| this.orbPosition = null; | ||
| } | ||
|
|
||
| @Override | ||
| public void extractRendering(PrimitiveCollector collector) { | ||
|
|
||
| if (orbPosition == null) { | ||
| return; | ||
| } | ||
|
|
||
| if (!SkyblockerConfigManager.get().helpers.showPowerOrbRange) { | ||
| return; | ||
| } | ||
|
|
||
| collector.submitCylinder(orbPosition, RANGE, 0.5f, SEGMENTS, COLOR); | ||
| } | ||
|
|
||
| private void findOrb() { | ||
|
|
||
| Minecraft mc = Minecraft.getInstance(); | ||
|
|
||
| if (mc.level == null) return; | ||
|
|
||
| for (Entity entity : mc.level.entitiesForRendering()) { | ||
|
|
||
| if (!(entity instanceof ArmorStand armorStand)) continue; | ||
|
|
||
| if (isOrb(armorStand)) { | ||
|
|
||
| Vec3 pos = armorStand.position().add(0, CIRCLE_HEIGHT, 0); | ||
|
|
||
| updatePosition(pos); | ||
| return; | ||
| } | ||
| } | ||
|
|
||
| clearPosition(); | ||
| } | ||
|
|
||
| private boolean isOrb(ArmorStand armorStand) { | ||
|
|
||
| if (!armorStand.hasCustomName()) return false; | ||
|
|
||
| String name = armorStand.getName().getString().replaceAll("§.", "").toLowerCase(Locale.ENGLISH); | ||
|
|
||
| return name.contains("radiant power orb") || name.contains("mana flux") || name.contains("manaflux") || name.contains("overflux") || name.contains("plasmaflux") || name.contains("plasma flux"); | ||
| } | ||
| } |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please find a better place to put this instead of a new module.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The question is if we want to see others or not?
As on now you the lates one placed will be shown