diff --git a/gradle.properties b/gradle.properties index 998cdaf..1737f1b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx2G # Mod Properties -mod_version = 0.0.46 +mod_version = 0.0.47 maven_group = dev.ithundxr archives_base_name = RailwaysTweaks diff --git a/src/main/java/dev/ithundxr/railwaystweaks/mixin/compat/tconstruct/LazyModifierMixin.java b/src/main/java/dev/ithundxr/railwaystweaks/mixin/compat/tconstruct/LazyModifierMixin.java new file mode 100644 index 0000000..7d4a480 --- /dev/null +++ b/src/main/java/dev/ithundxr/railwaystweaks/mixin/compat/tconstruct/LazyModifierMixin.java @@ -0,0 +1,29 @@ +package dev.ithundxr.railwaystweaks.mixin.compat.tconstruct; + +import org.spongepowered.asm.mixin.Final; +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.CallbackInfoReturnable; +import slimeknights.tconstruct.library.modifiers.Modifier; +import slimeknights.tconstruct.library.modifiers.ModifierId; +import slimeknights.tconstruct.library.modifiers.ModifierManager; +import slimeknights.tconstruct.library.modifiers.util.LazyModifier; + +@Mixin(LazyModifier.class) +public class LazyModifierMixin { + + @Shadow @Final protected ModifierId id; + + @Inject( + method = "get()Lslimeknights/tconstruct/library/modifiers/Modifier;", + at = @At("HEAD"), + cancellable = true, + remap = false + ) + private void railwayTweaks$suppressException(CallbackInfoReturnable cir) { + if (!ModifierManager.INSTANCE.isDynamicModifiersLoaded()) + cir.setReturnValue(ModifierManager.INSTANCE.getDefaultValue()); + } +} diff --git a/src/main/resources/railwaystweaks.mixins.json b/src/main/resources/railwaystweaks.mixins.json index c12022c..195c56a 100644 --- a/src/main/resources/railwaystweaks.mixins.json +++ b/src/main/resources/railwaystweaks.mixins.json @@ -17,6 +17,7 @@ "compat.create.SchematicannonBlockEntityMixin", "compat.dcintegration.DiscordEventListenerMixin", "compat.enchancement.SlideComponentMixin", + "compat.tconstruct.LazyModifierMixin", "compat.tconstruct.SimpleChannelAccessor" ], "client": [