diff options
Diffstat (limited to 'src/main/java/de/hysky/skyblocker')
13 files changed, 428 insertions, 89 deletions
diff --git a/src/main/java/de/hysky/skyblocker/SkyblockerMod.java b/src/main/java/de/hysky/skyblocker/SkyblockerMod.java index 115f90ec..dc8896cf 100644 --- a/src/main/java/de/hysky/skyblocker/SkyblockerMod.java +++ b/src/main/java/de/hysky/skyblocker/SkyblockerMod.java @@ -2,13 +2,13 @@ package de.hysky.skyblocker; import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import de.hysky.skyblocker.config.SkyblockerConfigManager; import de.hysky.skyblocker.skyblock.*; +import de.hysky.skyblocker.skyblock.diana.MythologicalRitual; import de.hysky.skyblocker.skyblock.dungeon.*; import de.hysky.skyblocker.skyblock.dungeon.secrets.DungeonSecrets; -import de.hysky.skyblocker.skyblock.item.*; -import de.hysky.skyblocker.skyblock.tabhud.screenbuilder.ScreenMaster; -import de.hysky.skyblocker.config.SkyblockerConfigManager; import de.hysky.skyblocker.skyblock.dwarven.DwarvenHud; +import de.hysky.skyblocker.skyblock.item.*; import de.hysky.skyblocker.skyblock.itemlist.ItemRepository; import de.hysky.skyblocker.skyblock.quicknav.QuickNav; import de.hysky.skyblocker.skyblock.rift.TheRift; @@ -16,6 +16,7 @@ import de.hysky.skyblocker.skyblock.shortcut.Shortcuts; import de.hysky.skyblocker.skyblock.special.SpecialEffects; import de.hysky.skyblocker.skyblock.spidersden.Relics; import de.hysky.skyblocker.skyblock.tabhud.TabHud; +import de.hysky.skyblocker.skyblock.tabhud.screenbuilder.ScreenMaster; import de.hysky.skyblocker.skyblock.tabhud.util.PlayerListMgr; import de.hysky.skyblocker.utils.NEURepoManager; import de.hysky.skyblocker.utils.Utils; @@ -39,7 +40,7 @@ import java.nio.file.Path; * this class. */ public class SkyblockerMod implements ClientModInitializer { - public static final String VERSION = FabricLoader.getInstance().getModContainer("skyblocker").get().getMetadata().getVersion().getFriendlyString(); + public static final String VERSION = FabricLoader.getInstance().getModContainer("skyblocker").orElseThrow().getMetadata().getVersion().getFriendlyString(); public static final String NAMESPACE = "skyblocker"; public static final Path CONFIG_DIR = FabricLoader.getInstance().getConfigDir().resolve(NAMESPACE); public static final Gson GSON = new GsonBuilder().setPrettyPrinting().create(); @@ -76,6 +77,7 @@ public class SkyblockerMod implements ClientModInitializer { WikiLookup.init(); FairySouls.init(); Relics.init(); + MythologicalRitual.init(); BackpackPreview.init(); QuickNav.init(); ItemCooldowns.init(); diff --git a/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java b/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java index 57d12c76..51f3f098 100644 --- a/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java +++ b/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java @@ -1,11 +1,11 @@ package de.hysky.skyblocker.config; +import de.hysky.skyblocker.skyblock.item.CustomArmorTrims; +import de.hysky.skyblocker.utils.chat.ChatFilterResult; import dev.isxander.yacl3.config.v2.api.SerialEntry; import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; -import de.hysky.skyblocker.skyblock.item.CustomArmorTrims; -import de.hysky.skyblocker.utils.chat.ChatFilterResult; import net.minecraft.client.resource.language.I18n; import net.minecraft.text.Text; import net.minecraft.util.Formatting; @@ -177,6 +177,9 @@ public class SkyblockerConfig { public FairySouls fairySouls = new FairySouls(); @SerialEntry + public MythologicalRitual mythologicalRitual = new MythologicalRitual(); + + @SerialEntry public ItemCooldown itemCooldown = new ItemCooldown(); @SerialEntry @@ -322,6 +325,11 @@ public class SkyblockerConfig { public boolean highlightOnlyNearbySouls = false; } + public static class MythologicalRitual { + @SerialEntry + public boolean enableMythologicalRitualHelper = true; + } + public static class ItemCooldown { @SerialEntry public boolean enableItemCooldowns = true; @@ -605,6 +613,12 @@ public class SkyblockerConfig { @SerialEntry public boolean enableStonkWaypoints = true; + + @SerialEntry + public boolean enableAotvWaypoints = true; + + @SerialEntry + public boolean enablePearlWaypoints = true; @SerialEntry public boolean enableDefaultWaypoints = true; @@ -653,7 +667,6 @@ public class SkyblockerConfig { @SerialEntry public Formatting incompleteColor = Formatting.BLUE; - } public static class LividColor { diff --git a/src/main/java/de/hysky/skyblocker/config/categories/DungeonsCategory.java b/src/main/java/de/hysky/skyblocker/config/categories/DungeonsCategory.java index c3f54d4d..2cdde89d 100644 --- a/src/main/java/de/hysky/skyblocker/config/categories/DungeonsCategory.java +++ b/src/main/java/de/hysky/skyblocker/config/categories/DungeonsCategory.java @@ -123,6 +123,21 @@ public class DungeonsCategory { .controller(ConfigUtils::createBooleanController) .build()) .option(Option.<Boolean>createBuilder() + .name(Text.translatable("text.autoconfig.skyblocker.option.locations.dungeons.secretWaypoints.enableAotvWaypoints")) + .binding(defaults.locations.dungeons.secretWaypoints.enableAotvWaypoints, + () -> config.locations.dungeons.secretWaypoints.enableAotvWaypoints, + newValue -> config.locations.dungeons.secretWaypoints.enableAotvWaypoints = newValue) + .controller(ConfigUtils::createBooleanController) + .build()) + .option(Option.<Boolean>createBuilder() + .name(Text.translatable("text.autoconfig.skyblocker.option.locations.dungeons.secretWaypoints.enablePearlWaypoints")) + .description(OptionDescription.of(Text.translatable("text.autoconfig.skyblocker.option.locations.dungeons.secretWaypoints.enablePearlWaypoints.@Tooltip"))) + .binding(defaults.locations.dungeons.secretWaypoints.enablePearlWaypoints, + () -> config.locations.dungeons.secretWaypoints.enablePearlWaypoints, + newValue -> config.locations.dungeons.secretWaypoints.enablePearlWaypoints = newValue) + .controller(ConfigUtils::createBooleanController) + .build()) + .option(Option.<Boolean>createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.locations.dungeons.secretWaypoints.enableDefaultWaypoints")) .description(OptionDescription.of(Text.translatable("text.autoconfig.skyblocker.option.locations.dungeons.secretWaypoints.enableDefaultWaypoints.@Tooltip"))) .binding(defaults.locations.dungeons.secretWaypoints.enableDefaultWaypoints, diff --git a/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java b/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java index 30bdbd3f..10b21891 100644 --- a/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java +++ b/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java @@ -2,12 +2,12 @@ package de.hysky.skyblocker.config.categories; import de.hysky.skyblocker.config.ConfigUtils; import de.hysky.skyblocker.config.SkyblockerConfig; +import de.hysky.skyblocker.skyblock.shortcut.ShortcutsConfigScreen; +import de.hysky.skyblocker.utils.render.title.TitleContainerConfigScreen; import dev.isxander.yacl3.api.*; import dev.isxander.yacl3.api.controller.FloatFieldControllerBuilder; import dev.isxander.yacl3.api.controller.FloatSliderControllerBuilder; import dev.isxander.yacl3.api.controller.IntegerSliderControllerBuilder; -import de.hysky.skyblocker.skyblock.shortcut.ShortcutsConfigScreen; -import de.hysky.skyblocker.utils.render.title.TitleContainerConfigScreen; import net.minecraft.client.MinecraftClient; import net.minecraft.text.Text; @@ -200,6 +200,19 @@ public class GeneralCategory { .build()) .build()) + //Mythological Ritual + .group(OptionGroup.createBuilder() + .name(Text.translatable("text.autoconfig.skyblocker.option.general.mythologicalRitual")) + .collapsed(true) + .option(Option.<Boolean>createBuilder() + .name(Text.translatable("text.autoconfig.skyblocker.option.general.mythologicalRitual.enableMythologicalRitualHelper")) + .binding(defaults.general.mythologicalRitual.enableMythologicalRitualHelper, + () -> config.general.mythologicalRitual.enableMythologicalRitualHelper, + newValue -> config.general.mythologicalRitual.enableMythologicalRitualHelper = newValue) + .controller(ConfigUtils::createBooleanController) + .build()) + .build()) + //Item Cooldown .group(OptionGroup.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.general.itemCooldown")) diff --git a/src/main/java/de/hysky/skyblocker/mixin/ClientPlayNetworkHandlerMixin.java b/src/main/java/de/hysky/skyblocker/mixin/ClientPlayNetworkHandlerMixin.java index fff534b2..f68a4e94 100644 --- a/src/main/java/de/hysky/skyblocker/mixin/ClientPlayNetworkHandlerMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixin/ClientPlayNetworkHandlerMixin.java @@ -2,14 +2,16 @@ package de.hysky.skyblocker.mixin; import com.llamalad7.mixinextras.injector.WrapWithCondition; import com.llamalad7.mixinextras.sugar.Local; -import de.hysky.skyblocker.skyblock.dungeon.secrets.DungeonSecrets; -import dev.cbyrne.betterinject.annotations.Inject; import de.hysky.skyblocker.skyblock.FishingHelper; +import de.hysky.skyblocker.skyblock.diana.MythologicalRitual; +import de.hysky.skyblocker.skyblock.dungeon.secrets.DungeonSecrets; import de.hysky.skyblocker.utils.Utils; +import dev.cbyrne.betterinject.annotations.Inject; import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.ClientPlayNetworkHandler; import net.minecraft.entity.ItemEntity; import net.minecraft.entity.LivingEntity; +import net.minecraft.network.packet.s2c.play.ParticleS2CPacket; import net.minecraft.network.packet.s2c.play.PlaySoundS2CPacket; import org.slf4j.Logger; import org.spongepowered.asm.mixin.Mixin; @@ -24,7 +26,6 @@ public abstract class ClientPlayNetworkHandlerMixin { FishingHelper.onSound(packet); } - @SuppressWarnings("resource") @ModifyVariable(method = "onItemPickupAnimation", at = @At(value = "STORE", ordinal = 0)) private ItemEntity skyblocker$onItemPickup(ItemEntity itemEntity, @Local LivingEntity collector) { DungeonSecrets.onItemPickup(itemEntity, collector, collector == MinecraftClient.getInstance().player); @@ -45,4 +46,9 @@ public abstract class ClientPlayNetworkHandlerMixin { private boolean skyblocker$cancelTeamWarning(Logger instance, String format, Object... arg) { return !Utils.isOnHypixel(); } + + @Inject(method = "onParticle", at = @At("RETURN")) + private void skyblocker$onParticle(ParticleS2CPacket packet) { + MythologicalRitual.onParticle(packet); + } } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/diana/MythologicalRitual.java b/src/main/java/de/hysky/skyblocker/skyblock/diana/MythologicalRitual.java new file mode 100644 index 00000000..ea7b39cf --- /dev/null +++ b/src/main/java/de/hysky/skyblocker/skyblock/diana/MythologicalRitual.java @@ -0,0 +1,187 @@ +package de.hysky.skyblocker.skyblock.diana; + +import com.mojang.brigadier.Command; +import de.hysky.skyblocker.SkyblockerMod; +import de.hysky.skyblocker.config.SkyblockerConfigManager; +import de.hysky.skyblocker.utils.Utils; +import de.hysky.skyblocker.utils.render.RenderHelper; +import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback; +import net.fabricmc.fabric.api.client.message.v1.ClientReceiveMessageEvents; +import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext; +import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents; +import net.fabricmc.fabric.api.event.player.AttackBlockCallback; +import net.fabricmc.fabric.api.event.player.UseBlockCallback; +import net.fabricmc.fabric.api.util.TriState; +import net.minecraft.block.Blocks; +import net.minecraft.client.MinecraftClient; +import net.minecraft.command.argument.BlockPosArgumentType; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.network.packet.s2c.play.ParticleS2CPacket; +import net.minecraft.particle.ParticleTypes; +import net.minecraft.text.Text; +import net.minecraft.util.ActionResult; +import net.minecraft.util.DyeColor; +import net.minecraft.util.Hand; +import net.minecraft.util.hit.BlockHitResult; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Direction; +import net.minecraft.util.math.Vec3d; +import net.minecraft.world.World; +import org.apache.commons.math3.stat.regression.SimpleRegression; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.HashMap; +import java.util.Map; +import java.util.regex.Pattern; + +import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.argument; +import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.literal; + +public class MythologicalRitual { + private static final Pattern GRIFFIN_BURROW_DUG = Pattern.compile("(?<message>You dug out a Griffin Burrow!|You finished the Griffin burrow chain!) \\((?<index>\\d)/4\\)"); + private static final float[] ORANGE_COLOR_COMPONENTS = DyeColor.ORANGE.getColorComponents(); + private static final Map<BlockPos, GriffinBurrow> griffinBurrows = new HashMap<>(); + @Nullable + private static BlockPos lastDugBurrowPos; + private static GriffinBurrow previousBurrow = new GriffinBurrow(); + + public static void init() { + WorldRenderEvents.AFTER_TRANSLUCENT.register(MythologicalRitual::render); + AttackBlockCallback.EVENT.register(MythologicalRitual::onAttackBlock); + UseBlockCallback.EVENT.register(MythologicalRitual::onUseBlock); + ClientReceiveMessageEvents.GAME.register(MythologicalRitual::onChatMessage); + ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> dispatcher.register(literal(SkyblockerMod.NAMESPACE).then(literal("diana") + .then(literal("clearGriffinBurrows").executes(context -> { + griffinBurrows.clear(); + return Command.SINGLE_SUCCESS; + })) + .then(literal("clearGriffinBurrow") + .then(argument("pos", BlockPosArgumentType.blockPos()).executes(context -> { + griffinBurrows.remove(context.getArgument("pos", BlockPos.class)); + return Command.SINGLE_SUCCESS; + })) + ) + ))); + + // Put a root burrow so echo detection works without a previous burrow + previousBurrow.confirmed = TriState.DEFAULT; + griffinBurrows.put(BlockPos.ORIGIN, previousBurrow); + } + + public static void onParticle(ParticleS2CPacket packet) { + if (isActive()) { + if (ParticleTypes.CRIT.equals(packet.getParameters().getType()) || ParticleTypes.ENCHANT.equals(packet.getParameters().getType())) { + BlockPos pos = BlockPos.ofFloored(packet.getX(), packet.getY(), packet.getZ()).down(); + if (MinecraftClient.getInstance().world == null || !MinecraftClient.getInstance().world.getBlockState(pos).isOf(Blocks.GRASS_BLOCK)) { + return; + } + GriffinBurrow burrow = griffinBurrows.computeIfAbsent(pos, pos1 -> new GriffinBurrow()); + if (ParticleTypes.CRIT.equals(packet.getParameters().getType())) burrow.critParticle++; + if (ParticleTypes.ENCHANT.equals(packet.getParameters().getType())) burrow.enchantParticle++; + if (burrow.critParticle >= 5 && burrow.enchantParticle >= 5 && burrow.confirmed == TriState.FALSE) { + griffinBurrows.get(pos).init(); + } + } else if (ParticleTypes.DUST.equals(packet.getParameters().getType())) { + BlockPos pos = BlockPos.ofFloored(packet.getX(), packet.getY(), packet.getZ()).down(2); + GriffinBurrow burrow = griffinBurrows.get(pos); + if (burrow == null) { + return; + } + burrow.regression.addData(packet.getX(), packet.getZ()); + double slope = burrow.regression.getSlope(); + if (Double.isNaN(slope)) { + return; + } + Vec3d nextBurrowDirection = new Vec3d(100, 0, slope * 100).normalize().multiply(100); + if (burrow.nextBurrowPlane == null) { + burrow.nextBurrowPlane = new Vec3d[4]; + } + burrow.nextBurrowPlane[0] = Vec3d.of(pos).add(nextBurrowDirection).subtract(0, 50, 0); + burrow.nextBurrowPlane[1] = Vec3d.of(pos).subtract(nextBurrowDirection).subtract(0, 50, 0); + burrow.nextBurrowPlane[2] = burrow.nextBurrowPlane[1].add(0, 100, 0); + burrow.nextBurrowPlane[3] = burrow.nextBurrowPlane[0].add(0, 100, 0); + } else if (ParticleTypes.DRIPPING_LAVA.equals(packet.getParameters().getType())) { + if (previousBurrow.echoBurrowDirection == null) { + previousBurrow.echoBurrowDirection = new Vec3d[2]; + } + previousBurrow.echoBurrowDirection[0] = previousBurrow.echoBurrowDirection[1]; + previousBurrow.echoBurrowDirection[1] = new Vec3d(packet.getX(), packet.getY(), packet.getZ()); + if (previousBurrow.echoBurrowDirection[0] == null || previousBurrow.echoBurrowDirection[1] == null) { + return; + } + Vec3d echoBurrowDirection = previousBurrow.echoBurrowDirection[1].subtract(previousBurrow.echoBurrowDirection[0]).normalize().multiply(100); + if (previousBurrow.echoBurrowPlane == null) { + previousBurrow.echoBurrowPlane = new Vec3d[4]; + } + previousBurrow.echoBurrowPlane[0] = previousBurrow.echoBurrowDirection[0].add(echoBurrowDirection).subtract(0, 50, 0); + previousBurrow.echoBurrowPlane[1] = previousBurrow.echoBurrowDirection[0].subtract(echoBurrowDirection).subtract(0, 50, 0); + previousBurrow.echoBurrowPlane[2] = previousBurrow.echoBurrowPlane[0].add(0, 100, 0); + previousBurrow.echoBurrowPlane[3] = previousBurrow.echoBurrowPlane[1].add(0, 100, 0); + } + } + } + + public static void render(WorldRenderContext context) { + if (isActive()) { + for (Map.Entry<BlockPos, GriffinBurrow> burrowEntry : griffinBurrows.entrySet()) { + GriffinBurrow burrow = burrowEntry.getValue(); + if (burrow.confirmed == TriState.TRUE) { + RenderHelper.renderFilledThroughWallsWithBeaconBeam(context, burrowEntry.getKey(), ORANGE_COLOR_COMPONENTS, 0.25F); + } + if (burrow.confirmed != TriState.FALSE) { + if (burrow.nextBurrowPlane != null) { + RenderHelper.renderQuad(context, burrow.nextBurrowPlane, ORANGE_COLOR_COMPONENTS, 0.25F, true); + } + if (burrow.echoBurrowPlane != null) { + RenderHelper.renderQuad(context, burrow.echoBurrowPlane, ORANGE_COLOR_COMPONENTS, 0.25F, true); + } + } + } + } + } + + public static ActionResult onAttackBlock(PlayerEntity player, World world, Hand hand, BlockPos pos, Direction direction) { + return onInteractBlock(pos); + } + + public static ActionResult onUseBlock(PlayerEntity player, World world, Hand hand, BlockHitResult hitResult) { + return onInteractBlock(hitResult.getBlockPos()); + } + + @NotNull + private static ActionResult onInteractBlock(BlockPos pos) { + if (isActive() && griffinBurrows.containsKey(pos)) { + lastDugBurrowPos = pos; + } + return ActionResult.PASS; + } + + public static void onChatMessage(Text message, boolean overlay) { + if (isActive() && GRIFFIN_BURROW_DUG.matcher(message.getString()).matches()) { + previousBurrow.confirmed = TriState.FALSE; + previousBurrow = griffinBurrows.get(lastDugBurrowPos); + previousBurrow.confirmed = TriState.DEFAULT; + } + } + + private static boolean isActive() { + return SkyblockerConfigManager.get().general.mythologicalRitual.enableMythologicalRitualHelper && Utils.getLocationRaw().equals("hub"); + } + + private static class GriffinBurrow { + private int critParticle; + private int enchantParticle; + private TriState confirmed = TriState.FALSE; + private final SimpleRegression regression = new SimpleRegression(); + private Vec3d[] nextBurrowPlane; + @Nullable + private Vec3d[] echoBurrowDirection; + private Vec3d[] echoBurrowPlane; + + private void init() { + confirmed = TriState.TRUE; + regression.clear(); + } + } +} diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/secrets/DungeonMapUtils.java b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/secrets/DungeonMapUtils.java index 259cc3f3..73d4a452 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/secrets/DungeonMapUtils.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/secrets/DungeonMapUtils.java @@ -7,7 +7,6 @@ import net.minecraft.block.MapColor; import net.minecraft.item.map.MapIcon; import net.minecraft.item.map.MapState; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3i; import org.jetbrains.annotations.NotNull; @@ -173,7 +172,7 @@ public class DungeonMapUtils { @NotNull public static Vector2ic getPhysicalRoomPos(double x, double z) { Vector2i physicalPos = new Vector2i(x + 8.5, z + 8.5, RoundingMode.TRUNCATE); - return physicalPos.sub(MathHelper.floorMod(physicalPos.x(), 32), MathHelper.floorMod(physicalPos.y(), 32)).sub(8, 8); + return physicalPos.sub(Math.floorMod(physicalPos.x(), 32), Math.floorMod(physicalPos.y(), 32)).sub(8, 8); } public static Vector2ic[] getPhysicalPosFromMap(Vector2ic mapEntrancePos, int mapRoomSize, Vector2ic physicalEntrancePos, Vector2ic... mapPositions) { diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/secrets/DungeonSecrets.java b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/secrets/DungeonSecrets.java index cb9615fb..08b84852 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/secrets/DungeonSecrets.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/secrets/DungeonSecrets.java @@ -7,14 +7,14 @@ import com.mojang.brigadier.Command; import com.mojang.brigadier.arguments.IntegerArgumentType; import com.mojang.brigadier.builder.ArgumentBuilder; import com.mojang.brigadier.builder.RequiredArgumentBuilder; -import it.unimi.dsi.fastutil.objects.Object2ByteMap; -import it.unimi.dsi.fastutil.objects.Object2ByteOpenHashMap; -import it.unimi.dsi.fastutil.objects.ObjectIntPair; import de.hysky.skyblocker.SkyblockerMod; import de.hysky.skyblocker.config.SkyblockerConfigManager; import de.hysky.skyblocker.utils.Constants; import de.hysky.skyblocker.utils.Utils; import de.hysky.skyblocker.utils.scheduler.Scheduler; +import it.unimi.dsi.fastutil.objects.Object2ByteMap; +import it.unimi.dsi.fastutil.objects.Object2ByteOpenHashMap; +import it.unimi.dsi.fastutil.objects.ObjectIntPair; import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback; import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; import net.fabricmc.fabric.api.client.message.v1.ClientReceiveMessageEvents; @@ -37,7 +37,10 @@ import net.minecraft.text.Text; import net.minecraft.util.ActionResult; import net.minecraft.util.Identifier; import net.minecraft.util.hit.BlockHitResult; +import net.minecraft.util.hit.HitResult; +import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; +import net.minecraft.util.math.Vec3i; import net.minecraft.world.World; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; @@ -149,7 +152,9 @@ public class DungeonSecrets { UseBlockCallback.EVENT.register((player, world, hand, hitResult) -> onUseBlock(world, hitResult)); ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> dispatcher.register(literal(SkyblockerMod.NAMESPACE).then(literal("dungeons").then(literal("secrets") .then(literal("markAsFound").then(markSecretsCommand(true))) - .then(literal("markAsMissing").then(markSecretsCommand(false))))))); + .then(literal("markAsMissing").then(markSecretsCommand(false))) + .then(literal("getRelativePos").executes(context -> getRelativePos(context.getSource()))) + .then(literal("getRelativeTargetPos").executes(context -> getRelativeTargetPos(context.getSource()))))))); ClientPlayConnectionEvents.JOIN.register(((handler, sender, client) -> reset())); } @@ -204,8 +209,9 @@ public class DungeonSecrets { /** * Loads the json from the given {@link BufferedReader} into the given {@link Map}. + * * @param reader the reader to read the json from - * @param map the map to load into + * @param map the map to load into */ private static void loadJson(BufferedReader reader, Map<String, JsonElement> map) { SkyblockerMod.GSON.fromJson(reader, JsonObject.class).asMap().forEach((room, jsonElement) -> map.put(room.toLowerCase().replaceAll(" ", "-"), jsonElement)); @@ -223,6 +229,30 @@ public class DungeonSecrets { }); } + private static int getRelativePos(FabricClientCommandSource source) { + return getRelativePos(source, source.getPlayer().getBlockPos()); + } + + private static int getRelativeTargetPos(FabricClientCommandSource source) { + if (MinecraftClient.getInstance().crosshairTarget instanceof BlockHitResult blockHitResult && blockHitResult.getType() == HitResult.Type.BLOCK) { + return getRelativePos(source, blockHitResult.getBlockPos()); + } else { + source.sendError(Constants.PREFIX.get().append(Text.translatable("skyblocker.dungeons.secrets.noTarget"))); + } + return Command.SINGLE_SUCCESS; + } + + private static int getRelativePos(FabricClientCommandSource source, BlockPos pos) { + Room room = getRoomAtPhysical(pos); + if (isRoomMatched(room)) { + BlockPos relativePos = currentRoom.actualToRelative(pos); + source.sendFeedback(Constants.PREFIX.get().append(Text.translatable("skyblocker.dungeons.secrets.posMessage", currentRoom.getName(), relativePos.getX(), relativePos.getY(), relativePos.getZ()))); + } else { + source.sendError(Constants.PREFIX.get().append(Text.translatable("skyblocker.dungeons.secrets.notMatched"))); + } + return Command.SINGLE_SUCCESS; + } + /** * Updates the dungeon. The general idea is similar to the Dungeon Rooms Mod. * <p></p> @@ -340,9 +370,16 @@ public class DungeonSecrets { * Used to detect when all secrets in a room are found. */ private static void onChatMessage(Text text, boolean overlay) { + String message = text.getString(); + if (overlay && isCurrentRoomMatched()) { - currentRoom.onChatMessage(text.getString()); + currentRoom.onChatMessage(message); } + + if (message.equals("[BOSS] Bonzo: Gratz for making it this far, but I'm basically unbeatable.") || message.equals("[BOSS] Scarf: This is where the journey ends for you, Adventurers.") + || message.equals("[BOSS] The Professor: I was burdened with terrible news recently...") || message.equals("[BOSS] Thorn: Welcome Adventurers! I am Thorn, the Spirit! And host of the Vegan Trials!") + || message.equals("[BOSS] Livid: Welcome, you've arrived right on time. I am Livid, the Master of Shadows.") || message.equals("[BOSS] Sadan: So you made it all the way here... Now you wish to defy me? Sadan?!") + || message.equals("[BOSS] Maxor: WELL! WELL! WELL! LOOK WHO'S HERE!")) reset(); } /** @@ -411,6 +448,19 @@ public class DungeonSecrets { } /** + * Gets the room at the given physical position. + * + * @param pos the physical position + * @return the room at the given physical position, or null if there is no room at the given physical position + * @see #rooms + * @see DungeonMapUtils#getPhysicalRoomPos(Vec3i) + */ + @Nullable + private static Room getRoomAtPhysical(Vec3i pos) { + return rooms.get(DungeonMapUtils.getPhysicalRoomPos(pos)); + } + + /** * Calls {@link #isRoomMatched(Room)} on {@link #currentRoom}. * * @return {@code true} if {@link #currentRoom} is not null and {@link #isRoomMatched(Room)} @@ -440,7 +490,7 @@ public class DungeonSecrets { } /** - * Resets fields when leaving a dungeon. + * Resets fields when leaving a dungeon or entering boss. */ private static void reset() { mapEntrancePos = null; diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/secrets/Room.java b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/secrets/Room.java index dd7dc91e..0d7a444f 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/secrets/Room.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/secrets/Room.java @@ -5,10 +5,10 @@ import com.google.common.collect.ImmutableTable; import com.google.common.collect.Table; import com.google.gson.JsonElement; import com.google.gson.JsonObject; +import de.hysky.skyblocker.utils.scheduler.Scheduler; import it.unimi.dsi.fastutil.ints.IntRBTreeSet; import it.unimi.dsi.fastutil.ints.IntSortedSet; import it.unimi.dsi.fastutil.ints.IntSortedSets; -import de.hysky.skyblocker.utils.scheduler.Scheduler; import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext; import net.fabricmc.fabric.api.util.TriState; import net.minecraft.block.BlockState; @@ -23,7 +23,6 @@ import net.minecraft.entity.mob.AmbientEntity; import net.minecraft.registry.Registries; import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; import org.apache.commons.lang3.tuple.MutableTriple; import org.apache.commons.lang3.tuple.Triple; @@ -72,6 +71,9 @@ public class Room { */ private TriState matched = TriState.DEFAULT; private Table<Integer, BlockPos, SecretWaypoint> secretWaypoints; + private String name; + private Direction direction; + private Vector2ic physicalCornerPos; public Room(@NotNull Type type, @NotNull Vector2ic... physicalPositions) { this.type = type; @@ -92,6 +94,13 @@ public class Room { return matched == TriState.TRUE; } + /** + * Not null if {@link #isMatched()}. + */ + public String getName() { + return name; + } + @Override public String toString() { return "Room{type=" + type + ", shape=" + shape + ", matched=" + matched + ", segments=" + Arrays.toString(segments.toArray()) + "}"; @@ -186,8 +195,8 @@ public class Room { if (pos.getY() < 66 || pos.getY() > 73) { return true; } - int x = MathHelper.floorMod(pos.getX() - 8, 32); - int z = MathHelper.floorMod(pos.getZ() - 8, 32); + int x = Math.floorMod(pos.getX() - 8, 32); + int z = Math.floorMod(pos.getZ() - 8, 32); return (x < 13 || x > 17 || z > 2 && z < 28) && (z < 13 || z > 17 || x > 2 && x < 28); } @@ -217,7 +226,7 @@ public class Room { * </ul> * <li> If there are exactly one room matching: </li> * <ul> - * <li> Call {@link #roomMatched(String, Direction, Vector2ic)}. </li> + * <li> Call {@link #roomMatched()}. </li> * <li> Discard the no longer needed fields to save memory. </li> * <li> Return {@code true} </li> * </ul> @@ -256,7 +265,10 @@ public class Room { // If one room matches, load the secrets for that room and discard the no longer needed fields. for (Triple<Direction, Vector2ic, List<String>> directionRooms : possibleRooms) { if (directionRooms.getRight().size() == 1) { - roomMatched(directionRooms.getRight().get(0), directionRooms.getLeft(), directionRooms.getMiddle()); + name = directionRooms.getRight().get(0); + direction = directionRooms.getLeft(); + physicalCornerPos = directionRooms.getMiddle(); + roomMatched(); discard(); return true; } @@ -286,7 +298,7 @@ public class Room { * @param directionRooms the direction, position, and name of the room */ @SuppressWarnings("JavadocReference") - private void roomMatched(String name, Direction direction, Vector2ic physicalCornerPos) { + private void roomMatched() { Table<Integer, BlockPos, SecretWaypoint> secretWaypointsMutable = HashBasedTable.create(); for (JsonElement waypointElement : DungeonSecrets.getRoomWaypoints(name)) { JsonObject waypoint = waypointElement.getAsJsonObject(); @@ -297,6 +309,7 @@ public class Room { } secretWaypoints = ImmutableTable.copyOf(secretWaypointsMutable); matched = TriState.TRUE; + DungeonSecrets.LOGGER.info("[Skyblocker] Room {} matched after checking {} block(s)", name, checkedBlocks.size()); } @@ -323,6 +336,20 @@ public class Room { } /** + * Fails if !{@link #isMatched()} + */ + protected BlockPos actualToRelative(BlockPos pos) { + return DungeonMapUtils.actualToRelative(direction, physicalCornerPos, pos); + } + + /** + * Fails if !{@link #isMatched()} + */ + protected BlockPos relativeToActual(BlockPos pos) { + return DungeonMapUtils.relativeToActual(direction, physicalCornerPos, pos); + } + + /** * Calls {@link SecretWaypoint#render(WorldRenderContext)} on {@link #secretWaypoints all secret waypoints}. */ protected void render(WorldRenderContext context) { diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/secrets/SecretWaypoint.java b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/secrets/SecretWaypoint.java index 0d9bdff1..a520c73f 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/secrets/SecretWaypoint.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/secrets/SecretWaypoint.java @@ -112,6 +112,8 @@ public class SecretWaypoint { LEVER(secretWaypoints -> secretWaypoints.enableLeverWaypoints, 250, 217, 2), FAIRYSOUL(secretWaypoints -> secretWaypoints.enableFairySoulWaypoints, 255, 85, 255), STONK(secretWaypoints -> secretWaypoints.enableStonkWaypoints, 146, 52, 235), + AOTV(secretWaypoints -> secretWaypoints.enableAotvWaypoints, 252, 98, 3), + PEARL(secretWaypoints -> secretWaypoints.enablePearlWaypoints, 57, 117, 125), DEFAULT(secretWaypoints -> secretWaypoints.enableDefaultWaypoints, 190, 255, 252); private final Predicate<SkyblockerConfig.SecretWaypoints> enabledPredicate; private final float[] colorComponents; @@ -135,6 +137,8 @@ public class SecretWaypoint { case "lever" -> Category.LEVER; case "fairysoul" -> Category.FAIRYSOUL; case "stonk" -> Category.STONK; + case "aotv" -> Category.AOTV; + case "pearl" -> Category.PEARL; default -> Category.DEFAULT; }; } diff --git a/src/main/java/de/hysky/skyblocker/utils/ItemUtils.java b/src/main/java/de/hysky/skyblocker/utils/ItemUtils.java index 50a9bcd1..ed46677d 100644 --- a/src/main/java/de/hysky/skyblocker/utils/ItemUtils.java +++ b/src/main/java/de/hysky/skyblocker/utils/ItemUtils.java @@ -12,34 +12,34 @@ import net.minecraft.util.Formatting; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Optional; +import java.util.function.Predicate; import java.util.regex.Pattern; public class ItemUtils { - private final static Pattern WHITESPACES = Pattern.compile("^\\s*$"); public static final String EXTRA_ATTRIBUTES = "ExtraAttributes"; public static final String ID = "id"; public static final String UUID = "uuid"; + public static final Pattern NOT_DURABILITY = Pattern.compile("[^0-9 /]"); + public static final Predicate<String> FUEL_PREDICATE = line -> line.contains("Fuel: "); - public static List<Text> getTooltip(ItemStack item) { + public static List<Text> getTooltips(ItemStack item) { MinecraftClient client = MinecraftClient.getInstance(); return client.player == null || item == null ? Collections.emptyList() : item.getTooltip(client.player, TooltipContext.Default.BASIC); } - public static List<String> getTooltipStrings(ItemStack item) { - List<Text> lines = getTooltip(item); - List<String> list = new ArrayList<>(); - - for (Text line : lines) { + @Nullable + public static String getTooltip(ItemStack item, Predicate<String> predicate) { + for (Text line : getTooltips(item)) { String string = line.getString(); - if (!WHITESPACES.matcher(string).matches()) - list.add(string); + if (predicate.test(string)) { + return string; + } } - return list; + return null; } /** @@ -98,7 +98,7 @@ public class ItemUtils { * Gets the UUID of the item stack from the {@code ExtraAttributes} NBT tag. * * @param stack the item stack to get the UUID from - * @return the UUID of the item stack, or null if the item stack is null or does not have a UUID + * @return the UUID of the item stack, or an empty string if the item stack is null or does not have a UUID */ public static String getItemUuid(@NotNull ItemStack stack) { NbtCompound extraAttributes = getExtraAttributes(stack); @@ -112,32 +112,21 @@ public class ItemUtils { @Nullable public static IntIntPair getDurability(@NotNull ItemStack stack) { - int current = 0; - int max = 0; - String clearFormatting; - - for (String line : getTooltipStrings(stack)) { - clearFormatting = Formatting.strip(line); - if (line.contains("Fuel: ")) { - if (clearFormatting != null) { - String clear = Pattern.compile("[^0-9 /]").matcher(clearFormatting).replaceAll("").trim(); - String[] split = clear.split("/"); - current = Integer.parseInt(split[0]); - max = Integer.parseInt(split[1]) * 1000; - return IntIntPair.of(current, max); - } - } else if (line.contains("uses.")) { - if (clearFormatting != null) { - int startIndex = clearFormatting.lastIndexOf("after") + 6; - int endIndex = clearFormatting.indexOf("uses", startIndex); - if (startIndex >= 0 && endIndex > startIndex) { - String usesString = clearFormatting.substring(startIndex, endIndex).trim(); - current = Integer.parseInt(usesString); - max = 5000; - } - return IntIntPair.of(current, max); - } - } + NbtCompound extraAttributes = getExtraAttributes(stack); + if (extraAttributes == null) return null; + + // TODO Calculate drill durability based on the drill_fuel flag, fuel_tank flag, and hotm level + // TODO Cache the max durability and only update the current durability on inventory tick + + int pickonimbusDurability = extraAttributes.getInt("pickonimbus_durability"); + if (pickonimbusDurability > 0) { + return IntIntPair.of(pickonimbusDurability, 5000); + } + + String drillFuel = Formatting.strip(getTooltip(stack, FUEL_PREDICATE)); + if (drillFuel != null) { + String[] drillFuelStrings = NOT_DURABILITY.matcher(drillFuel).replaceAll("").trim().split("/"); + return IntIntPair.of(Integer.parseInt(drillFuelStrings[0]), Integer.parseInt(drillFuelStrings[1]) * 1000); } return null; diff --git a/src/main/java/de/hysky/skyblocker/utils/Utils.java b/src/main/java/de/hysky/skyblocker/utils/Utils.java index c1b4223f..bbfd1101 100644 --- a/src/main/java/de/hysky/skyblocker/utils/Utils.java +++ b/src/main/java/de/hysky/skyblocker/utils/Utils.java @@ -19,6 +19,7 @@ import net.minecraft.client.network.PlayerListEntry; import net.minecraft.scoreboard.*; import net.minecraft.text.Text; import net.minecraft.util.Formatting; +import org.jetbrains.annotations.NotNull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -40,10 +41,15 @@ public class Utils { * The following fields store data returned from /locraw: {@link #profile}, {@link #server}, {@link #gameType}, {@link #locationRaw}, and {@link #map}. */ @SuppressWarnings("JavadocDeclaration") + @NotNull private static String profile = ""; + @NotNull private static String server = ""; + @NotNull private static String gameType = ""; + @NotNull private static String locationRaw = ""; + @NotNull private static String map = ""; private static long clientWorldJoinTime = 0; private static boolean sentLocRaw = false; @@ -78,6 +84,7 @@ public class Utils { /** * @return the profile parsed from the player list. */ + @NotNull public static String getProfile() { return profile; } @@ -85,6 +92,7 @@ public class Utils { /** * @return the server parsed from /locraw. */ + @NotNull public static String getServer() { return server; } @@ -92,6 +100,7 @@ public class Utils { /** * @return the game type parsed from /locraw. */ + @NotNull public static String getGameType() { return gameType; } @@ -99,6 +108,7 @@ public class Utils { /** * @return the location raw parsed from /locraw. */ + @NotNull public static String getLocationRaw() { return locationRaw; } @@ -106,6 +116,7 @@ public class Utils { /** * @return the map parsed from /locraw. */ + @NotNull public static String getMap() { return map; } diff --git a/src/main/java/de/hysky/skyblocker/utils/render/RenderHelper.java b/src/main/java/de/hysky/skyblocker/utils/render/RenderHelper.java index 5ab698a7..4cfaef8f 100644 --- a/src/main/java/de/hysky/skyblocker/utils/render/RenderHelper.java +++ b/src/main/java/de/hysky/skyblocker/utils/render/RenderHelper.java @@ -1,13 +1,11 @@ package de.hysky.skyblocker.utils.render; -import com.mojang.blaze3d.platform.GlStateManager.DstFactor; -import com.mojang.blaze3d.platform.GlStateManager.SrcFactor; import com.mojang.blaze3d.systems.RenderSystem; import de.hysky.skyblocker.mixin.accessor.BeaconBlockEntityRendererInvoker; -import me.x150.renderer.render.Renderer3d; import de.hysky.skyblocker.utils.render.culling.OcclusionCulling; import de.hysky.skyblocker.utils.render.title.Title; import de.hysky.skyblocker.utils.render.title.TitleContainer; +import me.x150.renderer.render.Renderer3d; import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; @@ -22,7 +20,6 @@ import net.minecraft.util.math.Box; import net.minecraft.util.math.Vec3d; import org.joml.Matrix3f; import org.joml.Matrix4f; -import org.joml.Vector3f; import org.lwjgl.opengl.GL11; import java.awt.*; @@ -111,6 +108,8 @@ public class RenderHelper { * Draws lines from point to point.<br><br> * <p> * Tip: To draw lines from the center of a block, offset the X, Y and Z each by 0.5 + * <p> + * Note: This is super messed up when drawing long lines. Tried different normals and {@link DrawMode#LINES} but nothing worked. * * @param context The WorldRenderContext which supplies the matrices and tick delta * @param points The points from which to draw lines between @@ -127,7 +126,7 @@ public class RenderHelper { Tessellator tessellator = RenderSystem.renderThreadTesselator(); BufferBuilder buffer = tessellator.getBuffer(); - Matrix4f projectionMatrix = matrices.peek().getPositionMatrix(); + Matrix4f positionMatrix = matrices.peek().getPositionMatrix(); Matrix3f normalMatrix = matrices.peek().getNormalMatrix(); GL11.glEnable(GL11.GL_LINE_SMOOTH); @@ -137,21 +136,18 @@ public class RenderHelper { RenderSystem.setShaderColor(1f, 1f, 1f, 1f); RenderSystem.lineWidth(lineWidth); RenderSystem.enableBlend(); - RenderSystem.blendFunc(SrcFactor.SRC_ALPHA, DstFactor.ONE_MINUS_SRC_ALPHA); + RenderSystem.defaultBlendFunc(); RenderSystem.disableCull(); RenderSystem.enableDepthTest(); buffer.begin(DrawMode.LINE_STRIP, VertexFormats.LINES); for (int i = 0; i < points.length; i++) { - Vec3d point = points[i]; - Vec3d nextPoint = (i + 1 == points.length) ? points[i - 1] : points[i + 1]; - Vector3f normalVec = new Vector3f((float) nextPoint.getX(), (float) nextPoint.getY(), (float) nextPoint.getZ()).sub((float) point.getX(), (float) point.getY(), (float) point.getZ()).normalize(); - + Vec3d normalVec = points[(i + 1) % points.length].subtract(points[i]).normalize(); buffer - .vertex(projectionMatrix, (float) point.getX(), (float) point.getY(), (float) point.getZ()) + .vertex(positionMatrix, (float) points[i].getX(), (float) points[i].getY(), (float) points[i].getZ()) .color(colorComponents[0], colorComponents[1], colorComponents[2], alpha) - .normal(normalMatrix, normalVec.x, normalVec.y, normalVec.z) + .normal(normalMatrix, (float) normalVec.x, (float) normalVec.y, (float) normalVec.z) .next(); } @@ -160,30 +156,57 @@ public class RenderHelper { matrices.pop(); GL11.glDisable(GL11.GL_LINE_SMOOTH); RenderSystem.lineWidth(1f); - RenderSystem.disableBlend(); + RenderSystem.enableCull(); + } + + public static void renderQuad(WorldRenderContext context, Vec3d[] points, float[] colorComponents, float alpha, boolean throughWalls) { + Vec3d camera = context.camera().getPos(); + MatrixStack matrices = context.matrixStack(); + + matrices.push(); + matrices.translate(-camera.x, -camera.y, -camera.z); + + Tessellator tessellator = RenderSystem.renderThreadTesselator(); + BufferBuilder buffer = tessellator.getBuffer(); + Matrix4f positionMatrix = matrices.peek().getPositionMatrix(); + + RenderSystem.setShader(GameRenderer::getPositionColorProgram); + RenderSystem.setShaderColor(1f, 1f, 1f, 1f); + RenderSystem.enableBlend(); RenderSystem.defaultBlendFunc(); + RenderSystem.disableCull(); + RenderSystem.depthFunc(throughWalls ? GL11.GL_ALWAYS : GL11.GL_LEQUAL); + + buffer.begin(DrawMode.QUADS, VertexFormats.POSITION_COLOR); + for (int i = 0; i < 4; i++) { + buffer.vertex(positionMatrix, (float) points[i].getX(), (float) points[i].getY(), (float) points[i].getZ()).color(colorComponents[0], colorComponents[1], colorComponents[2], alpha).next(); + } + tessellator.draw(); + RenderSystem.enableCull(); - RenderSystem.disableDepthTest(); + RenderSystem.depthFunc(GL11.GL_LEQUAL); + + matrices.pop(); } - public static void renderText(WorldRenderContext context, Text text, Vec3d pos, boolean seeThrough) { - renderText(context, text, pos, 1, seeThrough); + public static void renderText(WorldRenderContext context, Text text, Vec3d pos, boolean throughWalls) { + renderText(context, text, pos, 1, throughWalls); } - public static void renderText(WorldRenderContext context, Text text, Vec3d pos, float scale, boolean seeThrough) { - renderText(context, text, pos, scale, 0, seeThrough); + public static void renderText(WorldRenderContext context, Text text, Vec3d pos, float scale, boolean throughWalls) { + renderText(context, text, pos, scale, 0, throughWalls); } - public static void renderText(WorldRenderContext context, Text text, Vec3d pos, float scale, float yOffset, boolean seeThrough) { - renderText(context, text.asOrderedText(), pos, scale, yOffset, seeThrough); + public static void renderText(WorldRenderContext context, Text text, Vec3d pos, float scale, float yOffset, boolean throughWalls) { + renderText(context, text.asOrderedText(), pos, scale, yOffset, throughWalls); } /** * Renders text in the world space. * - * @param seeThrough Whether the text should be able to be seen through walls or not. + * @param throughWalls whether the text should be able to be seen through walls or not. */ - public static void renderText(WorldRenderContext context, OrderedText text, Vec3d pos, float scale, float yOffset, boolean seeThrough) { + public static void renderText(WorldRenderContext context, OrderedText text, Vec3d pos, float scale, float yOffset, boolean throughWalls) { MatrixStack matrices = context.matrixStack(); Vec3d camera = context.camera().getPos(); TextRenderer textRenderer = client.textRenderer; @@ -203,7 +226,7 @@ public class RenderHelper { BufferBuilder buffer = tessellator.getBuffer(); VertexConsumerProvider.Immediate consumers = VertexConsumerProvider.immediate(buffer); - RenderSystem.depthFunc(seeThrough ? GL11.GL_ALWAYS : GL11.GL_LEQUAL); + RenderSystem.depthFunc(throughWalls ? GL11.GL_ALWAYS : GL11.GL_LEQUAL); textRenderer.draw(text, xOffset, yOffset, 0xFFFFFFFF, false, positionMatrix, consumers, TextRenderer.TextLayerType.SEE_THROUGH, 0, LightmapTextureManager.MAX_LIGHT_COORDINATE); consumers.draw(); |