From 1a923ff1fda799906cc56c7a8a767053558db95c Mon Sep 17 00:00:00 2001 From: Linnea Gräf Date: Wed, 8 Jan 2025 14:48:54 +0100 Subject: fix: Hide mod resources patch outside of the devenv --- .../ledger/mixin/RegisterModResourcesPatch.java | 66 ---------------------- .../mixin/devenv/RegisterModResourcesPatch.java | 66 ++++++++++++++++++++++ 2 files changed, 66 insertions(+), 66 deletions(-) delete mode 100644 src/main/java/moe/nea/ledger/mixin/RegisterModResourcesPatch.java create mode 100644 src/main/java/moe/nea/ledger/mixin/devenv/RegisterModResourcesPatch.java (limited to 'src/main/java/moe/nea/ledger/mixin') diff --git a/src/main/java/moe/nea/ledger/mixin/RegisterModResourcesPatch.java b/src/main/java/moe/nea/ledger/mixin/RegisterModResourcesPatch.java deleted file mode 100644 index e925d18..0000000 --- a/src/main/java/moe/nea/ledger/mixin/RegisterModResourcesPatch.java +++ /dev/null @@ -1,66 +0,0 @@ -package moe.nea.ledger.mixin; - -import com.google.common.eventbus.EventBus; -import net.minecraftforge.fml.client.FMLFileResourcePack; -import net.minecraftforge.fml.common.DummyModContainer; -import net.minecraftforge.fml.common.LoadController; -import net.minecraftforge.fml.common.ModContainer; -import net.minecraftforge.fml.common.ModMetadata; -import net.minecraftforge.fml.common.discovery.ASMDataTable; -import net.minecraftforge.fml.common.discovery.ContainerType; -import net.minecraftforge.fml.common.discovery.ModCandidate; -import net.minecraftforge.fml.common.discovery.ModDiscoverer; -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 java.io.File; -import java.util.Collections; -import java.util.List; - -@Mixin(value = ModDiscoverer.class, remap = false) -public class RegisterModResourcesPatch { - @Shadow - private List candidates; - - @Inject(method = "identifyMods", at = @At("HEAD"), remap = false) - private void addCandidate(CallbackInfoReturnable> cir) { - String bonusResourceMod = System.getProperty("ledger.bonusresourcemod"); - if (bonusResourceMod == null) return; - File file = new File(bonusResourceMod); - if (!file.isDirectory()) return; - ModMetadata modMetadata = new ModMetadata(); - modMetadata.modId = "ledger-bonus"; - modMetadata.name = "Ledger Bonus Resources"; - modMetadata.autogenerated = true; - ModContainer container = new DummyModContainer(modMetadata) { - @Override - public Object getMod() { - return new Object(); - } - - @Override - public boolean registerBus(EventBus bus, LoadController controller) { - return true; - } - - @Override - public File getSource() { - return file; - } - - @Override - public Class getCustomResourcePackClass() { - return FMLFileResourcePack.class; - } - }; - candidates.add(new ModCandidate(file, file, ContainerType.DIR) { - @Override - public List explore(ASMDataTable table) { - return Collections.singletonList(container); - } - }); - } -} diff --git a/src/main/java/moe/nea/ledger/mixin/devenv/RegisterModResourcesPatch.java b/src/main/java/moe/nea/ledger/mixin/devenv/RegisterModResourcesPatch.java new file mode 100644 index 0000000..88e8364 --- /dev/null +++ b/src/main/java/moe/nea/ledger/mixin/devenv/RegisterModResourcesPatch.java @@ -0,0 +1,66 @@ +package moe.nea.ledger.mixin.devenv; + +import com.google.common.eventbus.EventBus; +import net.minecraftforge.fml.client.FMLFileResourcePack; +import net.minecraftforge.fml.common.DummyModContainer; +import net.minecraftforge.fml.common.LoadController; +import net.minecraftforge.fml.common.ModContainer; +import net.minecraftforge.fml.common.ModMetadata; +import net.minecraftforge.fml.common.discovery.ASMDataTable; +import net.minecraftforge.fml.common.discovery.ContainerType; +import net.minecraftforge.fml.common.discovery.ModCandidate; +import net.minecraftforge.fml.common.discovery.ModDiscoverer; +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 java.io.File; +import java.util.Collections; +import java.util.List; + +@Mixin(value = ModDiscoverer.class, remap = false) +public class RegisterModResourcesPatch { + @Shadow + private List candidates; + + @Inject(method = "identifyMods", at = @At("HEAD"), remap = false) + private void addCandidate(CallbackInfoReturnable> cir) { + String bonusResourceMod = System.getProperty("ledger.bonusresourcemod"); + if (bonusResourceMod == null) return; + File file = new File(bonusResourceMod); + if (!file.isDirectory()) return; + ModMetadata modMetadata = new ModMetadata(); + modMetadata.modId = "ledger-bonus"; + modMetadata.name = "Ledger Bonus Resources"; + modMetadata.autogenerated = true; + ModContainer container = new DummyModContainer(modMetadata) { + @Override + public Object getMod() { + return new Object(); + } + + @Override + public boolean registerBus(EventBus bus, LoadController controller) { + return true; + } + + @Override + public File getSource() { + return file; + } + + @Override + public Class getCustomResourcePackClass() { + return FMLFileResourcePack.class; + } + }; + candidates.add(new ModCandidate(file, file, ContainerType.DIR) { + @Override + public List explore(ASMDataTable table) { + return Collections.singletonList(container); + } + }); + } +} -- cgit