Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Analyser/FabricAnalyser.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Aternos\Codex\Minecraft\Analysis\Problem\Fabric\FabricEntryStageProblem;
use Aternos\Codex\Minecraft\Analysis\Problem\Fabric\FabricIncompatibleModsProblem;
use Aternos\Codex\Minecraft\Analysis\Problem\Fabric\FabricLoaderVersionProblem;
use Aternos\Codex\Minecraft\Analysis\Problem\Fabric\FabricMixinApplyProblem;
use Aternos\Codex\Minecraft\Analysis\Problem\Fabric\FabricMixinProblem;
use Aternos\Codex\Minecraft\Analysis\Problem\Fabric\FabricModDependencyProblem;
use Aternos\Codex\Minecraft\Analysis\Problem\Fabric\FabricModIncompatibleMinecraftVersionProblem;
Expand All @@ -29,6 +30,7 @@ public function __construct()
$this->addPossibleInsightClass(FabricModJavaVersionProblem::class);
$this->addPossibleInsightClass(FabricLoaderVersionProblem::class);
$this->addPossibleInsightClass(FabricMixinProblem::class);
$this->addPossibleInsightClass(FabricMixinApplyProblem::class);
$this->addPossibleInsightClass(FabricIncompatibleModsProblem::class);
$this->addPossibleInsightClass(FabricDuplicateModProblem::class);
$this->addPossibleInsightClass(FabricEntryStageProblem::class);
Expand Down
25 changes: 25 additions & 0 deletions src/Analysis/Problem/Fabric/FabricMixinApplyProblem.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace Aternos\Codex\Minecraft\Analysis\Problem\Fabric;

use Aternos\Codex\Minecraft\Analysis\Problem\Forge\MixinApplyProblem;

/**
* A mixin of a mod could not be applied and the game crashed, like MixinApplyProblem on Forge and NeoForge.
*
* Not matched when the mixin failed because it loaded a client-only class on a dedicated server,
* because FabricClientOnlyModProblem already reports that mod as client-only.
*/
class FabricMixinApplyProblem extends MixinApplyProblem
{
/**
* @inheritDoc
*/
public static function getPatterns(): array
{
return [
'/' . static::MIXIN_APPLY_ERROR
. '(?![^\n]*\n' . FabricClientOnlyModProblem::STACK_TRACE_LINES . 'Caused by: ' . FabricClientOnlyModProblem::CLIENT_ONLY_CAUSE . ')/'
];
}
}
20 changes: 18 additions & 2 deletions src/Analysis/Problem/Fabric/FabricMixinProblem.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
use Aternos\Codex\Minecraft\Analysis\Solution\Forge\ModRemoveSolution;
use Aternos\Codex\Minecraft\Translator\Translator;

/**
* Mixin hit a critical error while transforming a class, caused by a mixin of a mod, and the game crashed.
*
* Only the direct cause of the MixinTransformerError is checked.
* When that cause is a MixinApplyError, the crash is reported by FabricMixinApplyProblem instead,
* which reads the mod ID from the MixinApplyError line.
*/
class FabricMixinProblem extends FabricModProblem
{
/**
Expand All @@ -16,12 +23,21 @@ public function getMessage(): string
}

/**
* Matches a MixinTransformerError and the stack trace below it up to its direct cause, if that cause names a mod, e.g.
* "Caused by: org.spongepowered.asm.mixin.transformer.throwables.MixinTransformerError: An unexpected critical error was encountered
* at org.spongepowered.asm.mixin.transformer.MixinProcessor.applyMixins(MixinProcessor.java:392) ~[sponge-mixin-0.15.4+mixin.0.8.7.jar:0.15.4+mixin.0.8.7]
* ... 10 more
* Caused by: org.spongepowered.asm.mixin.injection.throwables.InjectionError: Critical injection failure: Callback method setInWater(Z)Z in expandability-common.mixins.json:swimming.EntityMixin from mod expandability failed injection check, (3/4) succeeded."
*
* Mixin can write more context directly after the mod ID, like "from mod enhanced_storage->@Inject::...",
* so the mod ID ends at the first character that cannot be part of it.
*
* @inheritDoc
*/
public static function getPatterns(): array
{
return [
"/MixinTransformerError: An unexpected critical error was encountered\n(?:.*\n)*Caused by: .* from mod " . static::$modIDPattern . "/"
"/MixinTransformerError: An unexpected critical error was encountered\n(?:\t[^\n]*\n)*+Caused by: (?!org\.spongepowered\.asm\.mixin\.throwables\.MixinApplyError:)[^\n]* from mod (?<modId>[\w-]+)/"
];
}

Expand All @@ -30,7 +46,7 @@ public static function getPatterns(): array
*/
public function setMatches(array $matches, mixed $patternKey): void
{
$this->setModName($matches[1]);
$this->setModName($matches['modId']);
$this->addSolution(new ModRemoveSolution($this->getModName()));
}
}
11 changes: 7 additions & 4 deletions src/Analysis/Problem/Forge/MixinApplyProblem.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ class MixinApplyProblem extends ModProblem
*/
protected const string UNKNOWN_MOD_ID = "(unknown)";

/**
* Matches the error Mixin throws when a mixin fails to apply, e.g.
* "Caused by: org.spongepowered.asm.mixin.throwables.MixinApplyError: Mixin [fabric-resource-loader-v0.mixins.json:ReloadableResourceManagerImplMixin from mod fabric_resource_loader_v0] from phase [DEFAULT] in config [fabric-resource-loader-v0.mixins.json] FAILED during APPLY"
*/
protected const string MIXIN_APPLY_ERROR = 'MixinApplyError: Mixin \[(?<mixinConfig>[^:\]\n]+):[^ \]\n]+ from mod (?<modId>[^\]\n]+)\] from phase';

protected string $mixinConfig;

/**
Expand All @@ -36,15 +42,12 @@ public function getMessage(): string
}

/**
* Matches the error Mixin throws when a mixin fails to apply, e.g.
* "Caused by: org.spongepowered.asm.mixin.throwables.MixinApplyError: Mixin [fabric-resource-loader-v0.mixins.json:ReloadableResourceManagerImplMixin from mod fabric_resource_loader_v0] from phase [DEFAULT] in config [fabric-resource-loader-v0.mixins.json] FAILED during APPLY"
*
* @inheritDoc
*/
public static function getPatterns(): array
{
return [
'/MixinApplyError: Mixin \[(?<mixinConfig>[^:\]\n]+):[^ \]\n]+ from mod (?<modId>[^\]\n]+)\] from phase/'
'/' . static::MIXIN_APPLY_ERROR . '/'
];
}

Expand Down
Loading
Loading