Skip to content

Commit

Permalink
3 modules now and almost all working
Browse files Browse the repository at this point in the history
  • Loading branch information
OroArmor committed Mar 4, 2021
1 parent e513274 commit e6c0572
Show file tree
Hide file tree
Showing 28 changed files with 182 additions and 219 deletions.
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ subprojects {
minecraft "com.mojang:minecraft:${rootProject.minecraft_version}"
mappings "net.fabricmc:yarn:1.16.5+build.4"
}

remapJar {
classifier project.name
}
}

allprojects {
Expand Down
38 changes: 0 additions & 38 deletions common-command/build.gradle

This file was deleted.

40 changes: 0 additions & 40 deletions common-screen/build.gradle

This file was deleted.

10 changes: 7 additions & 3 deletions common-testmod/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,19 @@ repositories {
}

dependencies {
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
compile(project(":common"))
compile(project(":common-command"))
compile(project(":common-screen"))
modApi "me.shedaniel:architectury:${rootProject.architectury_version}"
}

architectury {
common()
}

remapJar {
classifier "testmod"
}

java {
withSourcesJar()
}
Expand All @@ -36,4 +40,4 @@ publishing {
repositories {
// Add repositories to publish to here.
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
import com.oroarmor.config.Config;
import com.oroarmor.config.ConfigItem;
import com.oroarmor.config.ConfigItemGroup;
import me.shedaniel.architectury.Architectury;
import me.shedaniel.architectury.PlatformMethods;
import me.shedaniel.architectury.platform.Platform;

import net.fabricmc.loader.api.FabricLoader;
import static com.google.common.collect.ImmutableList.of;
Expand All @@ -16,7 +19,7 @@ public class TestConfig extends Config {
public static final List<ConfigItemGroup> configs = of(mainGroup);

public TestConfig() {
super(configs, new File(FabricLoader.getInstance().getConfigDir().toFile(), "oroarmor_config_testmod.json"), "oroarmor_config_testmod");
super(configs, new File(Platform.getConfigFolder().toFile(), "oroarmor_config_testmod.json"), "oroarmor_config_testmod");
}

public static class ConfigGroupLevel1 extends ConfigItemGroup {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.oroarmor.config.testmod;

import com.oroarmor.config.Config;
import com.oroarmor.config.command.ConfigCommand;
import me.shedaniel.architectury.event.events.CommandRegistrationEvent;
import me.shedaniel.architectury.event.events.LifecycleEvent;

import net.minecraft.server.command.CommandManager;

public class TestMod {
public static Config CONFIG = new TestConfig();

public static void initialize() {
CONFIG.readConfigFromFile();
LifecycleEvent.SERVER_STOPPED.register(instance -> CONFIG.saveConfigToFile());
CommandRegistrationEvent.EVENT.register((dispatcher, selection) -> new ConfigCommand(CONFIG).register(dispatcher, selection == CommandManager.RegistrationEnvironment.DEDICATED));
}
}
11 changes: 10 additions & 1 deletion common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,23 @@ architectury {
common()
}

repositories {
maven { url "https://maven.shedaniel.me/" }
}

dependencies {
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
testImplementation 'junit:junit:4.13.1'

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

java {
withSourcesJar()
}

archivesBaseName = rootProject.archives_base_name + "-config"
archivesBaseName = rootProject.archives_base_name
version = rootProject.mod_version
group = rootProject.maven_group
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import static net.minecraft.server.command.CommandManager.literal;

/**
* Creates a command register callback that is based of of a config. <br>
* Creates a com.oroarmor.config.command register callback that is based of of a config. <br>
* <br>
* Register with:
* <code>CommandRegistrationCallback.EVENT.register(new ConfigCommand(yourConfigInstance));</code>
Expand Down Expand Up @@ -104,17 +104,15 @@ private int listConfigGroups(CommandContext<ServerCommandSource> c) {
protected void parseConfigItemText(MutableText configList, ConfigItemGroup group, ConfigItem<?> item, String padding) {
configList.append(padding);
configList.append("|--> ");
switch (item.getType()) {
case GROUP:
configList.append(new LiteralText(item.getName() + "\n").formatted(Formatting.BOLD));
for (ConfigItem<?> item2 : ((ConfigItemGroup) item).getConfigs()) {
parseConfigItemText(configList, (ConfigItemGroup) item, item2, padding + "| ");
}
configList.append(padding + "/\n");
break;
default:
configList.append(createItemText(item, group));
configList.append("\n");
if (item.getType() == Type.GROUP) {
configList.append(new LiteralText(item.getName() + "\n").formatted(Formatting.BOLD));
for (ConfigItem<?> item2 : ((ConfigItemGroup) item).getConfigs()) {
parseConfigItemText(configList, (ConfigItemGroup) item, item2, padding + "| ");
}
configList.append(padding + "/\n");
} else {
configList.append(createItemText(item, group));
configList.append("\n");
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.oroarmor.config.modmenu;
package com.oroarmor.config.screen;

import java.util.List;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -31,12 +31,12 @@
*
* @author Eli Orona
*/
public abstract class ConfigScreen /*implements ModMenuApi*/ {
public abstract class ConfigScreen {

/**
* The config for the screen
*/
private final Config config;
protected final Config config;

/**
* Creates a new {@link ConfigScreen}
Expand All @@ -47,7 +47,7 @@ public ConfigScreen(Config config) {
this.config = config;
}

private ConfigCategory createCategory(ConfigBuilder builder, String categoryName) {
protected ConfigCategory createCategory(ConfigBuilder builder, String categoryName) {
return builder.getOrCreateCategory(new TranslatableText(categoryName));
}

Expand Down Expand Up @@ -96,7 +96,7 @@ private <T extends Enum<T>> AbstractConfigListEntry<?> createEnumConfigItem(Conf
}

@SuppressWarnings({"unchecked", "rawtypes"})
private void setupConfigItem(ConfigItem<?> ci, ConfigCategory category, ConfigEntryBuilder entryBuilder) {
protected void setupConfigItem(ConfigItem<?> ci, ConfigCategory category, ConfigEntryBuilder entryBuilder) {
switch (ci.getType()) {
case BOOLEAN:
setupBooleanConfigItem((ConfigItem<Boolean>) ci, category, entryBuilder);
Expand Down
15 changes: 11 additions & 4 deletions fabric-testmod/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {

repositories {
maven {
url = "https://jitpack.io"
url = "https://maven.terraformersmc.com/releases/"
}
}

Expand All @@ -29,11 +29,18 @@ dependencies {
runtimeOnly(project(path: ":common-testmod")) {
transitive = false
}
shadowCommonTestmod(project(path: ":common-testmod", configuration: "transformProductionFabric")) {
compileOnly(project(path: ":common")) {
transitive = false
}
runtimeOnly(project(path: ":common")) {
transitive = false
}

implementation(project(":fabric"))

shadow(project(path: ":fabric-screen"))
modRuntime("com.terraformersmc:modmenu:1.16.8")
modApi "me.shedaniel:architectury-fabric:${rootProject.architectury_version}"
modApi "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}"
}

processResources {
Expand All @@ -52,7 +59,7 @@ shadowJar {
remapJar {
input.set shadowJar.archiveFile
dependsOn shadowJar
classifier "fabric"
classifier "fabric-testmod"
}

jar {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.oroarmor.config.testmod;

import com.oroarmor.config.modmenu.ModMenuConfigScreen;
import com.oroarmor.config.screen.ModMenuConfigScreen;

public class ModMenuIntegration extends ModMenuConfigScreen {
public ModMenuIntegration() {
super(OroConfigTestMod.CONFIG);
super(TestMod.CONFIG);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.oroarmor.config.testmod;

import net.fabricmc.api.ModInitializer;

public class OroConfigTestMod implements ModInitializer {
@Override
public void onInitialize() {
TestMod.initialize();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
]
},
"depends": {
"fabricloader": ">=0.7.4",
"fabric": "*"
"fabricloader": ">=0.7.4"
},
"suggests": {
"flamingo": "*"
Expand Down
11 changes: 9 additions & 2 deletions fabric-config/build.gradle → fabric/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {

repositories {
maven {
url = "https://jitpack.io"
url = "https://maven.terraformersmc.com/releases/"
}
}

Expand All @@ -19,7 +19,6 @@ configurations {

dependencies {
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
// include(modImplementation(fabricApi.module("fabric-command-api-v1", project.fabric_version)))

implementation(project(path: ":common")) {
transitive = false
Expand All @@ -30,6 +29,14 @@ dependencies {
shadowCommon(project(path: ":common", configuration: "transformProductionFabric")) {
transitive = false
}

modApi("com.terraformersmc:modmenu:1.16.8") {
exclude(module: "fabric-api")
}

include(modApi("me.shedaniel.cloth:cloth-config-fabric:4.11.14")) {
exclude(group: "net.fabricmc.fabric-api")
}
}

processResources {
Expand Down
Loading

0 comments on commit e6c0572

Please sign in to comment.