Skip to content

Commit

Permalink
Re-enable cloth-config support on forge
Browse files Browse the repository at this point in the history
  • Loading branch information
Rakambda committed Dec 16, 2024
1 parent c40ccc9 commit 79f1ac2
Show file tree
Hide file tree
Showing 3 changed files with 407 additions and 14 deletions.
2 changes: 1 addition & 1 deletion forge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ dependencies {
minecraft(libs.forge)
library(project(":common"))

// implementation("me.shedaniel.cloth:cloth-config-forge:${libs.versions.clothConfigVersion.get()}")
implementation("me.shedaniel.cloth:cloth-config-forge:${libs.versions.clothConfigVersion.get()}")

// Hack fix for now, force jopt-simple to be exactly 5.0.4 because Mojang ships that version, but some transitive dependencies request 6.0+
implementation('net.sf.jopt-simple:jopt-simple:5.0.4') { version { strictly '5.0.4' } }
Expand Down
31 changes: 18 additions & 13 deletions forge/src/main/java/fr/rakambda/fallingtree/forge/FallingTree.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
package fr.rakambda.fallingtree.forge;

import fr.rakambda.fallingtree.common.FallingTreeCommon;
import fr.rakambda.fallingtree.forge.client.cloth.ClothConfigHook;
import fr.rakambda.fallingtree.forge.common.FallingTreeCommonsImpl;
import lombok.Getter;
import lombok.extern.log4j.Log4j2;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.ModList;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import java.lang.reflect.InvocationTargetException;

@Log4j2
@Mod(FallingTree.MOD_ID)
Expand All @@ -13,19 +18,19 @@ public class FallingTree{
@Getter
private static final FallingTreeCommonsImpl mod = new FallingTreeCommonsImpl();

public FallingTree(){
// if(ModList.get().isLoaded("cloth_config")){
// try{
// Class.forName("fr.rakambda.fallingtree.forge.client.cloth.ClothConfigHook")
// .asSubclass(ClothConfigHook.class)
// .getConstructor(FallingTreeCommon.class)
// .newInstance(mod)
// .load();
// }
// catch(ClassNotFoundException | IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e){
// log.error("Failed to hook into ClothConfig", e);
// }
// }
public FallingTree(FMLJavaModLoadingContext context){
if(ModList.get().isLoaded("cloth_config")){
try{
Class.forName("fr.rakambda.fallingtree.forge.client.cloth.ClothConfigHook")
.asSubclass(ClothConfigHook.class)
.getConstructor(FallingTreeCommon.class)
.newInstance(mod)
.load(context);
}
catch(ClassNotFoundException | IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e){
log.error("Failed to hook into ClothConfig", e);
}
}

mod.registerForge(MinecraftForge.EVENT_BUS);
}
Expand Down
Loading

0 comments on commit 79f1ac2

Please sign in to comment.