Skip to content

Commit

Permalink
Make Narrator Mixin Dev Only
Browse files Browse the repository at this point in the history
Hopefully:
Fixes #31
  • Loading branch information
IntegerLimit committed Nov 24, 2024
1 parent 380b1f9 commit 515d53e
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/main/java/com/nomiceu/nomilabs/config/LabsConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,8 @@ public static class Advanced {
public int otherModsLinearXp = 0;

@Config.Comment({ "Whether to disable the Narrator.",
"Fixes Crashes in Arm Macs, in some very specific environments.",
"Fixes crashes in Arm Macs, in some development environments.",
"This config does nothing outside of deobfuscated environments!",
"If your game is crashing, try enabling this!",
"[default: false]" })
@Config.LangKey("config.nomilabs.advanced.disable_narrator")
Expand Down
19 changes: 18 additions & 1 deletion src/main/java/com/nomiceu/nomilabs/core/LabsCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
import java.util.Map;

import net.minecraftforge.common.ForgeVersion;
import net.minecraftforge.fml.relauncher.FMLLaunchHandler;
import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin;

import org.jetbrains.annotations.Nullable;

import com.google.common.collect.ImmutableList;
import com.nomiceu.nomilabs.LabsValues;

import zone.rong.mixinbooter.IEarlyMixinLoader;

Expand All @@ -18,6 +20,8 @@
@IFMLLoadingPlugin.SortingIndex(-1001)
public class LabsCore implements IFMLLoadingPlugin, IEarlyMixinLoader {

public static final String devIdentifier = "dev";

@Override
public String[] getASMTransformerClass() {
return new String[] { "com.nomiceu.nomilabs.core.LabsTransformer" };
Expand All @@ -44,6 +48,19 @@ public String getAccessTransformerClass() {

@Override
public List<String> getMixinConfigs() {
return ImmutableList.of("mixins.nomilabs.json");
return ImmutableList.of(
"mixins.nomilabs.json",
"mixins." + LabsValues.LABS_MODID + "." + devIdentifier + ".json");
}

@Override
public boolean shouldMixinConfigQueue(String mixinConfig) {
String[] parts = mixinConfig.split("\\.");

if (parts.length == 4) {
if (devIdentifier.equals(parts[2]))
return FMLLaunchHandler.isDeobfuscatedEnvironment();
}
return true;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.nomiceu.nomilabs.mixin.vanilla;
package com.nomiceu.nomilabs.mixin.dev;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
Expand All @@ -7,6 +7,7 @@

import com.mojang.text2speech.Narrator;
import com.mojang.text2speech.NarratorDummy;
import com.nomiceu.nomilabs.NomiLabs;
import com.nomiceu.nomilabs.config.LabsConfig;

@SuppressWarnings("PublicStaticMixinMember")
Expand All @@ -15,6 +16,7 @@ public interface NarratorMixin {

@Inject(method = "getNarrator", at = @At("HEAD"), cancellable = true, remap = false)
static void getDummyNarrator(CallbackInfoReturnable<Narrator> cir) {
NomiLabs.LOGGER.info("[NarratorMixin]: Disabled Narrator in Dev Environment.");
if (LabsConfig.advanced.disableNarrator) cir.setReturnValue(new NarratorDummy());
}
}
2 changes: 1 addition & 1 deletion src/main/resources/assets/nomilabs/lang/en_us.lang
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ config.nomilabs.advanced.tooltip=Advanced Settings
config.nomilabs.advanced.allow_other_modes=Allow Other Modes
config.nomilabs.advanced.disable_xp_scaling=Disable Anvil XP Scaling
config.nomilabs.advanced.other_mods_linear_xp=Misc Mod Linear XP Support
config.nomilabs.advanced.disable_narrator=Disable Narrator
config.nomilabs.advanced.disable_narrator=[DEV ONLY] Disable Narrator
config.nomilabs.advanced.enable_nomi_ceu_data_fixes=Enable Nomi-CEu Specific Data Fixes
config.nomilabs.advanced.ignore_items=ITEM Missing Registry Ignore List
config.nomilabs.advanced.ignore_blocks=BLOCK Missing Registry Ignore List
Expand Down
12 changes: 12 additions & 0 deletions src/main/resources/mixins.nomilabs.dev.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"package": "com.nomiceu.nomilabs.mixin.dev",
"refmap": "mixins.nomilabs.refmap.json",
"target": "@env(DEFAULT)",
"minVersion": "0.8",
"compatibilityLevel": "JAVA_8",
"mixins": [
"NarratorMixin"
],
"client": [],
"server": []
}
1 change: 0 additions & 1 deletion src/main/resources/mixins.nomilabs.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"ForgeRegistryMixin",
"GameDataMixin",
"ItemStackMixin",
"NarratorMixin",
"PotionEffectMixin",
"SnapshotMixin",
"WorldLoadHandler",
Expand Down

0 comments on commit 515d53e

Please sign in to comment.