Actually fix android glitches on death

This commit is contained in:
DBotThePony 2022-10-22 00:54:26 +07:00
parent 667553fb3d
commit 32f5b2ece9
Signed by: DBot
GPG Key ID: DCC23B5715498507

View File

@ -17,6 +17,7 @@ import net.minecraft.client.Minecraft
import net.minecraft.client.renderer.GameRenderer import net.minecraft.client.renderer.GameRenderer
import net.minecraft.core.Vec3i import net.minecraft.core.Vec3i
import net.minecraft.world.level.levelgen.XoroshiroRandomSource import net.minecraft.world.level.levelgen.XoroshiroRandomSource
import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability
import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.capability.matteryPlayer
import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.minecraft
import ru.dbotthepony.mc.otm.core.component1 import ru.dbotthepony.mc.otm.core.component1
@ -24,6 +25,7 @@ import ru.dbotthepony.mc.otm.core.component2
import ru.dbotthepony.mc.otm.core.component3 import ru.dbotthepony.mc.otm.core.component3
import ru.dbotthepony.mc.otm.core.linearInterpolation import ru.dbotthepony.mc.otm.core.linearInterpolation
import ru.dbotthepony.mc.otm.milliTime import ru.dbotthepony.mc.otm.milliTime
import java.lang.ref.WeakReference
import java.util.stream.Collectors import java.util.stream.Collectors
import kotlin.math.absoluteValue import kotlin.math.absoluteValue
import kotlin.math.ceil import kotlin.math.ceil
@ -415,12 +417,17 @@ object GlitchRenderer {
private const val GLITCH_BLOCK_SIZE = 8f private const val GLITCH_BLOCK_SIZE = 8f
private var lastAndroid: WeakReference<MatteryPlayerCapability>? = null
@JvmStatic @JvmStatic
fun render() { fun render() {
if (System.nanoTime() - glitchSince >= glitchUntil && (minecraft.player?.matteryPlayer?.isAndroid != true || minecraft.player?.isAlive != false)) { if (System.nanoTime() - glitchSince >= glitchUntil && ((minecraft.player?.matteryPlayer ?: lastAndroid?.get())?.isAndroid != true || minecraft.player?.isAlive != false)) {
return return
} }
if (lastAndroid?.get() !== minecraft.player?.matteryPlayer)
lastAndroid = WeakReference(minecraft.player?.matteryPlayer!!)
val glitchBuffer = glitchBuffer val glitchBuffer = glitchBuffer
val projection = RenderSystem.getProjectionMatrix() val projection = RenderSystem.getProjectionMatrix()
RenderSystem.setProjectionMatrix(Matrix4f().also { it.setIdentity() }) RenderSystem.setProjectionMatrix(Matrix4f().also { it.setIdentity() })