Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Bawnorton committed Sep 8, 2024
1 parent 6b7a16c commit 7b35660
Show file tree
Hide file tree
Showing 15 changed files with 53 additions and 39 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 1.0.1
- Prevent config screen generator from init'ing on the server
- Add "description" to description translation key

# 1.0.0

Initial Release
6 changes: 3 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,11 @@ extensions.configure<PublishingExtension> {
}

publishMods {
file = tasks.remapJar.get().archiveFile
val tag = "$loader-${mod.version}+$minecraftVersion"
file = tasks.shadowJar.get().archiveFile
val tag = "$loader-${mod.mappings}-${mod.version}+$minecraftVersion"
val branch = "main"
changelog = "[Changelog](https://github.com/Bawnorton/${mod.name}/blob/$branch/CHANGELOG.md)"
displayName = "${mod.name} ${loader.toString().replaceFirstChar { it.uppercase() }} ${mod.version} for $minecraftVersion"
displayName = "${mod.name} ${loader.toString().replaceFirstChar { it.uppercase() }} (${mod.mappings}) ${mod.version} for $minecraftVersion"
type = STABLE
modLoaders.add(loader.toString())

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ org.gradle.jvmargs=-Xmx4G
fabric_versions=1.21.1
neoforge_versions=1.21.1

mod_version=1.0.0
mod_version=1.0.1
mod_group=com.bawnorton
mod_id=configurable
mod_name=Configurable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static void init() {
try {
ConfigurableWrapper wrapper = new ConfigurableWrapper(ConfigurableApiImplLoader.getImpl(configName));
addToWrapped(settings::fullyQualifiedLoader, wrapper::setLoader, configName);
if(settings.hasScreenFactory()) {
if(settings.hasScreenFactory() && !Platform.isServer()) {
addToWrapped(settings::fullyQualifiedScreenFactory, wrapper::setScreenFactory, configName);
}
WRAPPERS.put(configName, wrapper);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

//? if fabric {

/*import com.google.gson.Gson;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonObject;
import javax.annotation.processing.Filer;
Expand Down Expand Up @@ -44,4 +44,4 @@ public String getName() {
return fmj.get("id").getAsString();
}
}
*///?}
//?}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

//? if neoforge {

import com.electronwill.nightconfig.core.Config;
/*import com.electronwill.nightconfig.core.Config;
import com.electronwill.nightconfig.toml.TomlParser;
import javax.annotation.processing.Filer;
import java.io.IOException;
Expand Down Expand Up @@ -41,4 +41,4 @@ public String getName() {
return config.<ArrayList<Config>>get("mods").getFirst().get("modId");
}
}
//?}
*///?}
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ public final class SourceProviders {

public static void registerDefaultSourceProviders() {
//? if fabric
/*registerSourceProvider(FabricSourceProvider::new);*/
registerSourceProvider(FabricSourceProvider::new);
//? if neoforge
registerSourceProvider(NeoForgeSourceProvider::new);
/*registerSourceProvider(NeoForgeSourceProvider::new);*/
}

public static void registerSourceProvider(SourceProviderFactory factory) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ public YaclSimpleDescriptionText(String configName, String key) {

@Override
public String getKey() {
return key;
return "description.%s".formatted(key);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ public interface ConfigurableApi {
GeneratedConfig afterLoad(GeneratedConfig config);

//? if neoforge
String getConfigName();
/*String getConfigName();*/
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import org.spongepowered.asm.mixin.Mixin;

//? if fabric {
/*import com.bawnorton.configurable.ConfigurableMain;
import com.bawnorton.configurable.ConfigurableMain;
import com.bawnorton.configurable.load.ConfigurableWrapper;
import com.terraformersmc.modmenu.ModMenu;
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
Expand Down Expand Up @@ -51,9 +51,9 @@ public ConfigScreenFactory<?> getModConfigScreenFactory() {
});
}
}
*///?} else {
import com.bawnorton.configurable.client.ConfigurableClient;
//?} else {
/*import com.bawnorton.configurable.client.ConfigurableClient;
@Mixin(ConfigurableClient.class)
public abstract class ModMenuMixin {}
//?}
*///?}
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
import com.bawnorton.configurable.client.ConfigurableClient;

//? if fabric {
/*import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.api.ClientModInitializer;

public final class ConfigurableClientWrapper implements ClientModInitializer {
@Override
public void onInitializeClient() {
ConfigurableClient.init();
}
}
*///?} elif neoforge {
import com.bawnorton.configurable.ConfigurableMain;
//?} elif neoforge {
/*import com.bawnorton.configurable.ConfigurableMain;
import com.bawnorton.configurable.platform.Platform;
import net.minecraft.client.MinecraftClient;
import net.neoforged.api.distmarker.Dist;
Expand Down Expand Up @@ -41,4 +41,4 @@ public ConfigurableClientWrapper() {
});
}
}
//?}
*///?}
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,29 @@
import java.util.Map;

//? if fabric {
/*import net.fabricmc.loader.api.FabricLoader;
*///?} elif neoforge {
import java.util.ServiceLoader;
//?}
import net.fabricmc.loader.api.FabricLoader;
//?} elif neoforge {
/*import java.util.ServiceLoader;
*///?}

public final class ConfigurableApiImplLoader {
//? if neoforge
private static final ServiceLoader<ConfigurableApi> serviceLoader = ServiceLoader.load(ConfigurableApi.class);
/*private static final ServiceLoader<ConfigurableApi> serviceLoader = ServiceLoader.load(ConfigurableApi.class);*/
private static final Map<String, ConfigurableApi> impls = new HashMap<>();

public static void load() {
//? if fabric {
/*FabricLoader.getInstance().getEntrypointContainers("configurable", ConfigurableApi.class).forEach(container -> {
FabricLoader.getInstance().getEntrypointContainers("configurable", ConfigurableApi.class).forEach(container -> {
String id = container.getProvider().getMetadata().getId();
try {
applyImpl(id, container.getEntrypoint());
} catch (Throwable e) {
ConfigurableMain.LOGGER.error("Mod {} provides a broken ConfigurableApi implemenation", id, e);
}
});
*///?} elif neoforge {
serviceLoader.forEach(apiImpl -> applyImpl(apiImpl.getConfigName(), apiImpl));
//?}
//?} elif neoforge {
/*serviceLoader.forEach(apiImpl -> applyImpl(apiImpl.getConfigName(), apiImpl));
*///?}
}

private static void applyImpl(String id, ConfigurableApi apiImpl) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@
import com.bawnorton.configurable.ConfigurableMain;

//? if fabric {
/*import net.fabricmc.api.ModInitializer;
import net.fabricmc.api.ModInitializer;

public final class ConfigurableWrapper implements ModInitializer {
@Override
public void onInitialize() {
ConfigurableMain.init();
}
}
*///?} elif neoforge {
import net.neoforged.fml.common.Mod;
//?} elif neoforge {
/*import net.neoforged.fml.common.Mod;
@Mod(ConfigurableMain.MOD_ID)
public final class ConfigurableWrapper {
public ConfigurableWrapper() {
ConfigurableMain.init();
}
}
//?}
*///?}
18 changes: 14 additions & 4 deletions src/main/java/com/bawnorton/configurable/platform/Platform.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
import java.util.function.Consumer;

//? if fabric {
/*import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.api.EnvType;
import net.fabricmc.loader.api.FabricLoader;
import java.util.List;

public final class Platform {
Expand All @@ -28,10 +29,15 @@ public static void forEachJar(Consumer<Path> consumer) {
}
});
}

public static boolean isServer() {
return FabricLoader.getInstance().getEnvironmentType().equals(EnvType.SERVER);
}
}

*///?} elif neoforge {
import net.neoforged.fml.ModContainer;
//?} elif neoforge {
/*import net.neoforged.fml.ModContainer;
import net.neoforged.fml.loading.FMLEnvironment;
import net.neoforged.fml.loading.FMLPaths;
import net.neoforged.fml.loading.LoadingModList;
import net.neoforged.fml.ModList;
Expand Down Expand Up @@ -69,5 +75,9 @@ public static ModContainer getContainer(String name) {
}
return null;
}
public static boolean isServer() {
return FMLEnvironment.dist.isDedicatedServer();
}
}
//?}
*///?}
2 changes: 1 addition & 1 deletion stonecutter.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
id("dev.kikugie.stonecutter")
}
stonecutter active "1.21.1-neoforge-yarn" /* [SC] DO NOT EDIT */
stonecutter active "1.21.1-fabric-yarn" /* [SC] DO NOT EDIT */

stonecutter registerChiseled tasks.register("chiseledBuildAndCollect", stonecutter.chiseled) {
group = "project"
Expand Down

0 comments on commit 7b35660

Please sign in to comment.