-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Rework mixin handling - now an array in META-INF/mixinconfigs.json * Defer mixin configuration loading to mixin init phase 2 (agent prepare) * Update licenses * Add both mods from loading list and gamelibraries to GAME layer * Let mixins be defined in mods.toml instead * Gradlew
- Loading branch information
1 parent
3eaf250
commit 5836277
Showing
14 changed files
with
156 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
Copyright (c) Forge Development LLC and contributors | ||
SPDX-License-Identifier: LGPL-2.1-only | ||
Copyright (c) NeoForged and contributors | ||
SPDX-License-Identifier: LGPL-2.1-only |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
loader/src/main/java/net/neoforged/fml/loading/mixin/DeferredMixinConfigRegistration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright (c) NeoForged and contributors | ||
* SPDX-License-Identifier: LGPL-2.1-only | ||
*/ | ||
|
||
package net.neoforged.fml.loading.mixin; | ||
|
||
import org.spongepowered.asm.launch.GlobalProperties; | ||
import org.spongepowered.asm.launch.MixinBootstrap; | ||
import org.spongepowered.asm.mixin.Mixins; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class DeferredMixinConfigRegistration { | ||
private static boolean added = false; | ||
private static final List<String> mixinConfigs = new ArrayList<>(); | ||
|
||
static { | ||
// Register our platform agent first | ||
List<String> agentClassNames = GlobalProperties.get(GlobalProperties.Keys.AGENTS); | ||
agentClassNames.add(FMLMixinPlatformAgent.class.getName()); | ||
// Register the container (will use the platform agent) | ||
MixinBootstrap.getPlatform().addContainer(new FMLMixinContainerHandle()); | ||
} | ||
|
||
public static void addMixinConfig(String config) { | ||
if (added) { | ||
throw new IllegalStateException("Too late to add mixin configs!"); | ||
} | ||
|
||
mixinConfigs.add(config); | ||
} | ||
|
||
static void registerConfigs() { | ||
added = true; | ||
mixinConfigs.forEach(Mixins::addConfiguration); | ||
mixinConfigs.clear(); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
loader/src/main/java/net/neoforged/fml/loading/mixin/FMLMixinContainerHandle.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright (c) NeoForged and contributors | ||
* SPDX-License-Identifier: LGPL-2.1-only | ||
*/ | ||
|
||
package net.neoforged.fml.loading.mixin; | ||
|
||
import org.spongepowered.asm.launch.platform.container.IContainerHandle; | ||
|
||
import java.util.Collection; | ||
import java.util.List; | ||
|
||
/** | ||
* Container handle representing all of FML's mixin configs. | ||
* No attribute because we directly load the mixin configs in {@link FMLMixinPlatformAgent}. | ||
*/ | ||
public class FMLMixinContainerHandle implements IContainerHandle { | ||
@Override | ||
public String getAttribute(String name) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public Collection<IContainerHandle> getNestedContainers() { | ||
return List.of(); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
loader/src/main/java/net/neoforged/fml/loading/mixin/FMLMixinPlatformAgent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright (c) NeoForged and contributors | ||
* SPDX-License-Identifier: LGPL-2.1-only | ||
*/ | ||
|
||
package net.neoforged.fml.loading.mixin; | ||
|
||
import org.spongepowered.asm.launch.platform.MixinPlatformAgentAbstract; | ||
import org.spongepowered.asm.launch.platform.MixinPlatformManager; | ||
import org.spongepowered.asm.launch.platform.container.IContainerHandle; | ||
|
||
public class FMLMixinPlatformAgent extends MixinPlatformAgentAbstract { | ||
@Override | ||
public AcceptResult accept(MixinPlatformManager manager, IContainerHandle handle) { | ||
if (handle instanceof FMLMixinContainerHandle) { | ||
return AcceptResult.ACCEPTED; | ||
} | ||
return AcceptResult.REJECTED; | ||
} | ||
|
||
@Override | ||
public void prepare() { | ||
// Load all the mixin configs!! | ||
DeferredMixinConfigRegistration.registerConfigs(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters