From ac9ddcea56606a2fc6c7fb20ef09adebd6b92ef6 Mon Sep 17 00:00:00 2001 From: fretuks Date: Thu, 22 Jan 2026 09:26:14 +0100 Subject: [PATCH] Try to fix crashes --- gradle.properties | 2 +- .../net/fretux/mindmotion/AscendMindMotion.java | 3 --- .../java/net/fretux/mindmotion/ConfigMM.java | 1 - .../client/effects/IronsSpellbooksCompatMM.java | 17 +++-------------- .../mindmotion/command/SanityCommand.java | 2 +- .../fretux/mindmotion/network/ModMessages.java | 2 +- .../network/VentClientEffectPacket.java | 3 +-- .../player/PlayerCapabilityProvider.java | 6 +++--- 8 files changed, 10 insertions(+), 26 deletions(-) diff --git a/gradle.properties b/gradle.properties index 5f0d201..5eba48f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -52,7 +52,7 @@ mod_name=Mind & Motion # The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default. mod_license=All Rights Reserved # The mod version. See https://semver.org/ -mod_version=1.2.3 +mod_version=1.2.4 # The group ID for the mod. It is only important when publishing as an artifact to a Maven repository. # This should match the base package used for the mod sources. # See https://maven.apache.org/guides/mini/guide-naming-conventions.html diff --git a/src/main/java/net/fretux/mindmotion/AscendMindMotion.java b/src/main/java/net/fretux/mindmotion/AscendMindMotion.java index 2a4207a..3984c8c 100644 --- a/src/main/java/net/fretux/mindmotion/AscendMindMotion.java +++ b/src/main/java/net/fretux/mindmotion/AscendMindMotion.java @@ -6,11 +6,8 @@ import net.fretux.mindmotion.command.SanityCommand; import net.fretux.mindmotion.event.CombatEvents; import net.fretux.mindmotion.event.PlayerTickHandler; import net.fretux.mindmotion.network.ModMessages; -import net.minecraftforge.client.event.RegisterKeyMappingsEvent; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.RegisterCommandsEvent; import net.minecraftforge.eventbus.api.IEventBus; -import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.ModLoadingContext; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.config.ModConfig; diff --git a/src/main/java/net/fretux/mindmotion/ConfigMM.java b/src/main/java/net/fretux/mindmotion/ConfigMM.java index 538c179..4d1dfc5 100644 --- a/src/main/java/net/fretux/mindmotion/ConfigMM.java +++ b/src/main/java/net/fretux/mindmotion/ConfigMM.java @@ -1,6 +1,5 @@ package net.fretux.mindmotion; -import net.minecraft.resources.ResourceLocation; import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; diff --git a/src/main/java/net/fretux/mindmotion/client/effects/IronsSpellbooksCompatMM.java b/src/main/java/net/fretux/mindmotion/client/effects/IronsSpellbooksCompatMM.java index 89ead75..8f5073a 100644 --- a/src/main/java/net/fretux/mindmotion/client/effects/IronsSpellbooksCompatMM.java +++ b/src/main/java/net/fretux/mindmotion/client/effects/IronsSpellbooksCompatMM.java @@ -1,7 +1,6 @@ package net.fretux.mindmotion.client.effects; import net.fretux.mindmotion.ConfigMM; -import net.fretux.mindmotion.player.PlayerCapabilityProvider; import net.minecraft.world.entity.ai.attributes.Attribute; import net.minecraft.world.entity.ai.attributes.AttributeInstance; import net.minecraft.world.entity.ai.attributes.AttributeModifier; @@ -30,18 +29,8 @@ public final class IronsSpellbooksCompatMM { return ConfigMM.COMMON.TEMPO_PER_MANA_REGEN_PERCENT.get(); } - public static boolean isLoaded() { - return ModList.get().isLoaded(IRONS_MODID); - } - - public static void applyTempo(Player player) { - if (!isLoaded()) return; - resolveOnce(); - if (!available) return; - player.getCapability(PlayerCapabilityProvider.TEMPO).ifPresent(tempoCap -> { - int tempo = tempoCap.getTempo(); - applyTempoToManaRegen(player, tempo); - }); + public static boolean isNotLoaded() { + return !ModList.get().isLoaded(IRONS_MODID); } private static void resolveOnce() { @@ -60,7 +49,7 @@ public final class IronsSpellbooksCompatMM { } public static void applyTempoToManaRegen(Player player, int tempo) { - if (!isLoaded()) return; + if (isNotLoaded()) return; resolveOnce(); if (!available) return; Attribute manaRegenAttr = getManaRegenAttribute(); diff --git a/src/main/java/net/fretux/mindmotion/command/SanityCommand.java b/src/main/java/net/fretux/mindmotion/command/SanityCommand.java index da25d69..eca4914 100644 --- a/src/main/java/net/fretux/mindmotion/command/SanityCommand.java +++ b/src/main/java/net/fretux/mindmotion/command/SanityCommand.java @@ -21,7 +21,7 @@ public class SanityCommand { ServerPlayer player = ctx.getSource().getPlayer(); float sanity = FloatArgumentType.getFloat(ctx, "sanity"); float insanity = FloatArgumentType.getFloat(ctx, "insanity"); - + assert player != null; player.getCapability(PlayerCapabilityProvider.SANITY).ifPresent(cap -> { cap.setSanity(sanity); cap.setInsanity(insanity); diff --git a/src/main/java/net/fretux/mindmotion/network/ModMessages.java b/src/main/java/net/fretux/mindmotion/network/ModMessages.java index abe3576..d27392e 100644 --- a/src/main/java/net/fretux/mindmotion/network/ModMessages.java +++ b/src/main/java/net/fretux/mindmotion/network/ModMessages.java @@ -11,7 +11,7 @@ public class ModMessages { private static final String PROTOCOL_VERSION = "1"; public static final SimpleChannel CHANNEL = NetworkRegistry.newSimpleChannel( - new ResourceLocation(AscendMindMotion.MODID, "main"), + ResourceLocation.fromNamespaceAndPath(AscendMindMotion.MODID, "main"), () -> PROTOCOL_VERSION, PROTOCOL_VERSION::equals, PROTOCOL_VERSION::equals diff --git a/src/main/java/net/fretux/mindmotion/network/VentClientEffectPacket.java b/src/main/java/net/fretux/mindmotion/network/VentClientEffectPacket.java index 8940f7c..d94c02f 100644 --- a/src/main/java/net/fretux/mindmotion/network/VentClientEffectPacket.java +++ b/src/main/java/net/fretux/mindmotion/network/VentClientEffectPacket.java @@ -14,13 +14,12 @@ public class VentClientEffectPacket { public void toBytes(FriendlyByteBuf buf) {} - public boolean handle(Supplier ctx) { + public void handle(Supplier ctx) { ctx.get().enqueueWork(() -> { Minecraft mc = Minecraft.getInstance(); if (mc.player == null) return; mc.player.swingTime = 10; VentShaderHandler.triggerVentShockwave(); }); - return true; } } diff --git a/src/main/java/net/fretux/mindmotion/player/PlayerCapabilityProvider.java b/src/main/java/net/fretux/mindmotion/player/PlayerCapabilityProvider.java index f696f5c..37a1fc2 100644 --- a/src/main/java/net/fretux/mindmotion/player/PlayerCapabilityProvider.java +++ b/src/main/java/net/fretux/mindmotion/player/PlayerCapabilityProvider.java @@ -21,9 +21,9 @@ public class PlayerCapabilityProvider { @SubscribeEvent public static void attachCapabilities(AttachCapabilitiesEvent event) { - if (event.getObject() instanceof net.minecraft.world.entity.player.Player player) { - event.addCapability(new ResourceLocation("mindmotion", "sanity"), new SanityProvider()); - event.addCapability(new ResourceLocation("mindmotion", "tempo"), new TempoProvider()); + if (event.getObject() instanceof net.minecraft.world.entity.player.Player) { + event.addCapability(ResourceLocation.fromNamespaceAndPath("mindmotion", "sanity"), new SanityProvider()); + event.addCapability(ResourceLocation.fromNamespaceAndPath("mindmotion", "tempo"), new TempoProvider()); } }