diff options
author | inglettronald <inglettronald@gmail.com> | 2023-07-23 08:28:08 -0500 |
---|---|---|
committer | inglettronald <inglettronald@gmail.com> | 2023-07-23 08:28:08 -0500 |
commit | 6028973423c664e4a4626c577f4884cc4d92cbe0 (patch) | |
tree | d09fa6974290af6cac621e4a33d77a334cb2456d /src | |
parent | 4e8e3ae91f8be1906c298bf7b0aceb1b39d083d3 (diff) | |
download | DulkirMod-Fabric-6028973423c664e4a4626c577f4884cc4d92cbe0.tar.gz DulkirMod-Fabric-6028973423c664e4a4626c577f4884cc4d92cbe0.tar.bz2 DulkirMod-Fabric-6028973423c664e4a4626c577f4884cc4d92cbe0.zip |
performance improvements
Diffstat (limited to 'src')
5 files changed, 6 insertions, 78 deletions
diff --git a/src/main/java/com/dulkirfabric/mixin/render/LivingEntityMixin.java b/src/main/java/com/dulkirfabric/mixin/render/LivingEntityMixin.java index b615136..8c5f48c 100644 --- a/src/main/java/com/dulkirfabric/mixin/render/LivingEntityMixin.java +++ b/src/main/java/com/dulkirfabric/mixin/render/LivingEntityMixin.java @@ -34,10 +34,9 @@ public class LivingEntityMixin implements GlowingEntityInterface { private boolean shouldESP_DulkirMod; @Override - public void setDulkirEntityGlow(boolean shouldGlow, @NotNull Color glowColor, boolean shouldESP) { + public void setDulkirEntityGlow(boolean shouldGlow, @NotNull Color glowColor) { this.shouldGlow_DulkirMod = shouldGlow; this.glowColor_DulkirMod = glowColor; - this.shouldESP_DulkirMod = shouldESP; } @Override @@ -51,11 +50,6 @@ public class LivingEntityMixin implements GlowingEntityInterface { return glowColor_DulkirMod; } - @Override - public boolean shouldDulkirEntityESP() { - return shouldESP_DulkirMod; - } - @Inject(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;tickNewAi()V", shift = At.Shift.AFTER)) public void onWhatever(CallbackInfo ci) { diff --git a/src/main/java/com/dulkirfabric/mixin/render/WorldRendererMixin.java b/src/main/java/com/dulkirfabric/mixin/render/WorldRendererMixin.java index 03ffbd0..a843de0 100644 --- a/src/main/java/com/dulkirfabric/mixin/render/WorldRendererMixin.java +++ b/src/main/java/com/dulkirfabric/mixin/render/WorldRendererMixin.java @@ -3,40 +3,14 @@ package com.dulkirfabric.mixin.render; import com.dulkirfabric.util.GlowingEntityInterface; import com.llamalad7.mixinextras.injector.ModifyExpressionValue; import com.llamalad7.mixinextras.sugar.Local; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gl.Framebuffer; -import net.minecraft.client.gl.SimpleFramebuffer; -import net.minecraft.client.render.*; -import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.client.render.WorldRenderer; import net.minecraft.entity.Entity; -import org.jetbrains.annotations.Nullable; -import org.joml.Matrix4f; -import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.Unique; 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.CallbackInfoReturnable; - -import static com.dulkirfabric.DulkirModFabric.mc; @Mixin(WorldRenderer.class) public class WorldRendererMixin { - @Shadow - private @Nullable Framebuffer entityOutlinesFramebuffer; - @Shadow - @Final - public BufferBuilderStorage bufferBuilders; - @Shadow @Final private MinecraftClient client; - @Unique - boolean shouldRenderOutlinesDirect = false; - - @Unique - Framebuffer defaultEntityOutlineBuffer; - @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", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;getTeamColorValue()I")) public int getGlowColor(int existing, @Local Entity entity) { @@ -48,36 +22,4 @@ public class WorldRendererMixin { return existing; } - @Inject(method = "onResized", at = @At("HEAD")) - public void onResized(int width, int height, CallbackInfo ci) { - if (defaultEntityOutlineBuffer == null) { - defaultEntityOutlineBuffer = new SimpleFramebuffer(width, height, true, false); - defaultEntityOutlineBuffer.setClearColor(0, 0, 0, 0); - } else { - defaultEntityOutlineBuffer.resize(width, height, false); - } - } - - @Inject(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", - at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/BufferBuilderStorage;getEntityVertexConsumers()Lnet/minecraft/client/render/VertexConsumerProvider$Immediate;", shift = At.Shift.AFTER)) - public void saveDefaultBufferESP(MatrixStack matrices, float tickDelta, long limitTime, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightmapTextureManager lightmapTextureManager, Matrix4f positionMatrix, CallbackInfo ci) { - if (defaultEntityOutlineBuffer != null) { - defaultEntityOutlineBuffer.copyDepthFrom(this.entityOutlinesFramebuffer); - } - } - - @Inject(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", - at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/entity/EntityRenderDispatcher;shouldRender(Lnet/minecraft/entity/Entity;Lnet/minecraft/client/render/Frustum;DDD)Z")) - public void setOutlineESP(MatrixStack matrices, float tickDelta, long limitTime, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightmapTextureManager lightmapTextureManager, Matrix4f positionMatrix, CallbackInfo ci, @Local Entity entity) { - this.bufferBuilders.getEntityVertexConsumers().drawCurrentLayer(); - if (entity instanceof GlowingEntityInterface dEntity && dEntity.shouldDulkirEntityGlow() && !dEntity.shouldDulkirEntityESP()) { - if (this.entityOutlinesFramebuffer != null) - this.entityOutlinesFramebuffer.copyDepthFrom(mc.getFramebuffer()); - } else { - // give esp back here - if (this.entityOutlinesFramebuffer != null) - this.entityOutlinesFramebuffer.copyDepthFrom(defaultEntityOutlineBuffer); - } - this.client.getFramebuffer().beginWrite(false); - } } diff --git a/src/main/kotlin/com/dulkirfabric/features/RenderTest.kt b/src/main/kotlin/com/dulkirfabric/features/RenderTest.kt index 6d64bac..d747b93 100644 --- a/src/main/kotlin/com/dulkirfabric/features/RenderTest.kt +++ b/src/main/kotlin/com/dulkirfabric/features/RenderTest.kt @@ -1,14 +1,10 @@ package com.dulkirfabric.features -import com.dulkirfabric.DulkirModFabric.mc import com.dulkirfabric.events.EntityLoadEvent import com.dulkirfabric.events.HudRenderEvent import com.dulkirfabric.events.WorldRenderLastEvent -import com.dulkirfabric.util.GlowingEntityInterface -import com.dulkirfabric.util.HudRenderUtil import com.dulkirfabric.util.WorldRenderUtils import meteordevelopment.orbit.EventHandler -import net.minecraft.client.gui.DrawContext import net.minecraft.text.Style import net.minecraft.text.Text import net.minecraft.util.math.Vec3d diff --git a/src/main/kotlin/com/dulkirfabric/util/GlowingEntityInterface.kt b/src/main/kotlin/com/dulkirfabric/util/GlowingEntityInterface.kt index 9b129fd..e676736 100644 --- a/src/main/kotlin/com/dulkirfabric/util/GlowingEntityInterface.kt +++ b/src/main/kotlin/com/dulkirfabric/util/GlowingEntityInterface.kt @@ -3,11 +3,9 @@ package com.dulkirfabric.util import java.awt.Color interface GlowingEntityInterface { - fun setDulkirEntityGlow(shouldGlow: Boolean = false, glowColor: Color, shouldESP: Boolean = false) + fun setDulkirEntityGlow(shouldGlow: Boolean = false, glowColor: Color) fun shouldDulkirEntityGlow() : Boolean fun getDulkirEntityGlowColor() : Color? - - fun shouldDulkirEntityESP() : Boolean }
\ No newline at end of file diff --git a/src/main/kotlin/com/dulkirfabric/util/HudRenderUtil.kt b/src/main/kotlin/com/dulkirfabric/util/HudRenderUtil.kt index 40840d9..02b79f7 100644 --- a/src/main/kotlin/com/dulkirfabric/util/HudRenderUtil.kt +++ b/src/main/kotlin/com/dulkirfabric/util/HudRenderUtil.kt @@ -1,8 +1,6 @@ package com.dulkirfabric.util import com.dulkirfabric.DulkirModFabric.mc -import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext -import net.minecraft.client.font.TextRenderer import net.minecraft.client.gui.DrawContext import net.minecraft.text.Text @@ -11,11 +9,11 @@ object HudRenderUtil { val matrices = context.matrices val tr = mc.textRenderer val w = tr.getWidth(content) - val sf: Float = mc.window.scaledWidth / w.toFloat() + val sf: Float = mc.window.scaledWidth / w.toFloat() / 3 matrices.push() - matrices.translate(mc.currentScreen!!.width / 3f, mc.window.scaledHeight / 2f, - 0f) + matrices.translate(mc.window.scaledWidth / 3f, mc.window.scaledHeight / 2f, 0f) matrices.scale(sf, sf, 1f) context.drawText(tr, content, 0, -tr.fontHeight / 2, -1, true) + matrices.pop() } }
\ No newline at end of file |