From 384f75a5aec98713d719f01662fc95464bed84f3 Mon Sep 17 00:00:00 2001 From: Aaron <51387595+AzureAaron@users.noreply.github.com> Date: Mon, 26 Jun 2023 02:24:56 -0400 Subject: Add Mirrorverse Waypoints + Rift Fixes --- .../java/me/xmrvizzy/skyblocker/SkyblockerMod.java | 2 + .../skyblocker/config/SkyblockerConfig.java | 8 + .../xmrvizzy/skyblocker/mixin/InGameHudMixin.java | 7 +- .../skyblocker/mixin/accessor/FrustumInvoker.java | 17 + .../skyblocker/skyblock/FancyStatusBars.java | 5 +- .../skyblocker/skyblock/dungeon/Trivia.java | 4 +- .../skyblock/rift/MirrorverseWaypoints.java | 101 ++ .../xmrvizzy/skyblocker/skyblock/rift/TheRift.java | 11 + .../resources/assets/skyblocker/lang/en_us.json | 3 + .../assets/skyblocker/mirrorverse_waypoints.json | 1019 ++++++++++++++++++++ src/main/resources/skyblocker.mixins.json | 3 +- 11 files changed, 1173 insertions(+), 7 deletions(-) create mode 100644 src/main/java/me/xmrvizzy/skyblocker/mixin/accessor/FrustumInvoker.java create mode 100644 src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/MirrorverseWaypoints.java create mode 100644 src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/TheRift.java create mode 100644 src/main/resources/assets/skyblocker/mirrorverse_waypoints.json (limited to 'src') diff --git a/src/main/java/me/xmrvizzy/skyblocker/SkyblockerMod.java b/src/main/java/me/xmrvizzy/skyblocker/SkyblockerMod.java index add81791..a629f851 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/SkyblockerMod.java +++ b/src/main/java/me/xmrvizzy/skyblocker/SkyblockerMod.java @@ -16,6 +16,7 @@ import me.xmrvizzy.skyblocker.skyblock.item.PriceInfoTooltip; import me.xmrvizzy.skyblocker.skyblock.item.WikiLookup; import me.xmrvizzy.skyblocker.skyblock.itemlist.ItemRegistry; import me.xmrvizzy.skyblocker.skyblock.quicknav.QuickNav; +import me.xmrvizzy.skyblocker.skyblock.rift.TheRift; import me.xmrvizzy.skyblocker.skyblock.tabhud.TabHud; import me.xmrvizzy.skyblocker.skyblock.tabhud.util.PlayerListMgr; import me.xmrvizzy.skyblocker.utils.*; @@ -82,6 +83,7 @@ public class SkyblockerMod implements ClientModInitializer { FairySouls.init(); TabHud.init(); DungeonMap.init(); + TheRift.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 5621a258..988f5f77 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/config/SkyblockerConfig.java +++ b/src/main/java/me/xmrvizzy/skyblocker/config/SkyblockerConfig.java @@ -289,6 +289,10 @@ public class SkyblockerConfig implements ConfigData { @ConfigEntry.Category("dwarvenmines") @ConfigEntry.Gui.CollapsibleObject() public DwarvenMines dwarvenMines = new DwarvenMines(); + + @ConfigEntry.Category("rift") + @ConfigEntry.Gui.CollapsibleObject() + public Rift rift = new Rift(); } public static class Dungeons { @@ -357,6 +361,10 @@ public class SkyblockerConfig implements ConfigData { public boolean solveHungryHiker = true; public boolean solveTreasureHunter = true; } + + public static class Rift { + public boolean mirrorverseWaypoints = true; + } public static class Messages { @ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON) diff --git a/src/main/java/me/xmrvizzy/skyblocker/mixin/InGameHudMixin.java b/src/main/java/me/xmrvizzy/skyblocker/mixin/InGameHudMixin.java index 335737a1..4c89d497 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/mixin/InGameHudMixin.java +++ b/src/main/java/me/xmrvizzy/skyblocker/mixin/InGameHudMixin.java @@ -6,6 +6,7 @@ import me.xmrvizzy.skyblocker.skyblock.FancyStatusBars; import me.xmrvizzy.skyblocker.skyblock.HotbarSlotLock; import me.xmrvizzy.skyblocker.skyblock.StatusBarTracker; import me.xmrvizzy.skyblocker.skyblock.dungeon.DungeonMap; +import me.xmrvizzy.skyblocker.skyblock.rift.TheRift; import me.xmrvizzy.skyblocker.utils.Utils; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; @@ -53,7 +54,7 @@ public abstract class InGameHudMixin { @Inject(method = "setOverlayMessage(Lnet/minecraft/text/Text;Z)V", at = @At("HEAD"), cancellable = true) private void skyblocker$onSetOverlayMessage(Text message, boolean tinted, CallbackInfo ci) { - if (!Utils.isOnSkyblock() || !SkyblockerConfig.get().general.bars.enableBars) + if (!Utils.isOnSkyblock() || !SkyblockerConfig.get().general.bars.enableBars || Utils.getLocationRaw().equals(TheRift.LOCATION)) return; String msg = message.getString(); String res = statusBarTracker.update(msg, SkyblockerConfig.get().messages.hideMana); @@ -84,7 +85,7 @@ public abstract class InGameHudMixin { @Inject(method = "renderExperienceBar", at = @At("HEAD"), cancellable = true) private void skyblocker$renderExperienceBar(DrawContext context, int x, CallbackInfo ci) { - if (Utils.isOnSkyblock() && SkyblockerConfig.get().general.bars.enableBars) + if (Utils.isOnSkyblock() && SkyblockerConfig.get().general.bars.enableBars && !Utils.getLocationRaw().equals(TheRift.LOCATION)) ci.cancel(); } @@ -103,7 +104,7 @@ public abstract class InGameHudMixin { @Inject(method = "renderMountHealth", at = @At("HEAD"), cancellable = true) private void skyblocker$renderMountHealth(DrawContext context, CallbackInfo ci) { - if (Utils.isOnSkyblock() && SkyblockerConfig.get().general.bars.enableBars) + if (Utils.isOnSkyblock() && SkyblockerConfig.get().general.bars.enableBars && !Utils.getLocationRaw().equals(TheRift.LOCATION)) ci.cancel(); } } \ No newline at end of file diff --git a/src/main/java/me/xmrvizzy/skyblocker/mixin/accessor/FrustumInvoker.java b/src/main/java/me/xmrvizzy/skyblocker/mixin/accessor/FrustumInvoker.java new file mode 100644 index 00000000..f086b9e5 --- /dev/null +++ b/src/main/java/me/xmrvizzy/skyblocker/mixin/accessor/FrustumInvoker.java @@ -0,0 +1,17 @@ +package me.xmrvizzy.skyblocker.mixin.accessor; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Invoker; + +import net.minecraft.client.render.Frustum; + +/** + * For the purpose of avoiding object allocations! + * + */ +@Mixin(Frustum.class) +public interface FrustumInvoker { + + @Invoker("isVisible") + public boolean isVisible(double minX, double minY, double minZ, double maxX, double maxY, double maxZ); +} diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/FancyStatusBars.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/FancyStatusBars.java index 6af06e6d..8e0d43da 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/FancyStatusBars.java +++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/FancyStatusBars.java @@ -2,6 +2,8 @@ package me.xmrvizzy.skyblocker.skyblock; import me.xmrvizzy.skyblocker.SkyblockerMod; import me.xmrvizzy.skyblocker.config.SkyblockerConfig; +import me.xmrvizzy.skyblocker.skyblock.rift.TheRift; +import me.xmrvizzy.skyblocker.utils.Utils; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.DrawContext; @@ -9,6 +11,7 @@ import net.minecraft.util.Identifier; public class FancyStatusBars { private static final Identifier BARS = new Identifier(SkyblockerMod.NAMESPACE, "textures/gui/bars.png"); + private static final String RIFT_LOCATION = "rift"; private final MinecraftClient client = MinecraftClient.getInstance(); private final StatusBarTracker statusBarTracker = SkyblockerMod.getInstance().statusBarTracker; @@ -39,7 +42,7 @@ public class FancyStatusBars { public boolean render(DrawContext context, int scaledWidth, int scaledHeight) { var player = client.player; - if (!SkyblockerConfig.get().general.bars.enableBars || player == null) + if (!SkyblockerConfig.get().general.bars.enableBars || player == null || Utils.getLocationRaw().equals(TheRift.LOCATION)) return false; anchorsX[0] = scaledWidth / 2 - 91; anchorsY[0] = scaledHeight - 33; diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/dungeon/Trivia.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/dungeon/Trivia.java index 10a2e413..f7598af5 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/dungeon/Trivia.java +++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/dungeon/Trivia.java @@ -69,7 +69,7 @@ public class Trivia extends ChatPatternListener { answers.put("What is the status of Storm?", new String[]{"The Wither Lords"}); answers.put("What is the status of Necron?", new String[]{"The Wither Lords"}); answers.put("What is the status of Maxor, Storm, Goldor and Necron?", new String[]{"The Wither Lords"}); - answers.put("How many total Fairy Souls are there?", new String[]{"240 Fairy Souls"}); + answers.put("How many total Fairy Souls are there?", new String[]{"242 Fairy Souls"}); answers.put("How many Fairy Souls are there in Spider's Den?", new String[]{"19 Fairy Souls"}); answers.put("How many Fairy Souls are there in The End?", new String[]{"12 Fairy Souls"}); answers.put("How many Fairy Souls are there in The Farming Islands?", new String[]{"20 Fairy Souls"}); @@ -87,7 +87,7 @@ public class Trivia extends ChatPatternListener { answers.put("What is the name of the person that upgrades pets?", new String[]{"Kat"}); answers.put("What is the name of the lady of the Nether?", new String[]{"Elle"}); answers.put("Which villager in the Village gives you a Rogue Sword?", new String[]{"Jamie"}); - answers.put("How many unique minions are there?", new String[]{"58 Minions"}); + answers.put("How many unique minions are there?", new String[]{"59 Minions"}); answers.put("Which of these enemies does not spawn in the Spider's Den?", new String[]{"Zombie Spider", "Cave Spider", "Wither Skeleton", "Dashing Spooder", "Broodfather", "Night Spider"}); answers.put("Which of these monsters only spawns at night?", new String[]{"Zombie Villager", "Ghast"}); diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/MirrorverseWaypoints.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/MirrorverseWaypoints.java new file mode 100644 index 00000000..c0493d18 --- /dev/null +++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/MirrorverseWaypoints.java @@ -0,0 +1,101 @@ +package me.xmrvizzy.skyblocker.skyblock.rift; + +import java.awt.Color; +import java.io.BufferedReader; +import java.io.IOException; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; + +import me.x150.renderer.render.Renderer3d; +import me.xmrvizzy.skyblocker.config.SkyblockerConfig; +import me.xmrvizzy.skyblocker.mixin.accessor.FrustumInvoker; +import me.xmrvizzy.skyblocker.utils.FrustumUtils; +import me.xmrvizzy.skyblocker.utils.Utils; +import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext; +import net.minecraft.client.MinecraftClient; +import net.minecraft.util.DyeColor; +import net.minecraft.util.Identifier; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3d; + +public class MirrorverseWaypoints { + private static final Logger LOGGER = LoggerFactory.getLogger("skyblocker"); + private static final MinecraftClient CLIENT = MinecraftClient.getInstance(); + private static final Identifier WAYPOINTS_JSON = new Identifier("skyblocker", "mirrorverse_waypoints.json"); + private static final BlockPos[] LAVA_PATH_WAYPOINTS = new BlockPos[107]; + private static final BlockPos[] UPSIDE_DOWN_WAYPOINTS = new BlockPos[66]; + private static final BlockPos[] TURBULATOR_WAYPOINTS = new BlockPos[27]; + private static final float[] COLOR_COMPONENTS = DyeColor.RED.getColorComponents(); + private static final Vec3d ONE = new Vec3d(1, 1, 1); + + static { + loadWaypoints(); + } + + /** + * Loads the waypoint locations into memory + */ + public static void loadWaypoints() { + try(BufferedReader reader = CLIENT.getResourceManager().openAsReader(WAYPOINTS_JSON)) { + JsonObject file = JsonParser.parseReader(reader).getAsJsonObject(); + JsonArray sections = file.get("sections").getAsJsonArray(); + + /// Lava Path + JsonArray lavaPathWaypoints = sections.get(0).getAsJsonObject().get("waypoints").getAsJsonArray(); + + for(int i = 0; i < lavaPathWaypoints.size(); i++) { + JsonObject point = lavaPathWaypoints.get(i).getAsJsonObject(); + LAVA_PATH_WAYPOINTS[i] = new BlockPos(point.get("x").getAsInt(), point.get("y").getAsInt(), point.get("z").getAsInt()); + } + + /// Upside Down Parkour + JsonArray upsideDownParkourWaypoints = sections.get(1).getAsJsonObject().get("waypoints").getAsJsonArray(); + + for(int i = 0; i < upsideDownParkourWaypoints.size(); i++) { + JsonObject point = upsideDownParkourWaypoints.get(i).getAsJsonObject(); + UPSIDE_DOWN_WAYPOINTS[i] = new BlockPos(point.get("x").getAsInt(), point.get("y").getAsInt(), point.get("z").getAsInt()); + } + + /// Turbulator Parkour + JsonArray turbulatorParkourWaypoints = sections.get(2).getAsJsonObject().get("waypoints").getAsJsonArray(); + + for(int i = 0; i < turbulatorParkourWaypoints.size(); i++) { + JsonObject point = turbulatorParkourWaypoints.get(i).getAsJsonObject(); + TURBULATOR_WAYPOINTS[i] = new BlockPos(point.get("x").getAsInt(), point.get("y").getAsInt(), point.get("z").getAsInt()); + } + + } catch (IOException e) { + LOGGER.info("[Skyblocker] Mirrorverse Waypoints failed to load ;("); + e.printStackTrace(); + } + } + + public static void render(WorldRenderContext wrc) { + FrustumInvoker frustum = ((FrustumInvoker) FrustumUtils.getFrustum()); + //I would also check for the mirrorverse location but the scoreboard stuff is not performant at all... + if(Utils.getLocationRaw().equals(TheRift.LOCATION) && SkyblockerConfig.get().locations.rift.mirrorverseWaypoints) { + for(BlockPos pos : LAVA_PATH_WAYPOINTS) { + if(frustum.isVisible(pos.getX(), pos.getY(), pos.getZ(), pos.getX() + 1, pos.getY() + 1, pos.getZ() + 1)) { + Renderer3d.renderFilled(wrc.matrixStack(), new Color(COLOR_COMPONENTS[0], COLOR_COMPONENTS[1], COLOR_COMPONENTS[2], 0.5f), Vec3d.of(pos), ONE); + }; + } + + for(BlockPos pos : UPSIDE_DOWN_WAYPOINTS) { + if(frustum.isVisible(pos.getX(), pos.getY(), pos.getZ(), pos.getX() + 1, pos.getY() + 1, pos.getZ() + 1)) { + Renderer3d.renderFilled(wrc.matrixStack(), new Color(COLOR_COMPONENTS[0], COLOR_COMPONENTS[1], COLOR_COMPONENTS[2], 0.5f), Vec3d.of(pos), ONE); + }; + } + + for(BlockPos pos : TURBULATOR_WAYPOINTS) { + if(frustum.isVisible(pos.getX(), pos.getY(), pos.getZ(), pos.getX() + 1, pos.getY() + 1, pos.getZ() + 1)) { + Renderer3d.renderFilled(wrc.matrixStack(), new Color(COLOR_COMPONENTS[0], COLOR_COMPONENTS[1], COLOR_COMPONENTS[2], 0.5f), Vec3d.of(pos), ONE); + }; + } + } + } +} diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/TheRift.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/TheRift.java new file mode 100644 index 00000000..24f92238 --- /dev/null +++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/TheRift.java @@ -0,0 +1,11 @@ +package me.xmrvizzy.skyblocker.skyblock.rift; + +import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents; + +public class TheRift { + public static final String LOCATION = "rift"; + + public static void init() { + WorldRenderEvents.AFTER_TRANSLUCENT.register(MirrorverseWaypoints::render); + } +} diff --git a/src/main/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json index f2eec8fd..d18e180e 100644 --- a/src/main/resources/assets/skyblocker/lang/en_us.json +++ b/src/main/resources/assets/skyblocker/lang/en_us.json @@ -200,6 +200,9 @@ "text.autoconfig.skyblocker.option.locations.dwarvenMines.dwarvenHud.enableBackground": "Enable Background", "text.autoconfig.skyblocker.option.locations.dwarvenMines.dwarvenHud.x": "X", "text.autoconfig.skyblocker.option.locations.dwarvenMines.dwarvenHud.y": "Y", + + "text.autoconfig.skyblocker.option.locations.rift": "The Rift", + "text.autoconfig.skyblocker.option.locations.rift.mirrorverseWaypoints": "Enable Mirrorverse Waypoints", "text.autoconfig.skyblocker.category.messages": "Messages", "text.autoconfig.skyblocker.option.messages.chatFilterResult.PASS": "Disabled", diff --git a/src/main/resources/assets/skyblocker/mirrorverse_waypoints.json b/src/main/resources/assets/skyblocker/mirrorverse_waypoints.json new file mode 100644 index 00000000..2bc0296e --- /dev/null +++ b/src/main/resources/assets/skyblocker/mirrorverse_waypoints.json @@ -0,0 +1,1019 @@ +{ + "sections": [ + { + "name": "Lava Path", + "waypoints": [ + { + "x": -101, + "y": 52, + "z": -116 + }, + { + "x": -99, + "y": 52, + "z": -110 + }, + { + "x": -95, + "y": 52, + "z": -108 + }, + { + "x": -88, + "y": 52, + "z": -107 + }, + { + "x": -95, + "y": 52, + "z": -114 + }, + { + "x": -95, + "y": 52, + "z": -109 + }, + { + "x": -84, + "y": 52, + "z": -112 + }, + { + "x": -91, + "y": 52, + "z": -108 + }, + { + "x": -94, + "y": 52, + "z": -116 + }, + { + "x": -88, + "y": 52, + "z": -112 + }, + { + "x": -101, + "y": 52, + "z": -108 + }, + { + "x": -94, + "y": 52, + "z": -114 + }, + { + "x": -85, + "y": 52, + "z": -112 + }, + { + "x": -88, + "y": 52, + "z": -114 + }, + { + "x": -90, + "y": 52, + "z": -110 + }, + { + "x": -84, + "y": 52, + "z": -113 + }, + { + "x": -90, + "y": 52, + "z": -116 + }, + { + "x": -105, + "y": 52, + "z": -113 + }, + { + "x": -82, + "y": 52, + "z": -112 + }, + { + "x": -90, + "y": 52, + "z": -112 + }, + { + "x": -88, + "y": 52, + "z": -111 + }, + { + "x": -82, + "y": 52, + "z": -111 + }, + { + "x": -104, + "y": 52, + "z": -112 + }, + { + "x": -87, + "y": 52, + "z": -107 + }, + { + "x": -100, + "y": 52, + "z": -108 + }, + { + "x": -86, + "y": 52, + "z": -109 + }, + { + "x": -91, + "y": 52, + "z": -110 + }, + { + "x": -96, + "y": 52, + "z": -108 + }, + { + "x": -102, + "y": 52, + "z": -111 + }, + { + "x": -96, + "y": 52, + "z": -115 + }, + { + "x": -97, + "y": 52, + "z": -116 + }, + { + "x": -83, + "y": 52, + "z": -111 + }, + { + "x": -84, + "y": 52, + "z": -107 + }, + { + "x": -90, + "y": 52, + "z": -115 + }, + { + "x": -86, + "y": 52, + "z": -107 + }, + { + "x": -97, + "y": 52, + "z": -112 + }, + { + "x": -86, + "y": 52, + "z": -113 + }, + { + "x": -92, + "y": 52, + "z": -110 + }, + { + "x": -95, + "y": 52, + "z": -111 + }, + { + "x": -90, + "y": 52, + "z": -114 + }, + { + "x": -93, + "y": 52, + "z": -108 + }, + { + "x": -98, + "y": 52, + "z": -116 + }, + { + "x": -98, + "y": 52, + "z": -115 + }, + { + "x": -90, + "y": 52, + "z": -107 + }, + { + "x": -98, + "y": 52, + "z": -112 + }, + { + "x": -98, + "y": 52, + "z": -109 + }, + { + "x": -98, + "y": 52, + "z": -113 + }, + { + "x": -100, + "y": 52, + "z": -116 + }, + { + "x": -96, + "y": 52, + "z": -114 + }, + { + "x": -86, + "y": 52, + "z": -110 + }, + { + "x": -93, + "y": 52, + "z": -109 + }, + { + "x": -88, + "y": 52, + "z": -110 + }, + { + "x": -94, + "y": 52, + "z": -115 + }, + { + "x": -84, + "y": 52, + "z": -111 + }, + { + "x": -84, + "y": 52, + "z": -108 + }, + { + "x": -86, + "y": 52, + "z": -115 + }, + { + "x": -98, + "y": 52, + "z": -110 + }, + { + "x": -102, + "y": 52, + "z": -108 + }, + { + "x": -92, + "y": 52, + "z": -114 + }, + { + "x": -102, + "y": 52, + "z": -114 + }, + { + "x": -85, + "y": 52, + "z": -109 + }, + { + "x": -86, + "y": 52, + "z": -112 + }, + { + "x": -104, + "y": 52, + "z": -113 + }, + { + "x": -105, + "y": 52, + "z": -112 + }, + { + "x": -91, + "y": 52, + "z": -114 + }, + { + "x": -100, + "y": 52, + "z": -112 + }, + { + "x": -93, + "y": 52, + "z": -110 + }, + { + "x": -91, + "y": 52, + "z": -112 + }, + { + "x": -101, + "y": 52, + "z": -112 + }, + { + "x": -92, + "y": 52, + "z": -108 + }, + { + "x": -82, + "y": 52, + "z": -113 + }, + { + "x": -87, + "y": 52, + "z": -115 + }, + { + "x": -84, + "y": 52, + "z": -109 + }, + { + "x": -88, + "y": 52, + "z": -113 + }, + { + "x": -92, + "y": 52, + "z": -116 + }, + { + "x": -96, + "y": 52, + "z": -111 + }, + { + "x": -96, + "y": 52, + "z": -116 + }, + { + "x": -98, + "y": 52, + "z": -108 + }, + { + "x": -98, + "y": 52, + "z": -114 + }, + { + "x": -96, + "y": 52, + "z": -112 + }, + { + "x": -85, + "y": 52, + "z": -107 + }, + { + "x": -102, + "y": 52, + "z": -115 + }, + { + "x": -87, + "y": 52, + "z": -110 + }, + { + "x": -100, + "y": 52, + "z": -113 + }, + { + "x": -103, + "y": 52, + "z": -114 + }, + { + "x": -102, + "y": 52, + "z": -116 + }, + { + "x": -95, + "y": 52, + "z": -110 + }, + { + "x": -89, + "y": 52, + "z": -107 + }, + { + "x": -92, + "y": 52, + "z": -113 + }, + { + "x": -100, + "y": 52, + "z": -110 + }, + { + "x": -100, + "y": 52, + "z": -115 + }, + { + "x": -86, + "y": 52, + "z": -114 + }, + { + "x": -88, + "y": 52, + "z": -115 + }, + { + "x": -92, + "y": 52, + "z": -112 + }, + { + "x": -100, + "y": 52, + "z": -114 + }, + { + "x": -91, + "y": 52, + "z": -116 + }, + { + "x": -102, + "y": 52, + "z": -110 + }, + { + "x": -102, + "y": 52, + "z": -112 + }, + { + "x": -93, + "y": 52, + "z": -116 + }, + { + "x": -90, + "y": 52, + "z": -111 + }, + { + "x": -104, + "y": 52, + "z": -114 + }, + { + "x": -83, + "y": 52, + "z": -112 + }, + { + "x": -83, + "y": 52, + "z": -113 + }, + { + "x": -100, + "y": 52, + "z": -109 + }, + { + "x": -102, + "y": 52, + "z": -109 + }, + { + "x": -90, + "y": 52, + "z": -108 + }, + { + "x": -97, + "y": 52, + "z": -108 + } + ] + }, + { + "name": "Upside Down Parkour", + "waypoints": [ + { + "x": -137, + "y": 39, + "z": -104 + }, + { + "x": -169, + "y": 42, + "z": -116 + }, + { + "x": -173, + "y": 43, + "z": -112 + }, + { + "x": -197, + "y": 39, + "z": -92 + }, + { + "x": -161, + "y": 39, + "z": -92 + }, + { + "x": -137, + "y": 40, + "z": -116 + }, + { + "x": -213, + "y": 41, + "z": -116 + }, + { + "x": -173, + "y": 41, + "z": -96 + }, + { + "x": -205, + "y": 41, + "z": -100 + }, + { + "x": -205, + "y": 43, + "z": -108 + }, + { + "x": -137, + "y": 41, + "z": -96 + }, + { + "x": -145, + "y": 40, + "z": -104 + }, + { + "x": -149, + "y": 43, + "z": -112 + }, + { + "x": -189, + "y": 42, + "z": -120 + }, + { + "x": -157, + "y": 41, + "z": -104 + }, + { + "x": -189, + "y": 43, + "z": -116 + }, + { + "x": -193, + "y": 42, + "z": -104 + }, + { + "x": -161, + "y": 40, + "z": -120 + }, + { + "x": -221, + "y": 43, + "z": -104 + }, + { + "x": -185, + "y": 41, + "z": -108 + }, + { + "x": -141, + "y": 41, + "z": -120 + }, + { + "x": -157, + "y": 39, + "z": -116 + }, + { + "x": -153, + "y": 40, + "z": -100 + }, + { + "x": -209, + "y": 43, + "z": -120 + }, + { + "x": -129, + "y": 39, + "z": -108 + }, + { + "x": -189, + "y": 43, + "z": -100 + }, + { + "x": -141, + "y": 42, + "z": -100 + }, + { + "x": -133, + "y": 40, + "z": -108 + }, + { + "x": -209, + "y": 42, + "z": -104 + }, + { + "x": -173, + "y": 41, + "z": -100 + }, + { + "x": -189, + "y": 43, + "z": -112 + }, + { + "x": -145, + "y": 40, + "z": -108 + }, + { + "x": -217, + "y": 42, + "z": -108 + }, + { + "x": -169, + "y": 41, + "z": -120 + }, + { + "x": -165, + "y": 43, + "z": -109 + }, + { + "x": -145, + "y": 42, + "z": -116 + }, + { + "x": -165, + "y": 42, + "z": -104 + }, + { + "x": -181, + "y": 40, + "z": -112 + }, + { + "x": -193, + "y": 41, + "z": -108 + }, + { + "x": -201, + "y": 40, + "z": -96 + }, + { + "x": -137, + "y": 41, + "z": -124 + }, + { + "x": -173, + "y": 43, + "z": -108 + }, + { + "x": -133, + "y": 40, + "z": -100 + }, + { + "x": -201, + "y": 40, + "z": -116 + }, + { + "x": -185, + "y": 41, + "z": -108 + }, + { + "x": -125, + "y": 39, + "z": -108 + }, + { + "x": -161, + "y": 42, + "z": -112 + }, + { + "x": -165, + "y": 40, + "z": -96 + }, + { + "x": -141, + "y": 39, + "z": -112 + }, + { + "x": -177, + "y": 39, + "z": -92 + }, + { + "x": -213, + "y": 41, + "z": -112 + }, + { + "x": -153, + "y": 42, + "z": -108 + }, + { + "x": -205, + "y": 42, + "z": -120 + }, + { + "x": -197, + "y": 43, + "z": -112 + }, + { + "x": -181, + "y": 42, + "z": -104 + }, + { + "x": -165, + "y": 41, + "z": -100 + }, + { + "x": -193, + "y": 42, + "z": -96 + }, + { + "x": -133, + "y": 40, + "z": -120 + }, + { + "x": -185, + "y": 41, + "z": -100 + }, + { + "x": -165, + "y": 41, + "z": -124 + }, + { + "x": -177, + "y": 40, + "z": -104 + }, + { + "x": -157, + "y": 40, + "z": -96 + }, + { + "x": -205, + "y": 41, + "z": -116 + }, + { + "x": -181, + "y": 40, + "z": -96 + }, + { + "x": -201, + "y": 43, + "z": -108 + }, + { + "x": -185, + "y": 41, + "z": -116 + } + ] + }, + { + "name": "Turbulator Parkour", + "waypoints": [ + { + "x": -302, + "y": 34, + "z": -107 + }, + { + "x": -304, + "y": 52, + "z": -109 + }, + { + "x": -306, + "y": 16, + "z": -107 + }, + { + "x": -304, + "y": 12, + "z": -107 + }, + { + "x": -308, + "y": 6, + "z": -105 + }, + { + "x": -302, + "y": 44, + "z": -107 + }, + { + "x": -306, + "y": 24, + "z": -109 + }, + { + "x": -302, + "y": 18, + "z": -111 + }, + { + "x": -300, + "y": 36, + "z": -109 + }, + { + "x": -304, + "y": 30, + "z": -103 + }, + { + "x": -302, + "y": 26, + "z": -111 + }, + { + "x": -308, + "y": 14, + "z": -103 + }, + { + "x": -300, + "y": 46, + "z": -103 + }, + { + "x": -300, + "y": 10, + "z": -111 + }, + { + "x": -300, + "y": 20, + "z": -107 + }, + { + "x": -306, + "y": 54, + "z": -111 + }, + { + "x": -306, + "y": 4, + "z": -103 + }, + { + "x": -300, + "y": 28, + "z": -107 + }, + { + "x": -306, + "y": 42, + "z": -111 + }, + { + "x": -308, + "y": 50, + "z": -105 + }, + { + "x": -304, + "y": 48, + "z": -107 + }, + { + "x": -302, + "y": 38, + "z": -105 + }, + { + "x": -304, + "y": 22, + "z": -111 + }, + { + "x": -304, + "y": 2, + "z": -107 + }, + { + "x": -304, + "y": 40, + "z": -107 + }, + { + "x": -306, + "y": 32, + "z": -105 + }, + { + "x": -304, + "y": 8, + "z": -109 + } + ] + } + ] +} \ No newline at end of file diff --git a/src/main/resources/skyblocker.mixins.json b/src/main/resources/skyblocker.mixins.json index 253e42d7..701d54e5 100644 --- a/src/main/resources/skyblocker.mixins.json +++ b/src/main/resources/skyblocker.mixins.json @@ -18,7 +18,8 @@ "PlayerListHudAccessor", "PlayerListHudMixin", "RecipeBookWidgetAccessor", - "accessor.BeaconBlockEntityRendererInvoker" + "accessor.BeaconBlockEntityRendererInvoker", + "accessor.FrustumInvoker" ], "injectors": { "defaultRequire": 1 -- cgit From 5764eed4cfd41e78a8cc1bb6ceb51fc0f5b84d9c Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Mon, 26 Jun 2023 19:39:18 +0800 Subject: Refactor MirrorverseWaypoints --- .../skyblocker/mixin/accessor/FrustumInvoker.java | 12 ++-- .../skyblock/rift/MirrorverseWaypoints.java | 73 +++++++++------------- .../me/xmrvizzy/skyblocker/utils/FrustumUtils.java | 5 ++ .../me/xmrvizzy/skyblocker/utils/RenderHelper.java | 12 +++- 4 files changed, 51 insertions(+), 51 deletions(-) (limited to 'src') diff --git a/src/main/java/me/xmrvizzy/skyblocker/mixin/accessor/FrustumInvoker.java b/src/main/java/me/xmrvizzy/skyblocker/mixin/accessor/FrustumInvoker.java index f086b9e5..108a7344 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/mixin/accessor/FrustumInvoker.java +++ b/src/main/java/me/xmrvizzy/skyblocker/mixin/accessor/FrustumInvoker.java @@ -1,17 +1,15 @@ package me.xmrvizzy.skyblocker.mixin.accessor; +import me.xmrvizzy.skyblocker.utils.FrustumUtils; +import net.minecraft.client.render.Frustum; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Invoker; -import net.minecraft.client.render.Frustum; - /** - * For the purpose of avoiding object allocations! - * + * Use {@link FrustumUtils#isVisible(double, double, double, double, double, double) FrustumUtils#isVisible} which is shorter. For the purpose of avoiding object allocations! */ @Mixin(Frustum.class) public interface FrustumInvoker { - - @Invoker("isVisible") - public boolean isVisible(double minX, double minY, double minZ, double maxX, double maxY, double maxZ); + @Invoker("isVisible") + boolean isVisible(double minX, double minY, double minZ, double maxX, double maxY, double maxZ); } diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/MirrorverseWaypoints.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/MirrorverseWaypoints.java index c0493d18..630d953b 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/MirrorverseWaypoints.java +++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/MirrorverseWaypoints.java @@ -1,74 +1,68 @@ package me.xmrvizzy.skyblocker.skyblock.rift; -import java.awt.Color; -import java.io.BufferedReader; -import java.io.IOException; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import com.google.gson.JsonArray; import com.google.gson.JsonObject; import com.google.gson.JsonParser; - -import me.x150.renderer.render.Renderer3d; +import me.xmrvizzy.skyblocker.SkyblockerMod; import me.xmrvizzy.skyblocker.config.SkyblockerConfig; -import me.xmrvizzy.skyblocker.mixin.accessor.FrustumInvoker; -import me.xmrvizzy.skyblocker.utils.FrustumUtils; +import me.xmrvizzy.skyblocker.utils.RenderHelper; import me.xmrvizzy.skyblocker.utils.Utils; import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext; import net.minecraft.client.MinecraftClient; import net.minecraft.util.DyeColor; import net.minecraft.util.Identifier; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Vec3d; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.BufferedReader; +import java.io.IOException; public class MirrorverseWaypoints { private static final Logger LOGGER = LoggerFactory.getLogger("skyblocker"); private static final MinecraftClient CLIENT = MinecraftClient.getInstance(); - private static final Identifier WAYPOINTS_JSON = new Identifier("skyblocker", "mirrorverse_waypoints.json"); + private static final Identifier WAYPOINTS_JSON = new Identifier(SkyblockerMod.NAMESPACE, "mirrorverse_waypoints.json"); private static final BlockPos[] LAVA_PATH_WAYPOINTS = new BlockPos[107]; private static final BlockPos[] UPSIDE_DOWN_WAYPOINTS = new BlockPos[66]; private static final BlockPos[] TURBULATOR_WAYPOINTS = new BlockPos[27]; private static final float[] COLOR_COMPONENTS = DyeColor.RED.getColorComponents(); - private static final Vec3d ONE = new Vec3d(1, 1, 1); - + static { loadWaypoints(); } - + /** * Loads the waypoint locations into memory */ public static void loadWaypoints() { - try(BufferedReader reader = CLIENT.getResourceManager().openAsReader(WAYPOINTS_JSON)) { + try (BufferedReader reader = CLIENT.getResourceManager().openAsReader(WAYPOINTS_JSON)) { JsonObject file = JsonParser.parseReader(reader).getAsJsonObject(); JsonArray sections = file.get("sections").getAsJsonArray(); - + /// Lava Path JsonArray lavaPathWaypoints = sections.get(0).getAsJsonObject().get("waypoints").getAsJsonArray(); - - for(int i = 0; i < lavaPathWaypoints.size(); i++) { + + for (int i = 0; i < lavaPathWaypoints.size(); i++) { JsonObject point = lavaPathWaypoints.get(i).getAsJsonObject(); LAVA_PATH_WAYPOINTS[i] = new BlockPos(point.get("x").getAsInt(), point.get("y").getAsInt(), point.get("z").getAsInt()); } - + /// Upside Down Parkour JsonArray upsideDownParkourWaypoints = sections.get(1).getAsJsonObject().get("waypoints").getAsJsonArray(); - - for(int i = 0; i < upsideDownParkourWaypoints.size(); i++) { + + for (int i = 0; i < upsideDownParkourWaypoints.size(); i++) { JsonObject point = upsideDownParkourWaypoints.get(i).getAsJsonObject(); UPSIDE_DOWN_WAYPOINTS[i] = new BlockPos(point.get("x").getAsInt(), point.get("y").getAsInt(), point.get("z").getAsInt()); } - + /// Turbulator Parkour JsonArray turbulatorParkourWaypoints = sections.get(2).getAsJsonObject().get("waypoints").getAsJsonArray(); - - for(int i = 0; i < turbulatorParkourWaypoints.size(); i++) { + + for (int i = 0; i < turbulatorParkourWaypoints.size(); i++) { JsonObject point = turbulatorParkourWaypoints.get(i).getAsJsonObject(); TURBULATOR_WAYPOINTS[i] = new BlockPos(point.get("x").getAsInt(), point.get("y").getAsInt(), point.get("z").getAsInt()); } - + } catch (IOException e) { LOGGER.info("[Skyblocker] Mirrorverse Waypoints failed to load ;("); e.printStackTrace(); @@ -76,25 +70,18 @@ public class MirrorverseWaypoints { } public static void render(WorldRenderContext wrc) { - FrustumInvoker frustum = ((FrustumInvoker) FrustumUtils.getFrustum()); //I would also check for the mirrorverse location but the scoreboard stuff is not performant at all... - if(Utils.getLocationRaw().equals(TheRift.LOCATION) && SkyblockerConfig.get().locations.rift.mirrorverseWaypoints) { - for(BlockPos pos : LAVA_PATH_WAYPOINTS) { - if(frustum.isVisible(pos.getX(), pos.getY(), pos.getZ(), pos.getX() + 1, pos.getY() + 1, pos.getZ() + 1)) { - Renderer3d.renderFilled(wrc.matrixStack(), new Color(COLOR_COMPONENTS[0], COLOR_COMPONENTS[1], COLOR_COMPONENTS[2], 0.5f), Vec3d.of(pos), ONE); - }; + if (Utils.getLocationRaw().equals(TheRift.LOCATION) && SkyblockerConfig.get().locations.rift.mirrorverseWaypoints) { + for (BlockPos pos : LAVA_PATH_WAYPOINTS) { + RenderHelper.renderFilledIfVisible(wrc, pos, COLOR_COMPONENTS, 0.5f); } - - for(BlockPos pos : UPSIDE_DOWN_WAYPOINTS) { - if(frustum.isVisible(pos.getX(), pos.getY(), pos.getZ(), pos.getX() + 1, pos.getY() + 1, pos.getZ() + 1)) { - Renderer3d.renderFilled(wrc.matrixStack(), new Color(COLOR_COMPONENTS[0], COLOR_COMPONENTS[1], COLOR_COMPONENTS[2], 0.5f), Vec3d.of(pos), ONE); - }; + + for (BlockPos pos : UPSIDE_DOWN_WAYPOINTS) { + RenderHelper.renderFilledIfVisible(wrc, pos, COLOR_COMPONENTS, 0.5f); } - - for(BlockPos pos : TURBULATOR_WAYPOINTS) { - if(frustum.isVisible(pos.getX(), pos.getY(), pos.getZ(), pos.getX() + 1, pos.getY() + 1, pos.getZ() + 1)) { - Renderer3d.renderFilled(wrc.matrixStack(), new Color(COLOR_COMPONENTS[0], COLOR_COMPONENTS[1], COLOR_COMPONENTS[2], 0.5f), Vec3d.of(pos), ONE); - }; + + for (BlockPos pos : TURBULATOR_WAYPOINTS) { + RenderHelper.renderFilledIfVisible(wrc, pos, COLOR_COMPONENTS, 0.5f); } } } diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/FrustumUtils.java b/src/main/java/me/xmrvizzy/skyblocker/utils/FrustumUtils.java index 6973aa1e..9ea90c16 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/utils/FrustumUtils.java +++ b/src/main/java/me/xmrvizzy/skyblocker/utils/FrustumUtils.java @@ -1,6 +1,7 @@ package me.xmrvizzy.skyblocker.utils; import me.xmrvizzy.skyblocker.mixin.AccessorWorldRenderer; +import me.xmrvizzy.skyblocker.mixin.accessor.FrustumInvoker; import net.minecraft.client.MinecraftClient; import net.minecraft.client.render.Frustum; import net.minecraft.util.math.Box; @@ -14,4 +15,8 @@ public class FrustumUtils { public static boolean isBoxVisible(Box box) { return getFrustum().isVisible(box); } + + public static boolean isVisible(double minX, double minY, double minZ, double maxX, double maxY, double maxZ) { + return ((FrustumInvoker) getFrustum()).isVisible(minX, minY, minZ, maxX, maxY, maxZ); + } } \ No newline at end of file diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/RenderHelper.java b/src/main/java/me/xmrvizzy/skyblocker/utils/RenderHelper.java index 79308dc3..c843dc43 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/utils/RenderHelper.java +++ b/src/main/java/me/xmrvizzy/skyblocker/utils/RenderHelper.java @@ -17,10 +17,20 @@ public class RenderHelper { public static void renderFilledThroughWalls(WorldRenderContext context, BlockPos pos, float[] colorComponents, float alpha) { Renderer3d.renderThroughWalls(); - Renderer3d.renderFilled(context.matrixStack(), new Color(colorComponents[0], colorComponents[1], colorComponents[2], alpha), Vec3d.of(pos), new Vec3d(1, 1, 1)); + renderFilled(context, pos, colorComponents, alpha); Renderer3d.stopRenderThroughWalls(); } + public static void renderFilledIfVisible(WorldRenderContext context, BlockPos pos, float[] colorComponents, float alpha) { + if (FrustumUtils.isVisible(pos.getX(), pos.getY(), pos.getZ(), pos.getX() + 1, pos.getY() + 1, pos.getZ() + 1)) { + renderFilled(context, pos, colorComponents, alpha); + } + } + + public static void renderFilled(WorldRenderContext context, BlockPos pos, float[] colorComponents, float alpha) { + Renderer3d.renderFilled(context.matrixStack(), new Color(colorComponents[0], colorComponents[1], colorComponents[2], alpha), Vec3d.of(pos), new Vec3d(1, 1, 1)); + } + public static void renderBeaconBeam(WorldRenderContext context, BlockPos pos, float[] colorComponents) { context.matrixStack().push(); context.matrixStack().translate(pos.getX() - context.camera().getPos().x, pos.getY() - context.camera().getPos().y, pos.getZ() - context.camera().getPos().z); -- cgit From 86189e6455662e25e3f8cc64cc3ebbffea201db2 Mon Sep 17 00:00:00 2001 From: Aaron <51387595+AzureAaron@users.noreply.github.com> Date: Mon, 26 Jun 2023 14:33:00 -0400 Subject: Reuse vector --- src/main/java/me/xmrvizzy/skyblocker/utils/RenderHelper.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/RenderHelper.java b/src/main/java/me/xmrvizzy/skyblocker/utils/RenderHelper.java index c843dc43..b37d324d 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/utils/RenderHelper.java +++ b/src/main/java/me/xmrvizzy/skyblocker/utils/RenderHelper.java @@ -10,6 +10,8 @@ import net.minecraft.util.math.Vec3d; import java.awt.*; public class RenderHelper { + private static final Vec3d DIMENSIONS = new Vec3d(1, 1, 1); + public static void renderFilledThroughWallsWithBeaconBeam(WorldRenderContext context, BlockPos pos, float[] colorComponents, float alpha) { renderFilledThroughWalls(context, pos, colorComponents, alpha); renderBeaconBeam(context, pos, colorComponents); @@ -28,7 +30,7 @@ public class RenderHelper { } public static void renderFilled(WorldRenderContext context, BlockPos pos, float[] colorComponents, float alpha) { - Renderer3d.renderFilled(context.matrixStack(), new Color(colorComponents[0], colorComponents[1], colorComponents[2], alpha), Vec3d.of(pos), new Vec3d(1, 1, 1)); + Renderer3d.renderFilled(context.matrixStack(), new Color(colorComponents[0], colorComponents[1], colorComponents[2], alpha), Vec3d.of(pos), DIMENSIONS); } public static void renderBeaconBeam(WorldRenderContext context, BlockPos pos, float[] colorComponents) { -- cgit From f941ae83603d242972567710021192f1a4dfdc02 Mon Sep 17 00:00:00 2001 From: Aaron <51387595+AzureAaron@users.noreply.github.com> Date: Mon, 26 Jun 2023 17:41:32 -0400 Subject: Format file --- .../me/xmrvizzy/skyblocker/utils/RenderHelper.java | 64 ++++++++++++---------- 1 file changed, 36 insertions(+), 28 deletions(-) (limited to 'src') diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/RenderHelper.java b/src/main/java/me/xmrvizzy/skyblocker/utils/RenderHelper.java index b37d324d..3c3e30d1 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/utils/RenderHelper.java +++ b/src/main/java/me/xmrvizzy/skyblocker/utils/RenderHelper.java @@ -11,32 +11,40 @@ import java.awt.*; public class RenderHelper { private static final Vec3d DIMENSIONS = new Vec3d(1, 1, 1); - - public static void renderFilledThroughWallsWithBeaconBeam(WorldRenderContext context, BlockPos pos, float[] colorComponents, float alpha) { - renderFilledThroughWalls(context, pos, colorComponents, alpha); - renderBeaconBeam(context, pos, colorComponents); - } - - public static void renderFilledThroughWalls(WorldRenderContext context, BlockPos pos, float[] colorComponents, float alpha) { - Renderer3d.renderThroughWalls(); - renderFilled(context, pos, colorComponents, alpha); - Renderer3d.stopRenderThroughWalls(); - } - - public static void renderFilledIfVisible(WorldRenderContext context, BlockPos pos, float[] colorComponents, float alpha) { - if (FrustumUtils.isVisible(pos.getX(), pos.getY(), pos.getZ(), pos.getX() + 1, pos.getY() + 1, pos.getZ() + 1)) { - renderFilled(context, pos, colorComponents, alpha); - } - } - - public static void renderFilled(WorldRenderContext context, BlockPos pos, float[] colorComponents, float alpha) { - Renderer3d.renderFilled(context.matrixStack(), new Color(colorComponents[0], colorComponents[1], colorComponents[2], alpha), Vec3d.of(pos), DIMENSIONS); - } - - public static void renderBeaconBeam(WorldRenderContext context, BlockPos pos, float[] colorComponents) { - context.matrixStack().push(); - context.matrixStack().translate(pos.getX() - context.camera().getPos().x, pos.getY() - context.camera().getPos().y, pos.getZ() - context.camera().getPos().z); - BeaconBlockEntityRendererInvoker.renderBeam(context.matrixStack(), context.consumers(), context.tickDelta(), context.world().getTime(), 0, BeaconBlockEntityRenderer.MAX_BEAM_HEIGHT, colorComponents); - context.matrixStack().pop(); - } + + public static void renderFilledThroughWallsWithBeaconBeam(WorldRenderContext context, BlockPos pos, + float[] colorComponents, float alpha) { + renderFilledThroughWalls(context, pos, colorComponents, alpha); + renderBeaconBeam(context, pos, colorComponents); + } + + public static void renderFilledThroughWalls(WorldRenderContext context, BlockPos pos, float[] colorComponents, + float alpha) { + Renderer3d.renderThroughWalls(); + renderFilled(context, pos, colorComponents, alpha); + Renderer3d.stopRenderThroughWalls(); + } + + public static void renderFilledIfVisible(WorldRenderContext context, BlockPos pos, float[] colorComponents, + float alpha) { + if (FrustumUtils.isVisible(pos.getX(), pos.getY(), pos.getZ(), pos.getX() + 1, pos.getY() + 1, + pos.getZ() + 1)) { + renderFilled(context, pos, colorComponents, alpha); + } + } + + public static void renderFilled(WorldRenderContext context, BlockPos pos, float[] colorComponents, float alpha) { + Renderer3d.renderFilled(context.matrixStack(), + new Color(colorComponents[0], colorComponents[1], colorComponents[2], alpha), Vec3d.of(pos), + DIMENSIONS); + } + + public static void renderBeaconBeam(WorldRenderContext context, BlockPos pos, float[] colorComponents) { + context.matrixStack().push(); + context.matrixStack().translate(pos.getX() - context.camera().getPos().x, + pos.getY() - context.camera().getPos().y, pos.getZ() - context.camera().getPos().z); + BeaconBlockEntityRendererInvoker.renderBeam(context.matrixStack(), context.consumers(), context.tickDelta(), + context.world().getTime(), 0, BeaconBlockEntityRenderer.MAX_BEAM_HEIGHT, colorComponents); + context.matrixStack().pop(); + } } -- cgit From fa6c260672468ed412e65a685f89cf2e09e2f1d7 Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Tue, 27 Jun 2023 13:26:28 +0800 Subject: Refactor RenderHelper --- .../me/xmrvizzy/skyblocker/utils/RenderHelper.java | 66 ++++++++++------------ 1 file changed, 29 insertions(+), 37 deletions(-) (limited to 'src') diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/RenderHelper.java b/src/main/java/me/xmrvizzy/skyblocker/utils/RenderHelper.java index 3c3e30d1..2e942905 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/utils/RenderHelper.java +++ b/src/main/java/me/xmrvizzy/skyblocker/utils/RenderHelper.java @@ -10,41 +10,33 @@ import net.minecraft.util.math.Vec3d; import java.awt.*; public class RenderHelper { - private static final Vec3d DIMENSIONS = new Vec3d(1, 1, 1); - - public static void renderFilledThroughWallsWithBeaconBeam(WorldRenderContext context, BlockPos pos, - float[] colorComponents, float alpha) { - renderFilledThroughWalls(context, pos, colorComponents, alpha); - renderBeaconBeam(context, pos, colorComponents); - } - - public static void renderFilledThroughWalls(WorldRenderContext context, BlockPos pos, float[] colorComponents, - float alpha) { - Renderer3d.renderThroughWalls(); - renderFilled(context, pos, colorComponents, alpha); - Renderer3d.stopRenderThroughWalls(); - } - - public static void renderFilledIfVisible(WorldRenderContext context, BlockPos pos, float[] colorComponents, - float alpha) { - if (FrustumUtils.isVisible(pos.getX(), pos.getY(), pos.getZ(), pos.getX() + 1, pos.getY() + 1, - pos.getZ() + 1)) { - renderFilled(context, pos, colorComponents, alpha); - } - } - - public static void renderFilled(WorldRenderContext context, BlockPos pos, float[] colorComponents, float alpha) { - Renderer3d.renderFilled(context.matrixStack(), - new Color(colorComponents[0], colorComponents[1], colorComponents[2], alpha), Vec3d.of(pos), - DIMENSIONS); - } - - public static void renderBeaconBeam(WorldRenderContext context, BlockPos pos, float[] colorComponents) { - context.matrixStack().push(); - context.matrixStack().translate(pos.getX() - context.camera().getPos().x, - pos.getY() - context.camera().getPos().y, pos.getZ() - context.camera().getPos().z); - BeaconBlockEntityRendererInvoker.renderBeam(context.matrixStack(), context.consumers(), context.tickDelta(), - context.world().getTime(), 0, BeaconBlockEntityRenderer.MAX_BEAM_HEIGHT, colorComponents); - context.matrixStack().pop(); - } + private static final Vec3d ONE = new Vec3d(1, 1, 1); + + public static void renderFilledThroughWallsWithBeaconBeam(WorldRenderContext context, BlockPos pos, float[] colorComponents, float alpha) { + renderFilledThroughWalls(context, pos, colorComponents, alpha); + renderBeaconBeam(context, pos, colorComponents); + } + + public static void renderFilledThroughWalls(WorldRenderContext context, BlockPos pos, float[] colorComponents, float alpha) { + Renderer3d.renderThroughWalls(); + renderFilled(context, pos, colorComponents, alpha); + Renderer3d.stopRenderThroughWalls(); + } + + public static void renderFilledIfVisible(WorldRenderContext context, BlockPos pos, float[] colorComponents, float alpha) { + if (FrustumUtils.isVisible(pos.getX(), pos.getY(), pos.getZ(), pos.getX() + 1, pos.getY() + 1, pos.getZ() + 1)) { + renderFilled(context, pos, colorComponents, alpha); + } + } + + public static void renderFilled(WorldRenderContext context, BlockPos pos, float[] colorComponents, float alpha) { + Renderer3d.renderFilled(context.matrixStack(), new Color(colorComponents[0], colorComponents[1], colorComponents[2], alpha), Vec3d.of(pos), ONE); + } + + public static void renderBeaconBeam(WorldRenderContext context, BlockPos pos, float[] colorComponents) { + context.matrixStack().push(); + context.matrixStack().translate(pos.getX() - context.camera().getPos().x, pos.getY() - context.camera().getPos().y, pos.getZ() - context.camera().getPos().z); + BeaconBlockEntityRendererInvoker.renderBeam(context.matrixStack(), context.consumers(), context.tickDelta(), context.world().getTime(), 0, BeaconBlockEntityRenderer.MAX_BEAM_HEIGHT, colorComponents); + context.matrixStack().pop(); + } } -- cgit