From 17f046deb00fff1af666e608b3e98357aebe1c74 Mon Sep 17 00:00:00 2001 From: MicrocontrollersDev Date: Mon, 1 Jul 2024 18:58:23 -0700 Subject: [PATCH] fix smys crash 1.9.4 --- gradle.properties | 2 +- .../overlaytweaks/mixin/BuiltinItemModelRendererMixin.java | 7 +++---- .../overlaytweaks/mixin/LivingEntityRendererMixin.java | 3 +-- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/gradle.properties b/gradle.properties index ca7b90a..61f485a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,6 +6,6 @@ org.gradle.parallel=true polyfrost.defaults.loom=3 # Mod Properties -mod_version=1.9.3 +mod_version=1.9.4 maven_group=dev.microcontrollers.overlaytweaks archives_base_name=overlaytweaks diff --git a/src/main/java/dev/microcontrollers/overlaytweaks/mixin/BuiltinItemModelRendererMixin.java b/src/main/java/dev/microcontrollers/overlaytweaks/mixin/BuiltinItemModelRendererMixin.java index c5dc181..b0bf678 100644 --- a/src/main/java/dev/microcontrollers/overlaytweaks/mixin/BuiltinItemModelRendererMixin.java +++ b/src/main/java/dev/microcontrollers/overlaytweaks/mixin/BuiltinItemModelRendererMixin.java @@ -53,8 +53,8 @@ private void cancelShieldRendering(ItemStack stack, ModelTransformationMode mode //#if MC < 1.21 //$$ @ModifyArgs(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/model/ModelPart;render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumer;IIFFFF)V")) //$$ private void changeShieldColorAndTransparency(Args args, ItemStack stack, ModelTransformationMode mode, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) { + //$$ if (MinecraftClient.getInstance().player == null) return; //$$ ClientPlayerEntity player = MinecraftClient.getInstance().player; - //$$ assert player != null; //$$ float cooldown = player.getItemCooldownManager().getCooldownProgress(Items.SHIELD, 0); //$$ // We want this to only change shields that are being held so it doesn't affect containers/dropped items, as well as first person only. //$$ if (mode == ModelTransformationMode.FIRST_PERSON_LEFT_HAND || mode == ModelTransformationMode.FIRST_PERSON_RIGHT_HAND @@ -82,9 +82,8 @@ private void cancelShieldRendering(ItemStack stack, ModelTransformationMode mode //#if MC >= 1.21 @WrapOperation(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/model/ModelPart;render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumer;II)V")) private void changeShieldColorAndTransparencyPre(ModelPart instance, MatrixStack matrices, VertexConsumer vertices, int light, int overlay, Operation original, @Local(argsOnly = true) LocalRef mode) { - ClientPlayerEntity player = MinecraftClient.getInstance().player; - assert player != null; - float cooldown = player.getItemCooldownManager().getCooldownProgress(Items.SHIELD, 0); + if (MinecraftClient.getInstance().player == null) return; + float cooldown = MinecraftClient.getInstance().player.getItemCooldownManager().getCooldownProgress(Items.SHIELD, 0); if (mode.get() == ModelTransformationMode.FIRST_PERSON_LEFT_HAND || mode.get() == ModelTransformationMode.FIRST_PERSON_RIGHT_HAND && OverlayTweaksConfig.CONFIG.instance().customShieldOpacity != 0) { float alpha = OverlayTweaksConfig.CONFIG.instance().customShieldOpacity / 100; diff --git a/src/main/java/dev/microcontrollers/overlaytweaks/mixin/LivingEntityRendererMixin.java b/src/main/java/dev/microcontrollers/overlaytweaks/mixin/LivingEntityRendererMixin.java index 0e317ce..fcd41f9 100644 --- a/src/main/java/dev/microcontrollers/overlaytweaks/mixin/LivingEntityRendererMixin.java +++ b/src/main/java/dev/microcontrollers/overlaytweaks/mixin/LivingEntityRendererMixin.java @@ -29,8 +29,7 @@ public class LivingEntityRendererMixin { private RenderLayer transparentEntityRenderLayer(EntityModel model, Identifier texture, Operation original) { // let's not set this unless we absolutely have to // TODO: fix pig saddles - assert MinecraftClient.getInstance().player != null; - if (MinecraftClient.getInstance().player.hasVehicle() && + if (MinecraftClient.getInstance().player != null && MinecraftClient.getInstance().player.hasVehicle() && ((OverlayTweaksConfig.CONFIG.instance().horseOpacity != 100 && texture.toString().contains("horse")) || (OverlayTweaksConfig.CONFIG.instance().pigOpacity != 100 && texture.toString().contains("pig")) || (OverlayTweaksConfig.CONFIG.instance().striderOpacity != 100 && texture.toString().contains("strider")) ||