aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/SkyblockerMod.java2
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/config/SkyblockerConfig.java14
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/skyblock/EtherwarpOverlay.java54
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/skyblock/TeleportOverlay.java112
-rw-r--r--src/main/resources/assets/skyblocker/lang/en_us.json7
5 files changed, 133 insertions, 56 deletions
diff --git a/src/main/java/me/xmrvizzy/skyblocker/SkyblockerMod.java b/src/main/java/me/xmrvizzy/skyblocker/SkyblockerMod.java
index 50c60840..bd414acb 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/SkyblockerMod.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/SkyblockerMod.java
@@ -87,7 +87,7 @@ public class SkyblockerMod implements ClientModInitializer {
TheRift.init();
TitleContainer.init();
OcclusionCulling.init();
- EtherwarpOverlay.init();
+ TeleportOverlay.init();
containerSolverManager.init();
scheduler.scheduleCyclic(Utils::update, 20);
scheduler.scheduleCyclic(DiscordRPCManager::updateDataAndPresence, 100);
diff --git a/src/main/java/me/xmrvizzy/skyblocker/config/SkyblockerConfig.java b/src/main/java/me/xmrvizzy/skyblocker/config/SkyblockerConfig.java
index 6874f2ce..2cc7dd36 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/config/SkyblockerConfig.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/config/SkyblockerConfig.java
@@ -136,7 +136,6 @@ public class SkyblockerConfig implements ConfigData {
public boolean acceptReparty = true;
public boolean backpackPreviewWithoutShift = false;
public boolean hideEmptyTooltips = true;
- public boolean etherwarpOverlay = true;
@ConfigEntry.Category("tabHud")
@ConfigEntry.Gui.CollapsibleObject()
@@ -182,6 +181,10 @@ public class SkyblockerConfig implements ConfigData {
@ConfigEntry.Gui.CollapsibleObject()
public TitleContainer titleContainer = new TitleContainer();
+ @ConfigEntry.Category("Teleport Overlay")
+ @ConfigEntry.Gui.CollapsibleObject()
+ public TeleportOverlay teleportOverlay = new TeleportOverlay();
+
@ConfigEntry.Gui.Excluded
public List<Integer> lockedSlots = new ArrayList<>();
}
@@ -293,6 +296,15 @@ public class SkyblockerConfig implements ConfigData {
public Alignment alignment = Alignment.MIDDLE;
}
+ public static class TeleportOverlay {
+ public boolean enableTeleportOverlays = true;
+ public boolean enableWeirdTransmission = true;
+ public boolean enableInstantTransmission = true;
+ public boolean enableEtherTransmission = true;
+ public boolean enableSinrecallTransmission = true;
+ public boolean enableWitherImpact = true;
+ }
+
public enum Direction {
HORIZONTAL,
VERTICAL;
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/EtherwarpOverlay.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/EtherwarpOverlay.java
deleted file mode 100644
index 005b3d64..00000000
--- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/EtherwarpOverlay.java
+++ /dev/null
@@ -1,54 +0,0 @@
-package me.xmrvizzy.skyblocker.skyblock;
-
-import com.mojang.blaze3d.systems.RenderSystem;
-
-import me.xmrvizzy.skyblocker.config.SkyblockerConfig;
-import me.xmrvizzy.skyblocker.skyblock.item.PriceInfoTooltip;
-import me.xmrvizzy.skyblocker.utils.RenderHelper;
-import me.xmrvizzy.skyblocker.utils.Utils;
-import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext;
-import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents;
-import net.minecraft.block.BlockState;
-import net.minecraft.block.Blocks;
-import net.minecraft.client.MinecraftClient;
-import net.minecraft.item.ItemStack;
-import net.minecraft.nbt.NbtCompound;
-import net.minecraft.util.hit.BlockHitResult;
-import net.minecraft.util.hit.HitResult;
-import net.minecraft.util.math.BlockPos;
-
-public class EtherwarpOverlay {
- private static final MinecraftClient CLIENT = MinecraftClient.getInstance();
- private static final float[] COLOR_COMPONENTS = { 118f / 255f, 21f / 255f, 148f / 255f };
-
- public static void init() {
- WorldRenderEvents.AFTER_TRANSLUCENT.register(EtherwarpOverlay::renderEtherwarpOverlay);
- }
-
- private static void renderEtherwarpOverlay(WorldRenderContext wrc) {
- if (Utils.isOnSkyblock() && SkyblockerConfig.get().general.etherwarpOverlay) {
- ItemStack heldItem = CLIENT.player.getMainHandStack();
- String itemId = PriceInfoTooltip.getInternalNameFromNBT(heldItem);
- NbtCompound nbt = heldItem.getNbt();
-
- if (itemId != null && (((itemId.equals("ASPECT_OF_THE_VOID") || itemId.equals("ASPECT_OF_THE_END")) && nbt.getCompound("ExtraAttributes").getInt("ethermerge") == 1 && CLIENT.options.sneakKey.isPressed()) || itemId.equals("ETHERWARP_CONDUIT"))) {
- int range = (nbt.getCompound("ExtraAttributes").contains("tuned_transmission")) ? 57 + nbt.getCompound("ExtraAttributes").getInt("tuned_transmission") : 57;
- HitResult result = CLIENT.player.raycast(range, wrc.tickDelta(), false);
-
- if (result instanceof BlockHitResult blockHit) {
- BlockPos pos = blockHit.getBlockPos();
- BlockState state = CLIENT.world.getBlockState(pos);
- if (state.getBlock() != Blocks.AIR && CLIENT.world.getBlockState(pos.up()).getBlock() == Blocks.AIR && CLIENT.world.getBlockState(pos.up(2)).getBlock() == Blocks.AIR) {
- RenderSystem.polygonOffset(-1f, -10f);
- RenderSystem.enablePolygonOffset();
-
- RenderHelper.renderFilledIfVisible(wrc, pos, COLOR_COMPONENTS, 0.5f);
-
- RenderSystem.polygonOffset(0f, 0f);
- RenderSystem.disablePolygonOffset();
- }
- }
- }
- }
- }
-}
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/TeleportOverlay.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/TeleportOverlay.java
new file mode 100644
index 00000000..e7c76160
--- /dev/null
+++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/TeleportOverlay.java
@@ -0,0 +1,112 @@
+package me.xmrvizzy.skyblocker.skyblock;
+
+import com.mojang.blaze3d.systems.RenderSystem;
+import me.xmrvizzy.skyblocker.config.SkyblockerConfig;
+import me.xmrvizzy.skyblocker.skyblock.item.PriceInfoTooltip;
+import me.xmrvizzy.skyblocker.utils.RenderHelper;
+import me.xmrvizzy.skyblocker.utils.Utils;
+import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext;
+import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents;
+import net.minecraft.block.BlockState;
+import net.minecraft.client.MinecraftClient;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NbtCompound;
+import net.minecraft.util.hit.BlockHitResult;
+import net.minecraft.util.hit.HitResult;
+import net.minecraft.util.math.BlockPos;
+
+public class TeleportOverlay {
+ private static final float[] COLOR_COMPONENTS = {118f / 255f, 21f / 255f, 148f / 255f};
+ private static final MinecraftClient client = MinecraftClient.getInstance();
+
+ public static void init() {
+ WorldRenderEvents.AFTER_TRANSLUCENT.register(TeleportOverlay::render);
+ }
+
+ private static void render(WorldRenderContext wrc) {
+ if (Utils.isOnSkyblock() && SkyblockerConfig.get().general.teleportOverlay.enableTeleportOverlays && client.player != null && client.world != null) {
+ ItemStack heldItem = client.player.getMainHandStack();
+ String itemId = PriceInfoTooltip.getInternalNameFromNBT(heldItem);
+ NbtCompound nbt = heldItem.getNbt();
+
+ if (itemId != null) {
+ switch (itemId) {
+ case "ASPECT_OF_THE_LEECH_1" -> {
+ if (SkyblockerConfig.get().general.teleportOverlay.enableWeirdTransmission) {
+ render(wrc, 3);
+ }
+ }
+ case "ASPECT_OF_THE_LEECH_2" -> {
+ if (SkyblockerConfig.get().general.teleportOverlay.enableWeirdTransmission) {
+ render(wrc, 4);
+ }
+ }
+ case "ASPECT_OF_THE_END", "ASPECT_OF_THE_VOID" -> {
+ if (SkyblockerConfig.get().general.teleportOverlay.enableEtherTransmission && client.options.sneakKey.isPressed() && nbt != null && nbt.getCompound("ExtraAttributes").getInt("ethermerge") == 1) {
+ render(wrc, nbt, 57);
+ } else if (SkyblockerConfig.get().general.teleportOverlay.enableInstantTransmission) {
+ render(wrc, nbt, 8);
+ }
+ }
+ case "ETHERWARP_CONDUIT" -> {
+ if (SkyblockerConfig.get().general.teleportOverlay.enableEtherTransmission) {
+ render(wrc, nbt, 57);
+ }
+ }
+ case "SINSEEKER_SCYTHE" -> {
+ if (SkyblockerConfig.get().general.teleportOverlay.enableSinrecallTransmission) {
+ render(wrc, nbt, 4);
+ }
+ }
+ case "NECRON_BLADE", "ASTRAEA", "HYPERION", "SCYLLA", "VALKYRIE" -> {
+ if (SkyblockerConfig.get().general.teleportOverlay.enableWitherImpact) {
+ render(wrc, 10);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Renders the teleport overlay with a given base range and the tuned transmission stat.
+ */
+ private static void render(WorldRenderContext wrc, NbtCompound nbt, int baseRange) {
+ render(wrc, nbt != null && nbt.getCompound("ExtraAttributes").contains("tuned_transmission") ? baseRange + nbt.getCompound("ExtraAttributes").getInt("tuned_transmission") : baseRange);
+ }
+
+ /**
+ * Renders the teleport overlay with a given range. Uses {@link MinecraftClient#crosshairTarget} if it is a block and within range. Otherwise, raycasts from the player with the given range.
+ * @implNote {@link MinecraftClient#player} and {@link MinecraftClient#world} must not be null when calling this method.
+ */
+ private static void render(WorldRenderContext wrc, int range) {
+ if (client.crosshairTarget != null && client.crosshairTarget.getType() == HitResult.Type.BLOCK && client.crosshairTarget instanceof BlockHitResult blockHitResult && client.crosshairTarget.squaredDistanceTo(client.player) < range * range) {
+ render(wrc, blockHitResult);
+ } else if (client.interactionManager != null && range > client.interactionManager.getReachDistance()) {
+ @SuppressWarnings("DataFlowIssue")
+ HitResult result = client.player.raycast(range, wrc.tickDelta(), false);
+ if (result.getType() == HitResult.Type.BLOCK && result instanceof BlockHitResult blockHitResult) {
+ render(wrc, blockHitResult);
+ }
+ }
+ }
+
+ /**
+ * Renders the teleport overlay at the given {@link BlockHitResult}.
+ * @implNote {@link MinecraftClient#world} must not be null when calling this method.
+ */
+ private static void render(WorldRenderContext wrc, BlockHitResult blockHitResult) {
+ BlockPos pos = blockHitResult.getBlockPos();
+ @SuppressWarnings("DataFlowIssue")
+ BlockState state = client.world.getBlockState(pos);
+ if (!state.isAir() && client.world.getBlockState(pos.up()).isAir() && client.world.getBlockState(pos.up(2)).isAir()) {
+ RenderSystem.polygonOffset(-1f, -10f);
+ RenderSystem.enablePolygonOffset();
+
+ RenderHelper.renderFilledIfVisible(wrc, pos, COLOR_COMPONENTS, 0.5f);
+
+ RenderSystem.polygonOffset(0f, 0f);
+ RenderSystem.disablePolygonOffset();
+ }
+ }
+}
diff --git a/src/main/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json
index 736f5872..8e8de38a 100644
--- a/src/main/resources/assets/skyblocker/lang/en_us.json
+++ b/src/main/resources/assets/skyblocker/lang/en_us.json
@@ -71,6 +71,13 @@
"text.autoconfig.skyblocker.option.general.titleContainer.y": "Title Container Y Position",
"text.autoconfig.skyblocker.option.general.titleContainer.direction": "Title Container Orientation",
"text.autoconfig.skyblocker.option.general.titleContainer.alignment": "Title Container Horizontal Alignment",
+ "text.autoconfig.skyblocker.option.general.teleportOverlay": "Teleport Overlay",
+ "text.autoconfig.skyblocker.option.general.teleportOverlay.enableTeleportOverlays": "Enable Teleport Overlays",
+ "text.autoconfig.skyblocker.option.general.teleportOverlay.enableWeirdTransmission": "Enable Weird Transmission Overlay",
+ "text.autoconfig.skyblocker.option.general.teleportOverlay.enableInstantTransmission": "Enable Instant Transmission Overlay",
+ "text.autoconfig.skyblocker.option.general.teleportOverlay.enableEtherTransmission": "Enable Ether Transmission Overlay",
+ "text.autoconfig.skyblocker.option.general.teleportOverlay.enableSinrecallTransmission": "Enable Sinrecall Transmission Overlay",
+ "text.autoconfig.skyblocker.option.general.teleportOverlay.enableWitherImpact": "Enable Wither Impact Overlay",
"skyblocker.itemTooltip.nullMessage": "§b[§6Skyblocker§b] §cItem price information on tooltip will renew in max 60 seconds. If not, check latest.log",
"skyblocker.itemTooltip.noData": "§cNo Data",