aboutsummaryrefslogtreecommitdiff
path: root/mod/src/main/java/moe/nea/ledger/mixin/devenv
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2025-01-08 19:25:29 +0100
committerLinnea Gräf <nea@nea.moe>2025-01-08 19:25:29 +0100
commitd1e16a47819509ed645bb93e1a173e0a97025cef (patch)
treeefbe886d9ac1ab4ea01788cb4842812fd0af9079 /mod/src/main/java/moe/nea/ledger/mixin/devenv
parentf694daf322bbb4ff530a9332547c5c8337c3e0c0 (diff)
downloadLocalTransactionLedger-d1e16a47819509ed645bb93e1a173e0a97025cef.tar.gz
LocalTransactionLedger-d1e16a47819509ed645bb93e1a173e0a97025cef.tar.bz2
LocalTransactionLedger-d1e16a47819509ed645bb93e1a173e0a97025cef.zip
build: Move mod to subproject
Diffstat (limited to 'mod/src/main/java/moe/nea/ledger/mixin/devenv')
-rw-r--r--mod/src/main/java/moe/nea/ledger/mixin/devenv/RegisterModResourcesPatch.java66
1 files changed, 66 insertions, 0 deletions
diff --git a/mod/src/main/java/moe/nea/ledger/mixin/devenv/RegisterModResourcesPatch.java b/mod/src/main/java/moe/nea/ledger/mixin/devenv/RegisterModResourcesPatch.java
new file mode 100644
index 0000000..88e8364
--- /dev/null
+++ b/mod/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<ModCandidate> candidates;
+
+ @Inject(method = "identifyMods", at = @At("HEAD"), remap = false)
+ private void addCandidate(CallbackInfoReturnable<List<ModContainer>> 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<ModContainer> explore(ASMDataTable table) {
+ return Collections.singletonList(container);
+ }
+ });
+ }
+}