From 877ab5b0fbff431799e7ad8c00cddaef3a21b0a0 Mon Sep 17 00:00:00 2001 From: Hendrix-Shen Date: Sun, 27 Aug 2023 10:50:40 +0800 Subject: [PATCH] Try to fix a potential crash issue (#101) Signed-off-by: Hendrix-Shen --- .../inventoryPreviewUseCache/MixinMixinRenderUtils.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/plusls/MasaGadget/mixin/tweakeroo/inventoryPreviewUseCache/MixinMixinRenderUtils.java b/src/main/java/com/plusls/MasaGadget/mixin/tweakeroo/inventoryPreviewUseCache/MixinMixinRenderUtils.java index 73c5ac57..0e8e509e 100644 --- a/src/main/java/com/plusls/MasaGadget/mixin/tweakeroo/inventoryPreviewUseCache/MixinMixinRenderUtils.java +++ b/src/main/java/com/plusls/MasaGadget/mixin/tweakeroo/inventoryPreviewUseCache/MixinMixinRenderUtils.java @@ -7,10 +7,13 @@ import fi.dy.masa.tweakeroo.renderer.RenderUtils; import fi.dy.masa.tweakeroo.util.RayTraceUtils; import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; import net.minecraft.world.Container; import net.minecraft.world.entity.Entity; import net.minecraft.world.level.Level; +import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.HitResult; +import net.minecraft.world.phys.Vec3; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; @@ -29,7 +32,8 @@ private static HitResult getRayTraceFromEntityFromCache(Level worldIn, Entity en if (!Configs.inventoryPreviewUseCache) { return RayTraceUtils.getRayTraceFromEntity(worldIn, entityIn, useLiquids); } else { - return HitResultUtil.getLastHitResult(); + HitResult ret = HitResultUtil.getLastHitResult(); + return ret == null ? BlockHitResult.miss(Vec3.ZERO, Direction.UP, BlockPos.ZERO) : ret; } }