Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
id 'java-library'
id 'maven-publish'
id 'net.neoforged.moddev' version '2.0.91'
id 'net.neoforged.moddev' version '2.0.92'
id 'idea'
}

Expand Down Expand Up @@ -64,7 +64,7 @@ neoForge {
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
}

clientData {
data {
clientData()

// example of overriding the workingDirectory set in configureEach above, uncomment if you want to use it
Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ minecraft_version=1.21.4
# The Minecraft version range can use any release version of Minecraft as bounds.
# Snapshots, pre-releases, and release candidates are not guaranteed to sort properly
# as they do not follow standard versioning conventions.
minecraft_version_range=[1.21.4, 1.22)
minecraft_version_range=[1.21.4]
# The Neo version must agree with the Minecraft version to get a valid artifact
neo_version=21.4.138
# The Neo version range can use any version of Neo as bounds
neo_version_range=[21.4.0-beta,)
neo_version_range=[21.4.138,)
# The loader version range can only use the major version of FML as bounds
loader_version_range=[4,)
loader_version_range=[1,)

## Mod Properties

Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
9 changes: 4 additions & 5 deletions gradlew

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

188 changes: 94 additions & 94 deletions gradlew.bat

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ pluginManagement {
}

plugins {
id 'org.gradle.toolchains.foojay-resolver-convention' version '1.0.0'
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.9.0'
}
27 changes: 4 additions & 23 deletions src/main/java/com/example/examplemod/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,15 @@

// An example config class. This is not required, but it's a good idea to have one to keep your config organized.
// Demonstrates how to use Neo's config APIs
@EventBusSubscriber(modid = ExampleMod.MODID, bus = EventBusSubscriber.Bus.MOD)
public class Config
{
private static final ModConfigSpec.Builder BUILDER = new ModConfigSpec.Builder();

private static final ModConfigSpec.BooleanValue LOG_DIRT_BLOCK = BUILDER
public static final ModConfigSpec.BooleanValue LOG_DIRT_BLOCK = BUILDER
.comment("Whether to log the dirt block on common setup")
.define("logDirtBlock", true);

private static final ModConfigSpec.IntValue MAGIC_NUMBER = BUILDER
public static final ModConfigSpec.IntValue MAGIC_NUMBER = BUILDER
.comment("A magic number")
.defineInRange("magicNumber", 42, 0, Integer.MAX_VALUE);

Expand All @@ -32,32 +31,14 @@ public class Config
.define("magicNumberIntroduction", "The magic number is... ");

// a list of strings that are treated as resource locations for items
private static final ModConfigSpec.ConfigValue<List<? extends String>> ITEM_STRINGS = BUILDER
public static final ModConfigSpec.ConfigValue<List<? extends String>> ITEM_STRINGS = BUILDER
.comment("A list of items to log on common setup.")
.defineListAllowEmpty("items", List.of("minecraft:iron_ingot"), Config::validateItemName);
.defineListAllowEmpty("items", List.of("minecraft:iron_ingot"), () -> "", Config::validateItemName);

static final ModConfigSpec SPEC = BUILDER.build();

public static boolean logDirtBlock;
public static int magicNumber;
public static String magicNumberIntroduction;
public static Set<Item> items;

private static boolean validateItemName(final Object obj)
{
return obj instanceof String itemName && BuiltInRegistries.ITEM.containsKey(ResourceLocation.parse(itemName));
}

@SubscribeEvent
static void onLoad(final ModConfigEvent event)
{
logDirtBlock = LOG_DIRT_BLOCK.get();
magicNumber = MAGIC_NUMBER.get();
magicNumberIntroduction = MAGIC_NUMBER_INTRODUCTION.get();

// convert the list of strings into a set of items
items = ITEM_STRINGS.get().stream()
.map(itemName -> BuiltInRegistries.ITEM.getValue(ResourceLocation.parse(itemName)))
.collect(Collectors.toSet());
}
}
6 changes: 3 additions & 3 deletions src/main/java/com/example/examplemod/ExampleMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@ private void commonSetup(final FMLCommonSetupEvent event)
// Some common setup code
LOGGER.info("HELLO FROM COMMON SETUP");

if (Config.logDirtBlock)
if (Config.LOG_DIRT_BLOCK.getAsBoolean())
LOGGER.info("DIRT BLOCK >> {}", BuiltInRegistries.BLOCK.getKey(Blocks.DIRT));

LOGGER.info(Config.magicNumberIntroduction + Config.magicNumber);
LOGGER.info("{}{}", Config.MAGIC_NUMBER_INTRODUCTION.get(), Config.MAGIC_NUMBER.getAsInt());

Config.items.forEach((item) -> LOGGER.info("ITEM >> {}", item.toString()));
Config.ITEM_STRINGS.get().forEach((item) -> LOGGER.info("ITEM >> {}", item));
}

// Add the example block item to the building blocks tab
Expand Down
18 changes: 18 additions & 0 deletions src/main/java/com/example/examplemod/ExampleModClient.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.example.examplemod;

import net.neoforged.api.distmarker.Dist;
import net.neoforged.fml.ModContainer;
import net.neoforged.fml.common.Mod;
import net.neoforged.neoforge.client.gui.ConfigurationScreen;
import net.neoforged.neoforge.client.gui.IConfigScreenFactory;

// This class will not load on dedicated servers. Accessing client side code from here is safe.
@Mod(value = ExampleMod.MODID, dist = Dist.CLIENT)
public class ExampleModClient {
public ExampleModClient(ModContainer container) {
// Allows NeoForge to create a config screen for this mod's configs.
// The config screen is accessed by going to the Mods screen > clicking on your mod > clicking on config.
// Do not forget to add translations for your config options to the en_us.json file.
container.registerExtensionPoint(IConfigScreenFactory.class, ConfigurationScreen::new);
}
}
10 changes: 9 additions & 1 deletion src/main/resources/assets/examplemod/lang/en_us.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
{
"itemGroup.examplemod": "Example Mod Tab",
"block.examplemod.example_block": "Example Block",
"item.examplemod.example_item": "Example Item"
"item.examplemod.example_item": "Example Item",

"examplemod.configuration.title": "Example Mod Configs",
"examplemod.configuration.section.examplemod.common.toml": "Example Mod Configs",
"examplemod.configuration.section.examplemod.common.toml.title": "Example Mod Configs",
"examplemod.configuration.items": "Item List",
"examplemod.configuration.logDirtBlock": "Log Dirt Block",
"examplemod.configuration.magicNumberIntroduction": "Magic Number Text",
"examplemod.configuration.magicNumber": "Magic Number"
}
1 change: 1 addition & 0 deletions src/main/templates/META-INF/neoforge.mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# The overall format is standard TOML format, v0.5.0.
# Note that there are a couple of TOML lists in this file.
# Find more information on toml format here: https://github.com/toml-lang/toml

# The name of the mod loader type to load - for regular FML @Mod mods it should be javafml
modLoader="javafml" #mandatory

Expand Down