Skip to content

Commit

Permalink
fix server crash due to tooltips (closes #4), add config gui for mod …
Browse files Browse the repository at this point in the history
…menu
  • Loading branch information
LemmaEOF committed Apr 24, 2019
1 parent 65a7873 commit 8656833
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 3 deletions.
6 changes: 5 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ targetCompatibility = 1.8

archivesBaseName = "epicurean-gastronomy"
group = "io.github.cottonmc"
version = "2.1.1+1.14"
version = "2.1.2+1.14"

minecraft {
refmapName = 'mixins.epicurean.refmap.json'
Expand All @@ -32,6 +32,7 @@ minecraft {
repositories {
mavenCentral()
maven { url 'http://server.bbkr.space:8081/artifactory/libs-snapshot/' }
maven { url = "https://minecraft.curseforge.com/api/maven" }
}

dependencies {
Expand All @@ -41,8 +42,11 @@ dependencies {
modCompile "net.fabricmc:fabric:0.2.7+build.127"
include "net.fabricmc:fabric:0.2.7+build.127"

modCompile "io.github.prospector.modmenu:ModMenu:1.4.1-74"
modCompile "io.github.cottonmc:cotton:0.6.0+1.14-SNAPSHOT"
include "io.github.cottonmc:cotton:0.6.0+1.14-SNAPSHOT"
modCompile "cloth-config:ClothConfig:0.2.1.14"
include "cloth-config:ClothConfig:0.2.1.14"
}

processResources {
Expand Down
30 changes: 30 additions & 0 deletions src/main/java/io/github/cottonmc/epicurean/ConfigManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@
import io.github.cottonmc.repackage.blue.endless.jankson.JsonElement;
import io.github.cottonmc.repackage.blue.endless.jankson.JsonObject;
import io.github.cottonmc.repackage.blue.endless.jankson.impl.SyntaxError;
import me.shedaniel.cloth.api.ConfigScreenBuilder;
import me.shedaniel.cloth.gui.ClothConfigScreen;
import me.shedaniel.cloth.gui.entries.*;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.client.MinecraftClient;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.lang.reflect.Method;

public class ConfigManager {
private static String configName = "EpicureanGastronomy";
Expand Down Expand Up @@ -88,4 +93,29 @@ public static void save(Object obj) {
EpicureanGastronomy.LOGGER.warn("Failed to save config file: ", e);
}
}

public static void getConfigScreen() {
try {
Class<?> clazz = Class.forName("io.github.prospector.modmenu.api.ModMenuApi");
Method method = clazz.getMethod("addConfigOverride", String.class, Runnable.class);
method.invoke(null, "epicurean", (Runnable) () -> {
ClothConfigScreen.Builder builder = new ClothConfigScreen.Builder(MinecraftClient.getInstance().currentScreen, "Epicurean Gastronomy Config", null);
builder.addCategories("Primary Features", "Fun Features");
ConfigScreenBuilder.CategoryBuilder primaryFeatures = builder.getCategory("Primary Features");
primaryFeatures.addOption(new BooleanListEntry("Hopper Harvesting", EpicureanGastronomy.config.hopperHarvest, "text.cloth-config.reset_value", () -> false, null));
primaryFeatures.addOption(new BooleanListEntry("Saturation Only", EpicureanGastronomy.config.useSaturationOnly, "text.cloth-config.reset_value", () -> false, null));
primaryFeatures.addOption(new IntegerListEntry("Natural Regen Speed", EpicureanGastronomy.config.naturalRegenSpeed, "text.cloth-config.reset_value", () -> 15, null));
primaryFeatures.addOption(new DoubleListEntry("Seasoning Efficiency", EpicureanGastronomy.config.seasoningEfficiency, "text.cloth-config.reset_value", () -> 0.3d, null));
ConfigScreenBuilder.CategoryBuilder funFeatures = builder.getCategory("Fun Features");
funFeatures.addOption(new BooleanListEntry("Edible Nuggets", EpicureanGastronomy.config.edibleNuggets, "text.cloth-config.reset_value", () -> false, null));
funFeatures.addOption(new BooleanListEntry("Omnivore Mode", EpicureanGastronomy.config.omnivoreEnabled, "text.cloth-config.reset_value", () -> false, null));
funFeatures.addOption(new IntegerSliderEntry("Omnivore Hunger", 0, 20, EpicureanGastronomy.config.omnivoreFoodRestore, "text.cloth-config.reset_value", () -> 2, null));
funFeatures.addOption(new FloatListEntry("Omnivore Saturation", EpicureanGastronomy.config.omnivoreSaturationRestore, "text.cloth-config.reset_value", () -> 0.25f, null));
funFeatures.addOption(new DoubleListEntry("Omnivore Item Damage", EpicureanGastronomy.config.omnivoreItemDamage, "text.cloth-config.reset_value", () -> 30d, null));
MinecraftClient.getInstance().openScreen(builder.build());
});
} catch (Exception e) {
EpicureanGastronomy.LOGGER.error("Failed to add config screen to Mod Menu", e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder;
import net.fabricmc.fabric.api.resource.ResourceManagerHelper;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.resource.ResourceType;
Expand Down Expand Up @@ -38,6 +39,10 @@ public void onInitialize() {
EpicureanRecipes.init();
CropGeneration.registerCrops();
ResourceManagerHelper.get(ResourceType.DATA).registerReloadListener(new IngredientProfiles());

if (FabricLoader.getInstance().isModLoaded("modmenu")) {
ConfigManager.getConfigScreen();
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.FoodItemSetting;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
Expand Down
5 changes: 4 additions & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
},
"mixins": [
"epicurean.common.json",
"epicurean.client.json"
{
"config": "epicurean.client.json",
"environment": "client"
}
],
"requires": {
"fabricloader": ">=0.4.0",
Expand Down

0 comments on commit 8656833

Please sign in to comment.