diff options
18 files changed, 129 insertions, 154 deletions
diff --git a/build.gradle b/build.gradle index b18923a..b6acd8b 100644 --- a/build.gradle +++ b/build.gradle @@ -1,31 +1,31 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { - id 'fabric-loom' version '1.5-SNAPSHOT' - id 'maven-publish' - id "org.jetbrains.kotlin.jvm" version "1.8.21" - id "org.jetbrains.kotlin.plugin.serialization" version "1.8.10" + id 'fabric-loom' version '1.6-SNAPSHOT' + id 'maven-publish' + id "org.jetbrains.kotlin.jvm" version "1.9.23" + id "org.jetbrains.kotlin.plugin.serialization" version "1.9.23" } version = project.mod_version group = project.maven_group base { - archivesName = project.archives_base_name + archivesName = project.archives_base_name } repositories { - // Add repositories to retrieve artifacts from in here. - // You should only use this when depending on other mods because - // Loom adds the essential maven repositories to download Minecraft and libraries from automatically. - // See https://docs.gradle.org/current/userguide/declaring_repositories.html - // for more information about repositories. - maven { url = "https://pkgs.dev.azure.com/djtheredstoner/DevAuth/_packaging/public/maven/v1" } - maven { url "https://repo.nea.moe/mirror" } - maven { url "https://repo.nea.moe/releases/" } - maven { url "https://maven.shedaniel.me/" } - maven { url "https://maven.terraformersmc.com/releases/" } - maven { url = "https://jitpack.io/" } + // Add repositories to retrieve artifacts from in here. + // You should only use this when depending on other mods because + // Loom adds the essential maven repositories to download Minecraft and libraries from automatically. + // See https://docs.gradle.org/current/userguide/declaring_repositories.html + // for more information about repositories. + maven { url = "https://pkgs.dev.azure.com/djtheredstoner/DevAuth/_packaging/public/maven/v1" } + maven { url "https://repo.nea.moe/mirror" } + maven { url "https://repo.nea.moe/releases/" } + maven { url "https://maven.shedaniel.me/" } + maven { url "https://maven.terraformersmc.com/releases/" } + maven { url = "https://jitpack.io/" } maven { url "https://api.modrinth.com/maven" content { @@ -35,65 +35,69 @@ repositories { } dependencies { - minecraft "com.mojang:minecraft:${project.minecraft_version}" - mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" - modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" + minecraft "com.mojang:minecraft:${project.minecraft_version}" + mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" + modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" - modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" - modImplementation "net.fabricmc:fabric-language-kotlin:${project.fabric_kotlin_version}" - modRuntimeOnly("me.djtheredstoner:DevAuth-fabric:1.1.2") - implementation "meteordevelopment:orbit:0.2.3" - include "meteordevelopment:orbit:0.2.3" - modApi "me.shedaniel.cloth:cloth-config-fabric:13.0.121" - include "me.shedaniel.cloth:cloth-config-fabric:13.0.121" - modImplementation("moe.nea.jarvis:jarvis-api:1.1.1") - include("moe.nea.jarvis:jarvis-fabric:1.1.1") - modLocalRuntime("moe.nea.jarvis:jarvis-fabric:1.1.1") - modImplementation "maven.modrinth:modmenu:9.0.0" - modLocalRuntime "maven.modrinth:modmenu:9.0.0" + modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" + modImplementation "net.fabricmc:fabric-language-kotlin:${project.fabric_kotlin_version}" + modRuntimeOnly("me.djtheredstoner:DevAuth-fabric:1.1.2") + implementation "meteordevelopment:orbit:0.2.3" + include "meteordevelopment:orbit:0.2.3" + modApi "me.shedaniel.cloth:cloth-config-fabric:14.0.126" + include "me.shedaniel.cloth:cloth-config-fabric:14.0.126" + modImplementation("moe.nea.jarvis:jarvis-api:1.1.1") + include("moe.nea.jarvis:jarvis-fabric:1.1.1") { + exclude(group: "net.fabricmc.fabric-api") + } + modLocalRuntime("moe.nea.jarvis:jarvis-fabric:1.1.1") { + exclude(group: "net.fabricmc.fabric-api") + } + modImplementation "maven.modrinth:modmenu:10.0.0-beta.1" + modLocalRuntime "maven.modrinth:modmenu:10.0.0-beta.1" } loom { - runs { - removeIf { it.name != "client" } - named("client") { - property("devauth.enabled", "true") - property("fabric.log.level", "info") - vmArg("-ea") - vmArg("-XX:+AllowEnhancedClassRedefinition") - /*vmArg("-XX:HotswapAgent=external") - vmArg("-javaagent:/home/ronald/Software-Packages/hotswap-agent-1.4.2-SNAPSHOT.jar")*/ - } - } - accessWidenerPath = file("src/main/resources/dulkirmod.accesswidener") + runs { + removeIf { it.name != "client" } + named("client") { + property("devauth.enabled", "true") + property("fabric.log.level", "info") + vmArg("-ea") + vmArg("-XX:+AllowEnhancedClassRedefinition") + /*vmArg("-XX:HotswapAgent=external") + vmArg("-javaagent:/home/ronald/Software-Packages/hotswap-agent-1.4.2-SNAPSHOT.jar")*/ + } + } + accessWidenerPath = file("src/main/resources/dulkirmod.accesswidener") } processResources { - inputs.property "version", project.version + inputs.property "version", project.version - filesMatching("fabric.mod.json") { - expand "version": project.version - } + filesMatching("fabric.mod.json") { + expand "version": project.version + } } tasks.withType(JavaCompile).configureEach { - it.options.encoding = "UTF-8" - it.options.release = 17 + it.options.encoding = "UTF-8" + it.options.release = 21 } tasks.withType(KotlinCompile).configureEach { - kotlinOptions.jvmTarget = 17 + kotlinOptions.jvmTarget = 21 } java { - withSourcesJar() + withSourcesJar() - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 + sourceCompatibility = JavaVersion.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 } jar { - from("LICENSE") { - rename { "${it}_${base.archivesName.get()}"} - } + from("LICENSE") { + rename { "${it}_${base.archivesName.get()}" } + } }
\ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 3890e4f..9634e5c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,15 +4,15 @@ org.gradle.parallel=true # Fabric Properties # check these on https://fabricmc.net/develop -minecraft_version=1.20.4 -yarn_mappings=1.20.4+build.3 -loader_version=0.15.6 -fabric_kotlin_version=1.10.17+kotlin.1.9.22 +minecraft_version=1.20.6 +yarn_mappings=1.20.6+build.1 +loader_version=0.15.11 +fabric_kotlin_version=1.10.19+kotlin.1.9.23 # Mod Properties -mod_version=1.0.3 +mod_version=1.0.4 maven_group=com.dulkirfabric archives_base_name=dulkirmod-fabric # Dependencies -fabric_version=0.94.1+1.20.4
\ No newline at end of file +fabric_version=0.98.0+1.20.6
\ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 3499ded..20db9ad 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/java/com/dulkirfabric/mixin/ItemStackMixin.java b/src/main/java/com/dulkirfabric/mixin/ItemStackMixin.java index 7820bf3..f083290 100644 --- a/src/main/java/com/dulkirfabric/mixin/ItemStackMixin.java +++ b/src/main/java/com/dulkirfabric/mixin/ItemStackMixin.java @@ -1,7 +1,7 @@ package com.dulkirfabric.mixin; import com.dulkirfabric.util.render.ItemChangeHandler; -import net.minecraft.client.item.TooltipContext; +import net.minecraft.client.item.TooltipType; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -20,7 +20,7 @@ public abstract class ItemStackMixin { @Shadow public abstract Item getItem(); @Inject(method = "getTooltip", at = @At("HEAD")) - private void onGetTooltip(@Nullable PlayerEntity player, TooltipContext context, CallbackInfoReturnable<List<Text>> cir) { + private void onGetTooltip(Item.TooltipContext context, @Nullable PlayerEntity player, TooltipType type, CallbackInfoReturnable<List<Text>> cir) { ItemChangeHandler.INSTANCE.handle(this.getItem().getName().getString()); } } diff --git a/src/main/java/com/dulkirfabric/mixin/io/MouseMixin.java b/src/main/java/com/dulkirfabric/mixin/io/MouseMixin.java index 76dd828..d805170 100644 --- a/src/main/java/com/dulkirfabric/mixin/io/MouseMixin.java +++ b/src/main/java/com/dulkirfabric/mixin/io/MouseMixin.java @@ -19,16 +19,6 @@ public class MouseMixin { return (int) (originalScaledHeight / InventoryScale.INSTANCE.getScale()); } - @ModifyExpressionValue(method = "onCursorPos", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/Window;getScaledWidth()I")) - public int onCursorPosWidth(int originalScaledWidth) { - return (int) (originalScaledWidth / InventoryScale.INSTANCE.getScale()); - } - - @ModifyExpressionValue(method = "onCursorPos", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/Window;getScaledHeight()I")) - public int onCursorPosHeight(int originalScaledHeight) { - return (int) (originalScaledHeight / InventoryScale.INSTANCE.getScale()); - } - @ModifyExpressionValue(method = "onMouseScroll", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/Window;getScaledWidth()I")) public int onMouseScrollWidth(int originalScaledWidth) { return (int) (originalScaledWidth / InventoryScale.INSTANCE.getScale()); diff --git a/src/main/java/com/dulkirfabric/mixin/render/InGameHudMixin.java b/src/main/java/com/dulkirfabric/mixin/render/InGameHudMixin.java index 995b8af..7ab1671 100644 --- a/src/main/java/com/dulkirfabric/mixin/render/InGameHudMixin.java +++ b/src/main/java/com/dulkirfabric/mixin/render/InGameHudMixin.java @@ -3,14 +3,14 @@ package com.dulkirfabric.mixin.render; import com.dulkirfabric.config.DulkirConfig; import com.dulkirfabric.util.Utils; import com.llamalad7.mixinextras.injector.ModifyExpressionValue; -import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.hud.InGameHud; -import net.minecraft.text.Text; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.scoreboard.number.BlankNumberFormat; +import net.minecraft.scoreboard.number.NumberFormat; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(InGameHud.class) @@ -21,36 +21,32 @@ public class InGameHudMixin { at = @At("HEAD"), cancellable = true ) - public void onRenderStatusEffectOverlay(DrawContext context, CallbackInfo ci) { + public void onRenderStatusEffectOverlay(DrawContext context, float tickDelta, CallbackInfo ci) { if (DulkirConfig.ConfigVars.getConfigOptions().getStatusEffectHidden()) { ci.cancel(); } } - @Redirect( - method = "method_55440([Lnet/minecraft/client/gui/hud/InGameHud$SidebarEntry;ILnet/minecraft/client/gui/DrawContext;Lnet/minecraft/text/Text;I)V", + @ModifyExpressionValue( + method = "renderScoreboardSidebar(Lnet/minecraft/client/gui/DrawContext;Lnet/minecraft/scoreboard/ScoreboardObjective;)V", at = @At( value = "INVOKE", - target = "Lnet/minecraft/client/gui/DrawContext;drawText(Lnet/minecraft/client/font/TextRenderer;Lnet/minecraft/text/Text;IIIZ)I", - ordinal = 2 + target = "Lnet/minecraft/scoreboard/ScoreboardObjective;getNumberFormatOr(Lnet/minecraft/scoreboard/number/NumberFormat;)Lnet/minecraft/scoreboard/number/NumberFormat;" ) ) - public int removeScoreBoardNumbers(DrawContext instance, TextRenderer textRenderer, Text text, int x, int y, int color, boolean shadow) { - return 0; + public NumberFormat removeScoreBoardNumbers(NumberFormat original) { + return BlankNumberFormat.INSTANCE; } - @ModifyExpressionValue( - method = "renderStatusBars(Lnet/minecraft/client/gui/DrawContext;)V", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/entity/player/PlayerEntity;getArmor()I" - ) + @Inject( + method = "renderArmor", + at = @At("HEAD"), + cancellable = true ) - public int onGrabArmorAmount(int original) { + private static void onGrabArmorAmount(DrawContext context, PlayerEntity player, int i, int j, int k, int x, CallbackInfo ci) { if (DulkirConfig.ConfigVars.getConfigOptions().getHideArmorOverlay() && Utils.INSTANCE.isInSkyblock()) { - return 0; + ci.cancel(); } - return original; } @ModifyExpressionValue( diff --git a/src/main/java/com/dulkirfabric/mixin/render/LoomScreenMixin.java b/src/main/java/com/dulkirfabric/mixin/render/LoomScreenMixin.java deleted file mode 100644 index 0270251..0000000 --- a/src/main/java/com/dulkirfabric/mixin/render/LoomScreenMixin.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.dulkirfabric.mixin.render; - -import com.dulkirfabric.features.InventoryScale; -import net.minecraft.block.entity.BannerPattern; -import net.minecraft.client.gui.DrawContext; -import net.minecraft.client.gui.screen.ingame.LoomScreen; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NbtCompound; -import net.minecraft.nbt.NbtList; -import net.minecraft.registry.entry.RegistryEntry; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; - -@Mixin(LoomScreen.class) -public class LoomScreenMixin { - @Inject(method = "drawBanner", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/math/MatrixStack;push()V", shift = At.Shift.AFTER), locals = LocalCapture.CAPTURE_FAILHARD) - public void onCreateMatrix(DrawContext context, RegistryEntry<BannerPattern> pattern, int x, int y, CallbackInfo ci, NbtCompound nbtCompound, NbtList nbtList, ItemStack itemStack, MatrixStack matrixStack) { - matrixStack.scale(InventoryScale.INSTANCE.getScale(), InventoryScale.INSTANCE.getScale(), 1F); - } -} - diff --git a/src/main/java/com/dulkirfabric/mixin/render/WorldRendererMixin.java b/src/main/java/com/dulkirfabric/mixin/render/WorldRendererMixin.java index 58558e0..676cccf 100644 --- a/src/main/java/com/dulkirfabric/mixin/render/WorldRendererMixin.java +++ b/src/main/java/com/dulkirfabric/mixin/render/WorldRendererMixin.java @@ -11,7 +11,7 @@ import org.spongepowered.asm.mixin.injection.At; @Mixin(WorldRenderer.class) public class WorldRendererMixin { - @ModifyExpressionValue(method = "render(Lnet/minecraft/client/util/math/MatrixStack;FJZLnet/minecraft/client/render/Camera;Lnet/minecraft/client/render/GameRenderer;Lnet/minecraft/client/render/LightmapTextureManager;Lorg/joml/Matrix4f;)V", + @ModifyExpressionValue(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;getTeamColorValue()I")) public int getGlowColor(int existing, @Local Entity entity) { if (entity instanceof GlowingEntityInterface dEntity) { diff --git a/src/main/kotlin/com/dulkirfabric/Registrations.kt b/src/main/kotlin/com/dulkirfabric/Registrations.kt index 355abb8..f47182b 100644 --- a/src/main/kotlin/com/dulkirfabric/Registrations.kt +++ b/src/main/kotlin/com/dulkirfabric/Registrations.kt @@ -126,7 +126,12 @@ object Registrations { ModifyCommandEvent(command).also { it.post() }.command } - WorldRenderEvents.END.register { context -> WorldRenderLastEvent(context).post() } + WorldRenderEvents.END.register { context -> + WorldRenderLastEvent( + context, + context.matrixStack()!! // Not null assertion is safe here since this is late enough in rendering + ).post() + } ScreenEvents.BEFORE_INIT.register( ScreenEvents.BeforeInit { client, screen, scaledWidth, scaledHeight -> diff --git a/src/main/kotlin/com/dulkirfabric/events/WorldRenderLastEvent.kt b/src/main/kotlin/com/dulkirfabric/events/WorldRenderLastEvent.kt index 11b7714..e91c2f3 100644 --- a/src/main/kotlin/com/dulkirfabric/events/WorldRenderLastEvent.kt +++ b/src/main/kotlin/com/dulkirfabric/events/WorldRenderLastEvent.kt @@ -2,6 +2,7 @@ package com.dulkirfabric.events import com.dulkirfabric.events.base.Event import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext +import net.minecraft.client.util.math.MatrixStack data class -WorldRenderLastEvent(val context: WorldRenderContext): Event() +WorldRenderLastEvent(val context: WorldRenderContext, val matrixStack: MatrixStack): Event() diff --git a/src/main/kotlin/com/dulkirfabric/features/AotvHighlight.kt b/src/main/kotlin/com/dulkirfabric/features/AotvHighlight.kt index 5cce244..5b1a81d 100644 --- a/src/main/kotlin/com/dulkirfabric/features/AotvHighlight.kt +++ b/src/main/kotlin/com/dulkirfabric/features/AotvHighlight.kt @@ -10,7 +10,9 @@ import com.dulkirfabric.util.render.WorldRenderUtils import meteordevelopment.orbit.EventHandler import net.minecraft.client.MinecraftClient import net.minecraft.client.util.InputUtil +import net.minecraft.component.DataComponentTypes import net.minecraft.entity.Entity +import net.minecraft.nbt.NbtString import net.minecraft.util.hit.BlockHitResult import net.minecraft.util.hit.HitResult import net.minecraft.util.math.BlockPos @@ -29,14 +31,9 @@ object AotvHighlight { fun getHeldItemID(): String { val stack = mc.player?.mainHandStack ?: return "" - val tag = stack.nbt ?: return "" - val id = tag.getCompound("ExtraAttributes").get("id") ?: return "" - return id.toString().trim('"') - } - - @EventHandler - fun onLong(event: LongUpdateEvent) { - //println(heldItemID) + val tag = stack.get(DataComponentTypes.CUSTOM_DATA)?.nbt ?: return "" + val id = tag.get("id") as? NbtString ?: return "" + return id.asString() } @EventHandler diff --git a/src/main/kotlin/com/dulkirfabric/features/BrokenHyp.kt b/src/main/kotlin/com/dulkirfabric/features/BrokenHyp.kt index 85c1f7b..713a9d1 100644 --- a/src/main/kotlin/com/dulkirfabric/features/BrokenHyp.kt +++ b/src/main/kotlin/com/dulkirfabric/features/BrokenHyp.kt @@ -6,6 +6,7 @@ import com.dulkirfabric.events.LongUpdateEvent import com.dulkirfabric.util.TablistUtils import com.dulkirfabric.util.render.HudRenderUtil import meteordevelopment.orbit.EventHandler +import net.minecraft.component.DataComponentTypes import net.minecraft.item.ItemStack import net.minecraft.text.Style import net.minecraft.text.Text @@ -29,11 +30,11 @@ object BrokenHyp { val stack: ItemStack = mc.player?.mainHandStack ?: return // get info about held item - val tag = stack.nbt ?: return - id = tag.getCompound("ExtraAttributes")?.getString("id") ?: "" + val tag = stack.get(DataComponentTypes.CUSTOM_DATA)?.nbt ?: return + id = tag.getString("id") ?: "" - kill = tag.getCompound("ExtraAttributes")?.getInt("stats_book") ?: -1 - championXp = tag.getCompound("ExtraAttributes")?.getDouble("champion_combat_xp") ?: -1.0 + kill = tag.getInt("stats_book") ?: -1 + championXp = tag.getDouble("champion_combat_xp") ?: -1.0 // check if a wither blade, then check if same id if (!(id matches "(HYPERION|ASTRAEA|SCYLLA|VALKYRIE)".toRegex())) { diff --git a/src/main/kotlin/com/dulkirfabric/features/CooldownDisplays.kt b/src/main/kotlin/com/dulkirfabric/features/CooldownDisplays.kt index 0476d51..e562a2e 100644 --- a/src/main/kotlin/com/dulkirfabric/features/CooldownDisplays.kt +++ b/src/main/kotlin/com/dulkirfabric/features/CooldownDisplays.kt @@ -8,6 +8,7 @@ import com.dulkirfabric.util.TrackedCooldown import com.dulkirfabric.util.Utils import meteordevelopment.orbit.EventHandler import net.minecraft.client.sound.Sound +import net.minecraft.component.DataComponentTypes import net.minecraft.item.ItemStack import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable import kotlin.math.round @@ -89,8 +90,8 @@ object CooldownDisplays { } private fun fetchCooldownItem(stack: ItemStack): TrackedCooldown? { - val tag = stack.nbt ?: return null - val id = tag.getCompound("ExtraAttributes").get("id") ?: return null + val tag = stack.get(DataComponentTypes.CUSTOM_DATA)?.nbt ?: return null + val id = tag.get("id") ?: return null val idStr = id.toString().trim('"') trackedCooldowns.forEach { if (idStr matches it.value.itemID) diff --git a/src/main/kotlin/com/dulkirfabric/util/Utils.kt b/src/main/kotlin/com/dulkirfabric/util/Utils.kt index 342dc48..e6342cb 100644 --- a/src/main/kotlin/com/dulkirfabric/util/Utils.kt +++ b/src/main/kotlin/com/dulkirfabric/util/Utils.kt @@ -6,6 +6,7 @@ import com.dulkirfabric.events.WorldLoadEvent import com.dulkirfabric.events.chat.ChatEvents import meteordevelopment.orbit.EventHandler import net.minecraft.block.entity.SkullBlockEntity +import net.minecraft.component.DataComponentTypes import net.minecraft.entity.Entity import net.minecraft.item.ItemStack import net.minecraft.nbt.NbtHelper @@ -72,7 +73,7 @@ object Utils { } fun getSkullTexture(itemStack: ItemStack): String? { - return itemStack.getSubNbt(SkullBlockEntity.SKULL_OWNER_KEY)?.let(NbtHelper::toGameProfile)?.properties?.get( + return itemStack.get(DataComponentTypes.PROFILE)?.properties?.get( "textures")?.first()?.value } }
\ No newline at end of file diff --git a/src/main/kotlin/com/dulkirfabric/util/render/WorldRenderUtils.kt b/src/main/kotlin/com/dulkirfabric/util/render/WorldRenderUtils.kt index d779c23..d1cdab1 100644 --- a/src/main/kotlin/com/dulkirfabric/util/render/WorldRenderUtils.kt +++ b/src/main/kotlin/com/dulkirfabric/util/render/WorldRenderUtils.kt @@ -41,10 +41,10 @@ object WorldRenderUtils { private fun line(matrix: MatrixStack.Entry, buffer: BufferBuilder, from: Vector3f, to: Vector3f) { val normal = to.sub(from, Vector3f()).mul(-1F) - buffer.vertex(matrix.positionMatrix, from.x, from.y, from.z) - .normal(matrix.normalMatrix, normal.x, normal.y, normal.z).next() - buffer.vertex(matrix.positionMatrix, to.x, to.y, to.z) - .normal(matrix.normalMatrix, normal.x, normal.y, normal.z) + buffer.vertex(matrix, from.x, from.y, from.z) + .normal(matrix, normal.x, normal.y, normal.z).next() + buffer.vertex(matrix, to.x, to.y, to.z) + .normal(matrix, normal.x, normal.y, normal.z) .next() } @@ -60,7 +60,7 @@ object WorldRenderUtils { thickness: Float, depthTest: Boolean = true ) { - val matrices = context.matrixStack() + val matrices = context.assertHasMatrixStack() ?: return matrices.push() val prevShader = RenderSystem.getShader() RenderSystem.setShader(GameRenderer::getRenderTypeLinesProgram) @@ -114,12 +114,17 @@ object WorldRenderUtils { matrices.pop() } + fun WorldRenderContext.assertHasMatrixStack(): MatrixStack? { + assert(matrixStack() != null) + return matrixStack() + } + /** * This draw line function is intended to be used for drawing very few lines, as it's not the most efficient. * For drawing many lines in a series, save them to an array and use the drawLineArray function. */ fun drawLine(context: WorldRenderContext, startPos: Vec3d, endPos: Vec3d, color: Color, thickness: Float, depthTest: Boolean = true) { - val matrices = context.matrixStack() + val matrices = context.assertHasMatrixStack() ?: return matrices.push() val prevShader = RenderSystem.getShader() RenderSystem.setShader(GameRenderer::getRenderTypeLinesProgram) @@ -162,7 +167,7 @@ object WorldRenderUtils { * drawLine function being called many times in series. */ fun drawLineArray(context: WorldRenderContext, posArr: List<Vec3d>, color: Color, thickness: Float, depthTest: Boolean = true) { - val matrices = context.matrixStack() + val matrices = context.assertHasMatrixStack() ?: return matrices.push() val prevShader = RenderSystem.getShader() RenderSystem.setShader(GameRenderer::getRenderTypeLinesProgram) @@ -217,6 +222,7 @@ object WorldRenderUtils { depthTest: Boolean = true, scale: Float = 1f ) { + val matrices = context.assertHasMatrixStack() ?: return if (!depthTest) { RenderSystem.disableDepthTest() } @@ -224,8 +230,7 @@ object WorldRenderUtils { RenderSystem.defaultBlendFunc() RenderSystem.disableCull() - val vertexConsumer = context.worldRenderer().bufferBuilders.entityVertexConsumers - val matrices = context.matrixStack() + val vertexConsumer = context.worldRenderer().bufferBuilders.entityVertexConsumers matrices.push() matrices.translate( pos.x - context.camera().pos.x, @@ -277,13 +282,13 @@ object WorldRenderUtils { pos: Vec3d, ) { + val matrices = context.assertHasMatrixStack() ?: return RenderSystem.disableDepthTest() RenderSystem.enableBlend() RenderSystem.defaultBlendFunc() RenderSystem.disableCull() val d: Double = pos.distanceTo(MinecraftClient.getInstance().player?.pos) val distText = Text.literal(d.toInt().toString() + "m").setStyle(Style.EMPTY.withColor(Formatting.YELLOW)) - val matrices = context.matrixStack() val vertexConsumer = context.worldRenderer().bufferBuilders.entityVertexConsumers matrices.push() val magnitude = sqrt((pos.x - context.camera().pos.x).pow(2) + @@ -365,6 +370,7 @@ object WorldRenderUtils { color: Color, depthTest: Boolean ) { + val matrices = context.assertHasMatrixStack() ?: return if (!depthTest) { RenderSystem.disableDepthTest() //RenderSystem.depthMask(false) @@ -375,7 +381,6 @@ object WorldRenderUtils { RenderSystem.enableBlend() RenderSystem.defaultBlendFunc() - val matrices = context.matrixStack() val tes = Tessellator.getInstance() tes.buffer.begin(VertexFormat.DrawMode.TRIANGLE_STRIP, VertexFormats.POSITION_COLOR) matrices.push() diff --git a/src/main/resources/dulkirmod-fabric.mixins.json b/src/main/resources/dulkirmod-fabric.mixins.json index 310dd23..c97509b 100644 --- a/src/main/resources/dulkirmod-fabric.mixins.json +++ b/src/main/resources/dulkirmod-fabric.mixins.json @@ -17,7 +17,6 @@ "render.HeldItemRendererMixin", "render.InGameHudMixin", "render.InGameOverlayRendererMixin", - "render.LoomScreenMixin", "render.MinecraftClientMixin", "render.ParticleManagerMixin", "render.PerspectiveMixin", diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index fabcfeb..2ae0320 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -35,11 +35,11 @@ "dulkirmod-fabric.mixins.json" ], "depends": { - "fabricloader": ">=0.14.21", - "minecraft": "~1.20.1", - "java": ">=17", - "fabric-api": ">=0.86.0+1.20.1", - "fabric-language-kotlin": ">=1.8.21" + "fabricloader": ">=0.15.0", + "minecraft": "~1.20.6", + "java": ">=21", + "fabric-api": ">=0.98.0+1.20.6", + "fabric-language-kotlin": ">=1.9.23" }, "suggests": { "Farsight": "https://www.curseforge.com/minecraft/mc-mods/farsight-fabric/files", |