Skip to content

Commit

Permalink
Reenable CLothConfig for Forge (#740)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rakambda authored Aug 15, 2024
1 parent c549c70 commit 4150e6c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 40 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(fg.deobf("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
28 changes: 16 additions & 12 deletions forge/src/main/java/fr/rakambda/fallingtree/forge/FallingTree.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
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 java.lang.reflect.InvocationTargetException;

@Log4j2
@Mod(FallingTree.MOD_ID)
Expand All @@ -14,18 +18,18 @@ public class FallingTree{
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);
// }
// }
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);
}
}

mod.registerForge(MinecraftForge.EVENT_BUS);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import fr.rakambda.fallingtree.common.config.enums.BreakOrder;
import fr.rakambda.fallingtree.common.config.enums.DamageRounding;
import fr.rakambda.fallingtree.common.config.enums.DetectionMode;
import fr.rakambda.fallingtree.common.config.enums.DurabilityMode;
import fr.rakambda.fallingtree.common.config.enums.MaxSizeAction;
import fr.rakambda.fallingtree.common.config.enums.NotificationMode;
import fr.rakambda.fallingtree.common.config.enums.SneakMode;
Expand Down Expand Up @@ -317,11 +318,11 @@ private void fillToolsConfigScreen(@NotNull ConfigBuilder builder, @NotNull Tool
.setTooltip(getTooltips("tools", "speedMultiplicand"))
.setSaveConsumer(config::setSpeedMultiplicand)
.build();
var preserveEntry = builder.entryBuilder()
.startBooleanToggle(translatable(getFieldName("tools", "preserve")), config.isPreserve())
.setDefaultValue(false)
.setTooltip(getTooltips("tools", "preserve"))
.setSaveConsumer(config::setPreserve)
var durabilityModeEntry = builder.entryBuilder()
.startEnumSelector(translatable(getFieldName("tools", "durabilityMode")), DurabilityMode.class, config.getDurabilityMode())
.setDefaultValue(DurabilityMode.NORMAL)
.setTooltip(getTooltips("tools", "durabilityMode"))
.setSaveConsumer(config::setDurabilityMode)
.build();
var forceToolUsageEntry = builder.entryBuilder()
.startBooleanToggle(translatable(getFieldName("tools", "forceToolUsage")), config.isForceToolUsage())
Expand All @@ -337,7 +338,7 @@ private void fillToolsConfigScreen(@NotNull ConfigBuilder builder, @NotNull Tool
tools.addEntry(damageMultiplicandEntry);
tools.addEntry(damageRoundingEntry);
tools.addEntry(speedMultiplicandEntry);
tools.addEntry(preserveEntry);
tools.addEntry(durabilityModeEntry);
tools.addEntry(forceToolUsageEntry);
}

Expand All @@ -356,24 +357,6 @@ private void fillPlayerConfigScreen(@NotNull ConfigBuilder builder, @NotNull Pla

@OnlyIn(Dist.CLIENT)
private void fillEnchantmentConfigScreen(@NotNull ConfigBuilder builder, @NotNull EnchantmentConfiguration config){
var registerEnchantEntry = builder.entryBuilder()
.startBooleanToggle(translatable(getFieldName("enchantment", "registerEnchant")), config.isRegisterEnchant())
.setDefaultValue(false)
.setTooltip(getTooltips("enchantment", "registerEnchant"))
.setSaveConsumer(config::setRegisterEnchant)
.build();
var registerSpecificEnchantEntry = builder.entryBuilder()
.startBooleanToggle(translatable(getFieldName("enchantment", "registerSpecificEnchant")), config.isRegisterSpecificEnchant())
.setDefaultValue(false)
.setTooltip(getTooltips("enchantment", "registerSpecificEnchant"))
.setSaveConsumer(config::setRegisterSpecificEnchant)
.build();
var hideEnchantEntry = builder.entryBuilder()
.startBooleanToggle(translatable(getFieldName("enchantment", "hideEnchant")), config.isHideEnchant())
.setDefaultValue(false)
.setTooltip(getTooltips("enchantment", "hideEnchant"))
.setSaveConsumer(config::setHideEnchant)
.build();
var requireEnchantmentEntry = builder.entryBuilder()
.startBooleanToggle(translatable(getFieldName("enchantment", "requireEnchantment")), config.isRequireEnchantment())
.setDefaultValue(false)
Expand All @@ -382,9 +365,6 @@ private void fillEnchantmentConfigScreen(@NotNull ConfigBuilder builder, @NotNul
.build();

var enchantment = builder.getOrCreateCategory(translatable("text.autoconfig.fallingtree.category.enchantment"));
enchantment.addEntry(registerEnchantEntry);
enchantment.addEntry(registerSpecificEnchantEntry);
enchantment.addEntry(hideEnchantEntry);
enchantment.addEntry(requireEnchantmentEntry);
}

Expand Down

0 comments on commit 4150e6c

Please sign in to comment.