Skip to content

Commit

Permalink
NeoForge: Fix loading on dedicated if cloth-config is present (#706)
Browse files Browse the repository at this point in the history
* NeoForge: Fix loading on dedicated if cloth config is present

* Hopefully fix neoforge issue template
  • Loading branch information
Rakambda authored Jun 19, 2024
1 parent d36cffc commit 911eeae
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/2_neoforge-bug-report.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Forge bug report
name: NeoForge bug report
description: Create a report to help us improve the NeoForge version
labels: ["modloader: Neoforge", "type: 🐛 bug"]
assignees:
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/3_feature_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ body:
id: describing
attributes:
label: Describe the feature
description: Describe the feature/enhacement you wish to have
description: Describe the feature/enhancement you wish to have
validations:
required: true
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
package fr.rakambda.fallingtree.neoforge;

import fr.rakambda.fallingtree.common.FallingTreeCommon;
import fr.rakambda.fallingtree.neoforge.client.cloth.ClothConfigHook;
import fr.rakambda.fallingtree.neoforge.common.FallingTreeCommonsImpl;
import lombok.Getter;
import lombok.extern.log4j.Log4j2;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.fml.ModContainer;
import net.neoforged.fml.ModList;
import net.neoforged.fml.common.Mod;
import net.neoforged.neoforge.common.NeoForge;
import org.jetbrains.annotations.NotNull;
import java.lang.reflect.InvocationTargetException;

@Log4j2
@Mod(FallingTree.MOD_ID)
Expand All @@ -22,20 +18,6 @@ public class FallingTree{

public FallingTree(@NotNull IEventBus modEventBus, @NotNull ModContainer modContainer){
mod = new FallingTreeCommonsImpl(modEventBus);

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

mod.registerForge(NeoForge.EVENT_BUS);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package fr.rakambda.fallingtree.neoforge;

import fr.rakambda.fallingtree.common.FallingTreeCommon;
import fr.rakambda.fallingtree.neoforge.client.cloth.ClothConfigHook;
import lombok.extern.log4j.Log4j2;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.fml.ModContainer;
import net.neoforged.fml.ModList;
import net.neoforged.fml.common.Mod;
import org.jetbrains.annotations.NotNull;
import java.lang.reflect.InvocationTargetException;

@Log4j2
@Mod(value = FallingTree.MOD_ID, dist = Dist.CLIENT)
public class FallingTreeClient {
public FallingTreeClient(@NotNull IEventBus modEventBus, @NotNull ModContainer modContainer){
if(ModList.get().isLoaded("cloth_config")){
try{
Class.forName("fr.rakambda.fallingtree.neoforge.client.cloth.ClothConfigHook")
.asSubclass(ClothConfigHook.class)
.getConstructor(FallingTreeCommon.class)
.newInstance(FallingTree.getMod())
.load(modContainer);
}
catch(ClassNotFoundException | IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e){
log.error("Failed to hook into ClothConfig", e);
}
}
}
}

0 comments on commit 911eeae

Please sign in to comment.