From ae9324d7feaca4a5e92d6b2fd3fb524c2b90efb8 Mon Sep 17 00:00:00 2001 From: IThundxr Date: Tue, 19 Nov 2024 21:15:18 -0500 Subject: [PATCH] fix: crash caused by missing null check --- .../mixin/compat/create/BlockHelperMixin.java | 16 ++++++++++++++++ src/main/resources/railwaystweaks.mixins.json | 1 + 2 files changed, 17 insertions(+) create mode 100644 src/main/java/dev/ithundxr/railwaystweaks/mixin/compat/create/BlockHelperMixin.java diff --git a/src/main/java/dev/ithundxr/railwaystweaks/mixin/compat/create/BlockHelperMixin.java b/src/main/java/dev/ithundxr/railwaystweaks/mixin/compat/create/BlockHelperMixin.java new file mode 100644 index 0000000..63ad45b --- /dev/null +++ b/src/main/java/dev/ithundxr/railwaystweaks/mixin/compat/create/BlockHelperMixin.java @@ -0,0 +1,16 @@ +package dev.ithundxr.railwaystweaks.mixin.compat.create; + +import com.llamalad7.mixinextras.injector.ModifyExpressionValue; +import com.llamalad7.mixinextras.sugar.Local; +import com.simibubi.create.foundation.utility.BlockHelper; +import net.minecraft.world.level.block.entity.BlockEntity; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; + +@Mixin(BlockHelper.class) +public class BlockHelperMixin { + @ModifyExpressionValue(method = "placeSchematicBlock", at = @At(value = "INVOKE", target = "Ljava/lang/Object;equals(Ljava/lang/Object;)Z")) + private static boolean railwayTweaks$fixSchematicannonCrash(boolean original, @Local(ordinal = 1) BlockEntity loaded) { + return loaded != null && original; + } +} diff --git a/src/main/resources/railwaystweaks.mixins.json b/src/main/resources/railwaystweaks.mixins.json index 7ed6dcc..c12022c 100644 --- a/src/main/resources/railwaystweaks.mixins.json +++ b/src/main/resources/railwaystweaks.mixins.json @@ -11,6 +11,7 @@ "ServerPlayerMixin", "ServerStatusPacketListenerImplMixin", "compat.appleskin.SyncHandlerMixin", + "compat.create.BlockHelperMixin", "compat.create.Carriage$DimensionalCarriageEntityMixin", "compat.create.CarriageAccessor", "compat.create.SchematicannonBlockEntityMixin",