Skip to content

Commit

Permalink
Rewrite modhelper
Browse files Browse the repository at this point in the history
  • Loading branch information
wohaopa committed May 31, 2024
1 parent 00274ed commit 00c4442
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 22 deletions.
1 change: 1 addition & 0 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ dependencies {
compileOnly("com.github.GTNewHorizons:GT5-Unofficial:5.09.45.163:dev")

implementation("thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev")
implementation("com.github.GTNewHorizons:Botania:1.10.12-GTNH:dev")
compileOnly("com.github.GTNewHorizons:GTNH-Intergalactic:1.3.4:dev")

compileOnly("com.github.GTNewHorizons:TecTech:5.3.45:dev")
Expand Down
19 changes: 8 additions & 11 deletions src/main/java/com/github/wohaopa/GTNHModify/LateMixinLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,29 @@ public String getMixinConfig() {
@Override
public List<String> getMixins(Set<String> loadedMods) {

for (String modId : loadedMods) {
if (modId.equals("gregtech")) {
ModHelper.hasGregtech = true;
} else if (modId.equals("Thaumcraft")) {
ModHelper.hasThaumcraft = true;
} else if (modId.equals("gtnhintergalactic")) {
ModHelper.hasGtnhIntergalactic = true;
}
for (Mods mod : Mods.values()) {
if (loadedMods.contains(mod.modid)) mod.setLoaded();
}

List<String> mixins = new ArrayList<>();

if (ModHelper.hasGregtech) {
if (Mods.GregTech.isLoaded()) {
// GregTech
mixins.add("gregtech.GT_MetaTileEntity_ScannerMixin");
mixins.add("gregtech.GT_MetaTileEntity_MinerMixin");
mixins.add("gregtech.GT_MetaTileEntity_MultiFurnaceMixin");
mixins.add("gregtech.GT_MetaTileEntity_DrillerBaseMixin");
}
if (ModHelper.hasThaumcraft) {
if (Mods.Thaumcraft.isLoaded()) {
mixins.add("thaumcraft.TileAlchemyFurnaceMixin");
mixins.add("thaumcraft.TileNodeMixin");
}
if (ModHelper.hasGtnhIntergalactic) {
if (Mods.GtnhIntergalactic.isLoaded()) {
mixins.add("gtnhintergalactic.TileEntityModuleMinerMixin");
}
if (Mods.Botania.isLoaded()) {
// mixins.add("botania.BotaniaMixin");
}

return mixins;
}
Expand Down
8 changes: 0 additions & 8 deletions src/main/java/com/github/wohaopa/GTNHModify/ModHelper.java

This file was deleted.

36 changes: 36 additions & 0 deletions src/main/java/com/github/wohaopa/GTNHModify/Mods.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.github.wohaopa.GTNHModify;

public enum Mods {

GregTech("gregtech"),
Thaumcraft("Thaumcraft"),
GtnhIntergalactic("gtnhintergalactic", false),
Botania("Botania"),;

public final String modid;
private boolean isLoaded = false;
private final boolean hasHandler;

Mods(String modid) {
this(modid, true);

}

Mods(String modid, boolean hasHandler) {
this.modid = modid;
this.hasHandler = hasHandler;
}

public String getHandler() {
if (hasHandler) return null;
return name();
}

public void setLoaded() {
this.isLoaded = true;
}

public boolean isLoaded() {
return isLoaded;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.github.wohaopa.GTNHModify.handler;

import com.github.wohaopa.GTNHModify.strategies.Strategy;

@IHandler("init")
public class BotaniaHandler {

public static void init() {

}

public static int handle(Object owner, int number) {
// todo new method
return Strategy.strategy.handler_FurnaceProcessingTime(owner, number);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import java.util.List;

import com.github.wohaopa.GTNHModify.GTNHModifyMod;
import com.github.wohaopa.GTNHModify.ModHelper;
import com.github.wohaopa.GTNHModify.Mods;
import com.github.wohaopa.GTNHModify.strategies.Strategy;

public class Handlers {
Expand All @@ -22,8 +22,12 @@ public static boolean init() {
if (methods.isEmpty()) {

handlers.add("Minecraft");
if (ModHelper.hasGregtech) handlers.add("GregTech");
if (ModHelper.hasThaumcraft) handlers.add("Thaumcraft");
for (Mods mod : Mods.values()) {
String handler = mod.getHandler();
if (handler != null) {
handlers.add(handler);
}
}

String pkg = Handlers.class.getName()
.replace("Handlers", "");
Expand Down

0 comments on commit 00c4442

Please sign in to comment.