diff --git a/common/src/main/java/org/embeddedt/modernfix/common/mixin/safety/DynamicTextureMixin.java b/common/src/main/java/org/embeddedt/modernfix/common/mixin/safety/DynamicTextureMixin.java deleted file mode 100644 index 388cc1eb..00000000 --- a/common/src/main/java/org/embeddedt/modernfix/common/mixin/safety/DynamicTextureMixin.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.embeddedt.modernfix.common.mixin.safety; - -import com.mojang.blaze3d.platform.NativeImage; -import net.minecraft.client.renderer.texture.DynamicTexture; -import org.embeddedt.modernfix.ModernFix; -import org.jetbrains.annotations.Nullable; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -@Mixin(DynamicTexture.class) -public class DynamicTextureMixin { - @Shadow @Nullable private NativeImage pixels; - - @Redirect(method = "(Lcom/mojang/blaze3d/platform/NativeImage;)V", at = @At(value = "FIELD", target = "Lnet/minecraft/client/renderer/texture/DynamicTexture;pixels:Lcom/mojang/blaze3d/platform/NativeImage;", ordinal = 0)) - private void putNewPixel(DynamicTexture texture, NativeImage pixels) { - if(pixels == null) { - ModernFix.LOGGER.error("Null image provided to DynamicTexture", new Exception()); - pixels = new NativeImage(4, 4, false); - } - this.pixels = pixels; - } -} diff --git a/fabric/src/main/java/org/embeddedt/modernfix/fabric/mixin/safety/DynamicTextureMixin.java b/fabric/src/main/java/org/embeddedt/modernfix/fabric/mixin/safety/DynamicTextureMixin.java new file mode 100644 index 00000000..5cc7f1ac --- /dev/null +++ b/fabric/src/main/java/org/embeddedt/modernfix/fabric/mixin/safety/DynamicTextureMixin.java @@ -0,0 +1,30 @@ +package org.embeddedt.modernfix.fabric.mixin.safety; + +import com.mojang.blaze3d.platform.NativeImage; +import net.minecraft.client.renderer.texture.DynamicTexture; +import org.embeddedt.modernfix.ModernFix; +import org.jetbrains.annotations.Nullable; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(DynamicTexture.class) +public class DynamicTextureMixin { + @Shadow @Nullable private NativeImage pixels; + + private Exception closeTrace; + + @Inject(method = "method_22793", at = @At(value = "FIELD", target = "Lnet/minecraft/client/renderer/texture/DynamicTexture;pixels:Lcom/mojang/blaze3d/platform/NativeImage;", ordinal = 0)) + private void checkNullPixels(CallbackInfo ci) { + if(pixels == null) { + ModernFix.LOGGER.error("Attempted to upload null texture! This is not allowed, closed here", closeTrace); + } + } + + @Inject(method = "close", at = @At("HEAD")) + private void storeCloseTrace(CallbackInfo ci) { + closeTrace = new Exception(); + } +}