Skip to content

Commit

Permalink
GH-1 - Added mod config (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
xPand4B authored Feb 26, 2022
1 parent 754a30a commit dd05d4e
Show file tree
Hide file tree
Showing 11 changed files with 293 additions and 94 deletions.
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ body:
label: Mod Version
description: "Please select the used version of 'Towers of the Wild: Reworked'."
options:
- "v2.2.0"
- "v2.1.1"
- "v2.1.0"
- "v2.0.0"
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## v2.2.0
### What's Changed
* [GH-1](https://github.com/xPand4B/Towers_Of_The_Wild_Reworked/issues/1) - Added mod config by [@xPand4B](https://github.com/xPand4B) in [#14](https://github.com/xPand4B/Towers_Of_The_Wild_Reworked/pull/14)

**Full Changelog**: [v2.1.1...v.2.2.0](https://github.com/WaldiNet/Towers_Of_The_Wild_Reworked/compare/v2.1.1...v2.2.0)

## v2.1.1
### What's Changed
* Create es_cl.json by [DracoExE](https://github.com/DracoExE) in [#11](https://github.com/WaldiNet/Towers_Of_The_Wild_Reworked/pull/11)
Expand Down
29 changes: 27 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Have fun using this mod!
* [How to install](#how-to-install)
* [How to configure](#how-to-configure)
* [Credits](#credits)
* [How to build](#how-to-build)


## Getting started
Expand Down Expand Up @@ -61,18 +62,42 @@ This mod does not add any blocks or items to the game (if that matters to you).
**Prerequisite:**
* Minecraft 1.18.1
* [Fabric Loader](https://fabricmc.net/use/)
* [Fabric API](https://www.curseforge.com/minecraft/mc-mods/fabric-api) inside your `.minecraft/mods` directory
* [Fabric API](https://www.curseforge.com/minecraft/mc-mods/fabric-api) inside `.minecraft/mods`
* [Cloth Config API (Fabric)](https://www.curseforge.com/minecraft/mc-mods/cloth-config) inside `.minecraft/mods`

Simply put the file `towers_of_the_wild-*.jar` inside you mods directory.

**Note:**
If you also want to use [Waystones (Fabric Edition)](https://www.curseforge.com/minecraft/mc-mods/waystones-fabric) you'll also need the [Balm](https://www.curseforge.com/minecraft/mc-mods/balm-fabric) mod.

## How to configure
Will be implemented in a later build
The mod generates the file `.minecraft/config/towers_of_the_wild_reworked.json`.

There you can set a multiple of things:
* Should the tower type be active?
* What should be the spacing *(in chunks)*?
* What should be the separation *(in chunks)*?
* Do you want Waystones on top of towers?
* Some debugging stuff

### !!! Important !!! <!-- omit in toc -->
The spacing has to be higher than the separation!

## Credits
* [idrae_](https://github.com/Idrae) *(original author)*
* [RawPineapple](https://github.com/RawPineapple) *(translation for zh_cn)*
* [DracoExE](https://github.com/DracoExE) *(translation for es_cl)*
* [scarf005](https://github.com/scarf005) *(translation for ko_kr)*

## How to build
Just as with *(almost)* every fabric mod, run following commands and everything should be up an running.
```bash
gradlew genSources
gradlew build

# For Client testing
gradlew runClient

# For Server testing
gradlew runServer
```
39 changes: 6 additions & 33 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
plugins {
id 'fabric-loom' version '0.10-SNAPSHOT'
id 'maven-publish'
id 'com.matthewprenger.cursegradle' version '1.4.0'
}

sourceCompatibility = JavaVersion.VERSION_17
Expand All @@ -13,22 +12,22 @@ group = project.maven_group

repositories {
maven { url "https://maven.shedaniel.me/" }
maven { url = 'https://maven.terraformersmc.com/' }
}

dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

// modImplementation "com.terraformersmc:modmenu:${mod_menu_version}"
// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

// modApi("me.shedaniel.cloth:cloth-config-fabric:${cloth_config_version}") {
// exclude(group: "net.fabricmc.fabric-api")
// }
modApi("me.shedaniel.cloth:cloth-config-fabric:${cloth_config_version}") {
exclude(group: "net.fabricmc.fabric-api")
}
}


processResources {
inputs.property "version", project.version

Expand All @@ -52,32 +51,6 @@ jar {
}
}

// curseforge {
// apiKey = file("${rootDir}/curseforge_api_key.txt").exists() ? file("${rootDir}/curseforge_api_key.txt").text : ''
// project {
// id = curseforge_id
// releaseType = curseforge_release_type
// addGameVersion curseforge_minecraft_version
// addGameVersion 'Fabric'
// addGameVersion 'Java 18'
// addGameVersion 'Java 17'
// addGameVersion 'Java 16'
// mainArtifact(file("${buildDir}/libs/${archivesBaseName}-${version}.jar")) {
// displayName = "${minecraft_version} [v${version}]"
// relations {
// requiredDependency 'fabric-api'
// }
// }
// afterEvaluate {
// mainArtifact(remapJar)
// uploadTask.dependsOn(remapJar)
// }
// }
// options {
// forgeGradleIntegration = false
// }
// }

// configure the maven publication
publishing {
publications {
Expand Down
10 changes: 2 additions & 8 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,10 @@ loader_version=0.12.12

# Mod Properties
mod_name = Towers of the Wild: Reworked
mod_version = 2.1.1
mod_version = 2.2.0
maven_group = waldinet.towers_of_the_wild_reworked
archives_base_name = towers_of_the_wild_reworked

# Dependencies
fabric_version=0.44.0+1.18
# cloth_config_version=5.1.40
# mod_menu_version=2.0.2

# Curseforge
curseforge_id=552655
curseforge_release_type=release
curseforge_minecraft_version=1.18.1
cloth_config_version=6.0.45
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,23 @@
import net.minecraft.world.biome.Biome.Category;
import net.minecraft.world.gen.feature.StructureFeature;
import net.minecraft.world.gen.feature.StructurePoolFeatureConfig;
import waldinet.towers_of_the_wild_reworked.config.TowersOfTheWildReworkedConfig;
import waldinet.towers_of_the_wild_reworked.generator.DerelictGrassTowerGenerator;
import waldinet.towers_of_the_wild_reworked.generator.DerelictTowerGenerator;
import waldinet.towers_of_the_wild_reworked.generator.IceTowerGenerator;
import waldinet.towers_of_the_wild_reworked.generator.JungleTowerGenerator;
import waldinet.towers_of_the_wild_reworked.generator.RegularTowerGenerator;
import waldinet.towers_of_the_wild_reworked.structure.*;
import waldinet.towers_of_the_wild_reworked.utils.ConfigUtils;
import waldinet.towers_of_the_wild_reworked.utils.RegUtils;
import waldinet.towers_of_the_wild_reworked.utils.StructUtils;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import me.shedaniel.autoconfig.AutoConfig;
import me.shedaniel.autoconfig.serializer.GsonConfigSerializer;

public class TowersOfTheWildReworked implements ModInitializer
{
public static final TranslatableText MOD_NAME = new TranslatableText("mod.towers_of_the_wild_reworked.name");
Expand All @@ -31,6 +36,7 @@ public class TowersOfTheWildReworked implements ModInitializer
public static final String WAYSTONE_MOD_ID = "waystones";

public static final Logger LOGGER = LogManager.getLogger(MOD_ID);
public static TowersOfTheWildReworkedConfig CONFIG;

//#region Structures
public static final StructureFeature<StructurePoolFeatureConfig> DERELICT_GRASS_TOWER = new DerelictTowerStructure();
Expand All @@ -47,7 +53,14 @@ public class TowersOfTheWildReworked implements ModInitializer
@Override
public void onInitialize()
{
Log("Initializing...");
// Loading Config
AutoConfig.register(TowersOfTheWildReworkedConfig.class, GsonConfigSerializer::new);
CONFIG = AutoConfig.getConfigHolder(TowersOfTheWildReworkedConfig.class).getConfig();
ConfigUtils.Log("Config read successfully!");

if (CONFIG.debugging.logConfig) {
ConfigUtils.logConfig();
}

// Registering Structures and Features
registerStructures();
Expand All @@ -56,12 +69,7 @@ public void onInitialize()
// Adding to biomes
putStructures();

Log("Initializing finished!");
}

public static void Log(String message)
{
LOGGER.info(String.format("[Towers of the Wild: Reworked] %s", message));
ConfigUtils.Log("Initializing finished!");
}

public static Identifier id(String name)
Expand All @@ -71,30 +79,78 @@ public static Identifier id(String name)

private void registerStructures()
{
Log("Registering structures...");
ConfigUtils.Log("Registering structures...");

// https://github.dev/frqnny/mostructures
RegUtils.registerStructure(StructUtils.DERELICT_GRASS_TOWER, DERELICT_GRASS_TOWER, 72, 8, 1689781);
RegUtils.registerStructure(StructUtils.DERELICT_TOWER, DERELICT_TOWER, 72, 8, 1689780);
RegUtils.registerStructure(StructUtils.ICE_TOWER, ICE_TOWER, 35, 8, 1689779);
RegUtils.registerStructure(StructUtils.JUNGLE_TOWER, JUNGLE_TOWER, 38, 8, 1689778);
RegUtils.registerStructure(StructUtils.OCEAN_TOWER, OCEAN_TOWER, 38, 8, 1689782);
RegUtils.registerStructure(StructUtils.OCEAN_WARM_TOWER, OCEAN_WARM_TOWER, 32, 8, 1689782);
RegUtils.registerStructure(StructUtils.REGULAR_TOWER, REGULAR_TOWER, 42, 8, 1689777);

Log("Registration finished!");
RegUtils.registerStructure(
StructUtils.DERELICT_GRASS_TOWER,
DERELICT_GRASS_TOWER,
CONFIG.derelictGrassTower.spacing,
CONFIG.derelictGrassTower.separation,
1689781
);

RegUtils.registerStructure(
StructUtils.DERELICT_TOWER,
DERELICT_TOWER,
CONFIG.derelictTower.spacing,
CONFIG.derelictTower.separation,
1689780
);

RegUtils.registerStructure(
StructUtils.ICE_TOWER,
ICE_TOWER,
CONFIG.iceTower.spacing,
CONFIG.iceTower.separation,
1689779
);

RegUtils.registerStructure(
StructUtils.JUNGLE_TOWER,
JUNGLE_TOWER,
CONFIG.jungleTower.spacing,
CONFIG.jungleTower.separation,
1689778
);

RegUtils.registerStructure(
StructUtils.OCEAN_TOWER,
OCEAN_TOWER,
CONFIG.oceanTower.spacing,
CONFIG.oceanTower.separation,
1689782
);

RegUtils.registerStructure(
StructUtils.OCEAN_WARM_TOWER,
OCEAN_WARM_TOWER,
CONFIG.oceanWarmTower.spacing,
CONFIG.oceanWarmTower.separation,
1689782
);

RegUtils.registerStructure(
StructUtils.REGULAR_TOWER,
REGULAR_TOWER,
CONFIG.regularTower.spacing,
CONFIG.regularTower.separation,
1689777
);

ConfigUtils.Log("Registration finished!");
}

private void putStructures()
{
Log("Loading active structures...");
ConfigUtils.Log("Loading active structures...");

// Derelict Grass
RegUtils.addToBiome(
StructUtils.DERELICT_GRASS_TOWER,
BiomeSelectors
.categories(DerelictGrassTowerGenerator.BIOME_CATEGORIES)
// .and(RegUtils.booleanToPredicate(_config.derelictGrassTower.active))
.and(RegUtils.booleanToPredicate(CONFIG.derelictGrassTower.active))
.and(BiomeSelectors.foundInOverworld()),
(context) -> RegUtils.addStructure(context, ConfiguredFeatures.DERELICT_GRASS_TOWER)
);
Expand All @@ -104,7 +160,7 @@ private void putStructures()
StructUtils.DERELICT_TOWER,
BiomeSelectors
.categories(DerelictTowerGenerator.BIOME_CATEGORIES)
// .and(RegUtils.booleanToPredicate(_config.derelictTower.active))
.and(RegUtils.booleanToPredicate(CONFIG.derelictTower.active))
.and(BiomeSelectors.foundInOverworld()),
(context) -> RegUtils.addStructure(context, ConfiguredFeatures.DERELICT_TOWER)
);
Expand All @@ -114,7 +170,7 @@ private void putStructures()
StructUtils.ICE_TOWER,
BiomeSelectors
.categories(IceTowerGenerator.BIOME_CATEGORIES)
// .and(RegUtils.booleanToPredicate(_config.iceTower.active))
.and(RegUtils.booleanToPredicate(CONFIG.iceTower.active))
.and(BiomeSelectors.foundInOverworld()),
(context) -> RegUtils.addStructure(context, ConfiguredFeatures.ICE_TOWER)
);
Expand All @@ -124,7 +180,7 @@ private void putStructures()
StructUtils.JUNGLE_TOWER,
BiomeSelectors
.categories(JungleTowerGenerator.BIOME_CATEGORIES)
// .and(RegUtils.booleanToPredicate(_config.jungleTower.active))
.and(RegUtils.booleanToPredicate(CONFIG.jungleTower.active))
.and(BiomeSelectors.foundInOverworld()),
(context) -> RegUtils.addStructure(context, ConfiguredFeatures.JUNGLE_TOWER)
);
Expand All @@ -138,7 +194,7 @@ private void putStructures()
String string = context.getBiomeKey().getValue().toString();
return !string.contains("deep") && !string.contains("frozen");
})
// .and(RegUtils.booleanToPredicate(_config.oceanTower.active))
.and(RegUtils.booleanToPredicate(CONFIG.oceanTower.active))
.and(BiomeSelectors.foundInOverworld()),
(context) -> RegUtils.addStructure(context, ConfiguredFeatures.OCEAN_TOWER)
);
Expand All @@ -151,8 +207,8 @@ private void putStructures()
.and((context) -> {
String string = context.getBiomeKey().getValue().toString();
return string.equals("minecraft:warm_ocean");
}),
// .and(RegUtils.booleanToPredicate(_config.oceanWarmTower.active)),
})
.and(RegUtils.booleanToPredicate(CONFIG.oceanWarmTower.active)),
(context) -> RegUtils.addStructure(context, ConfiguredFeatures.OCEAN_WARM_TOWER)
);

Expand All @@ -161,11 +217,11 @@ private void putStructures()
StructUtils.REGULAR_TOWER,
BiomeSelectors
.categories(RegularTowerGenerator.BIOME_CATEGORIES)
// .and(RegUtils.booleanToPredicate(_config.regularTower.active))
.and(RegUtils.booleanToPredicate(CONFIG.regularTower.active))
.and(BiomeSelectors.foundInOverworld()),
(context) -> RegUtils.addStructure(context, ConfiguredFeatures.REGULAR_TOWER)
);

Log("Loading active structures finished!");
ConfigUtils.Log("Loading active structures finished!");
}
}
Loading

0 comments on commit dd05d4e

Please sign in to comment.