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 .github/workflows/auto-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
name: '${{ github.ref_name }}-${{ steps.ver.outputs.version}} SNAPSHOT ${{ env.VERSION_SUFFIX }}'
prerelease: true
body: |
The latest build of GTMoreMachine for Minecraft ${{ github.ref_name }}.
Please report any [issues](https://github.com/ModularMCLib/Registrate/issues).
The latest build of RegistrateLib for Minecraft ${{ github.ref_name }}.
Please report any [issues](https://github.com/ModularMCLib/RegistrateLib/issues).
${{ steps.changelog.outputs.changelog }}
files: build/libs/*.jar
12 changes: 6 additions & 6 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ jobs:
# modrinth-id: aADDBrNC
# modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
# files: |
# ./gtmoremachine-${{ env.MC_VERSION }}-${{ needs.build.outputs.ver }}.jar
# ./!(gtmoremachine-${{ env.MC_VERSION }}-${{ needs.build.outputs.ver }}.jar)
# name: 'GTMoreMachine ${{ env.MC_VERSION }}-${{ needs.build.outputs.ver }}'
# ./registrate-${{ env.MC_VERSION }}-${{ needs.build.outputs.ver }}.jar
# ./!(registrate-${{ env.MC_VERSION }}-${{ needs.build.outputs.ver }}.jar)
# name: 'RegistrateLib ${{ env.MC_VERSION }}-${{ needs.build.outputs.ver }}'
# version: 'mc${{ env.MC_VERSION }}-${{ needs.build.outputs.ver }}'
# version-type: ${{ env.VERSION_TYPE }}
# changelog: ${{ inputs.release-body }}
Expand Down Expand Up @@ -136,9 +136,9 @@ jobs:
# curseforge-id: 1397216
# curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }}
# files: |
# ./gtmoremachine-${{ env.MC_VERSION }}-${{ needs.build.outputs.ver }}.jar
# ./!(gtmoremachine-${{ env.MC_VERSION }}-${{ needs.build.outputs.ver }}.jar)
# name: 'GTMoreMachine ${{ env.MC_VERSION }}-${{ needs.build.outputs.ver }}'
# ./registrate-${{ env.MC_VERSION }}-${{ needs.build.outputs.ver }}.jar
# ./!(registrate-${{ env.MC_VERSION }}-${{ needs.build.outputs.ver }}.jar)
# name: 'RegistrateLib ${{ env.MC_VERSION }}-${{ needs.build.outputs.ver }}'
# version: 'mc${{ env.MC_VERSION }}-${{ needs.build.outputs.ver }}'
# version-type: ${{ env.VERSION_TYPE }}
# changelog: ${{ inputs.release-body }}
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Registrate [![Build Status](https://img.shields.io/jenkins/build?jobUrl=https%3A%2F%2Fci.tterrag.com%2Fjob%2FRegistrate%2Fjob%2F1.21%2F)](https://ci.tterrag.com/job/Registrate/job/1.21) [![License](https://img.shields.io/github/license/tterrag1098/Registrate?cacheSeconds=36000)](https://www.tldrlegal.com/l/mpl-2.0) [![Maven Version](https://img.shields.io/maven-metadata/v?metadataUrl=https%3A%2F%2Fmaven.tterrag.com%2Fcom%2Ftterrag%2Fregistrate%2FRegistrate%2Fmaven-metadata.xml)](https://maven.tterrag.com/com/tterrag/registrate/Registrate) ![Minecraft Version](https://img.shields.io/badge/minecraft-1.21.8-blue) [![Discord](https://img.shields.io/discord/175740881389879296?label=discord&logo=discord&color=7289da)](https://discord.gg/gZqYcEj)
# RegistrateLib [![Build Status](https://img.shields.io/jenkins/build?jobUrl=https%3A%2F%2Fci.tterrag.com%2Fjob%2FRegistrate%2Fjob%2F1.21%2F)](https://ci.tterrag.com/job/Registrate/job/1.21) [![License](https://img.shields.io/github/license/ModularMCLib/RegistrateLib?cacheSeconds=36000)](https://www.tldrlegal.com/l/mpl-2.0) [![Maven Version](https://img.shields.io/maven-metadata/v?metadataUrl=https%3A%2F%2Fmaven.tterrag.com%2Fcom%2Ftterrag%2Fregistrate%2FRegistrate%2Fmaven-metadata.xml)](https://maven.tterrag.com/com/tterrag/registrate/Registrate) ![Minecraft Version](https://img.shields.io/badge/minecraft-26.1.1-blue) [![Discord](https://img.shields.io/discord/175740881389879296?label=discord&logo=discord&color=7289da)](https://discord.gg/gZqYcEj)

A powerful wrapper for creating and registering objects in your mod.

Expand Down Expand Up @@ -91,25 +91,25 @@ public static final RegistryEntry<MyStairsBlock> MY_STAIRS = REGISTRATE.block("m

This customized version will create a BlockItem (with its own default model and lang entry), add the block to a tag, configure the blockstate for stair properties, and add a custom localization.

To get an overview of the different APIs and methods, check out the [Javadocs](https://ci.tterrag.com/job/Registrate/job/1.21/javadoc/). For more advanced usage, read the [wiki](https://github.com/tterrag1098/Registrate/wiki) (WIP).
To get an overview of the different APIs and methods, check out the [Javadocs](https://ci.tterrag.com/job/Registrate/job/1.21/javadoc/). For more advanced usage, read the [wiki](https://github.com/ModularMCLib/RegistrateLib/wiki) (WIP).

## Project Setup

For this `26.1` fork, the preferred integration model is to depend on Registrate as a normal NeoForge library mod and declare it as a required dependency in your own metadata. Bundling remains possible for tightly controlled distributions, but standalone dependency loading is the default posture for this branch.
For this `26.1` fork, the preferred integration model is to depend on RegistrateLib as a normal NeoForge library mod and declare it as a required dependency in your own metadata. Bundling remains possible for tightly controlled distributions, but standalone dependency loading is the default posture for this branch.

Add the library to your Gradle dependencies:

```groovy
dependencies {
implementation "com.modularmc.registrate:registrate:${registrate_version}"
implementation "com.modularmc.registrate:registratelib:${registratelib_version}"
}
```

Then declare `registrate` as a required dependency in your `neoforge.mods.toml`:
Then declare `registratelib` as a required dependency in your `neoforge.mods.toml`:

```toml
[[dependencies.yourmodid]]
modId="registrate"
modId="registratelib"
type="required"
versionRange="[2.0.0,)"
ordering="AFTER"
Expand Down
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ org.gradle.caching = true


# Mod Info
mod_id = registrate
mod_name = Registrate
mod_id = registratelib
mod_name = RegistrateLib
mod_version = 2.0.0
mod_description =
mod_license = Mozilla Public License Version 2.0
mod_url = https://github.com/ModularMCLib/Registrate/
mod_issue_tracker = https://github.com/ModularMCLib/Registrate/issues/
mod_url = https://github.com/ModularMCLib/RegistrateLib/
mod_issue_tracker = https://github.com/ModularMCLib/RegistrateLib/issues/
maven_group = com.modularmc.registrate
49 changes: 37 additions & 12 deletions src/main/java/com/modularmc/registrate/AbstractRegistrate.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.modularmc.registrate.internal.event.OneTimeEventReceiver;
import com.modularmc.registrate.internal.lifecycle.RegistrateLifecycle;
import com.modularmc.registrate.internal.util.DebugMarkers;
import com.modularmc.registrate.internal.util.RegistrateLogger;
import com.modularmc.registrate.providers.*;
import com.modularmc.registrate.providers.core.*;
import com.modularmc.registrate.util.CreativeModeTabModifier;
Expand Down Expand Up @@ -49,9 +50,9 @@
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import lombok.extern.log4j.Log4j2;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.message.Message;
import org.jspecify.annotations.Nullable;

Expand Down Expand Up @@ -86,9 +87,11 @@
*
* For specifics as to building different registry entries, read the documentation on their respective builders.
*/
@Log4j2
public abstract class AbstractRegistrate<S extends AbstractRegistrate<S>> {

private static final Logger LOGGER = RegistrateLogger.core();
private static final Logger DATAGEN_LOGGER = RegistrateLogger.datagen();

/**
* Checks if Minecraft is running from a dev environment. Enables certain debug logging.
*
Expand Down Expand Up @@ -173,7 +176,7 @@ public void onData(GatherDataEvent event) {
*/
protected AbstractRegistrate(String modid) {
this.modid = modid;
this.registrationTracker = new RegistrationTracker(modid, log);
this.registrationTracker = new RegistrationTracker(modid);
this.lifecycle = new RegistrateLifecycle(this, new LifecycleHooks());
}

Expand Down Expand Up @@ -657,12 +660,23 @@ public <T> void genData(GeneratorType<? extends T> type, T gen) {
}
datagens.get(type).forEach(cons -> {
Optional<Pair<String, ResourceKey<? extends Registry<?>>>> entry = Optional.empty();
if (log.isEnabled(Level.DEBUG, DebugMarkers.DATA)) {
if (DATAGEN_LOGGER.isEnabled(Level.DEBUG, DebugMarkers.DATA)) {
entry = getEntryForGenerator(type, cons);
if (entry.isPresent()) {
log.debug(DebugMarkers.DATA, "Generating data of type {} for entry {} [{}]", RegistrateDataProvider.getTypeName(type), entry.get().getLeft(), entry.get().getRight().identifier());
DATAGEN_LOGGER.debug(
DebugMarkers.DATA,
RegistrateLogger.modMessage("Generating data of type {} for entry {} [{}]"),
modid,
RegistrateDataProvider.getTypeName(type),
entry.get().getLeft(),
entry.get().getRight().identifier());
} else {
log.debug(DebugMarkers.DATA, "Generating unassociated data of type {} ({})", RegistrateDataProvider.getTypeName(type), type);
DATAGEN_LOGGER.debug(
DebugMarkers.DATA,
RegistrateLogger.modMessage("Generating unassociated data of type {} ({})"),
modid,
RegistrateDataProvider.getTypeName(type),
type);
}
}
try {
Expand All @@ -673,12 +687,21 @@ public <T> void genData(GeneratorType<? extends T> type, T gen) {
}
Message err;
if (entry.isPresent()) {
err = log.getMessageFactory().newMessage("Unexpected error while running data generator of type {} for entry {} [{}]", RegistrateDataProvider.getTypeName(type), entry.get().getLeft(), entry.get().getRight().identifier());
err = DATAGEN_LOGGER.getMessageFactory().newMessage(
RegistrateLogger.modMessage("Unexpected error while running data generator of type {} for entry {} [{}]"),
modid,
RegistrateDataProvider.getTypeName(type),
entry.get().getLeft(),
entry.get().getRight().identifier());
} else {
err = log.getMessageFactory().newMessage("Unexpected error while running unassociated data generator of type {} ({})", RegistrateDataProvider.getTypeName(type), type);
err = DATAGEN_LOGGER.getMessageFactory().newMessage(
RegistrateLogger.modMessage("Unexpected error while running unassociated data generator of type {} ({})"),
modid,
RegistrateDataProvider.getTypeName(type),
type);
}
if (skipErrors) {
log.error(err);
DATAGEN_LOGGER.error(err);
} else {
throw new RuntimeException(err.getFormattedMessage(), e);
}
Expand All @@ -698,7 +721,9 @@ public <T> void genData(GeneratorType<? extends T> type, T gen) {
*/
public S skipErrors(boolean skipErrors) {
if (skipErrors && !isDevEnvironment()) {
log.error("Ignoring skipErrors(true) as this is not a development environment!");
LOGGER.warn(
RegistrateLogger.modMessage("Ignoring skipErrors(true) because the runtime is not a development environment"),
modid);
} else {
this.skipErrors = skipErrors;
}
Expand Down Expand Up @@ -806,7 +831,7 @@ public <R, T extends R, P, S2 extends Builder<R, T, P, S2>> S2 transform(NonNull

/**
* Create a builder for a new entry. This is typically not needed, unless you are implementing a
* <a href="https://github.com/tterrag1098/Registrate/wiki/Custom-Builders">custom builder type</a>.
* <a href="https://github.com/ModularMCLib/RegistrateLib/wiki/Custom-Builders">custom builder type</a>.
* <p>
* Uses the currently set name (via {@link #object(String)}) as the name for the new entry, and passes it to the
* factory as the first parameter.
Expand All @@ -829,7 +854,7 @@ public <R, T extends R, P, S2 extends Builder<R, T, P, S2>> S2 entry(NonNullBiFu

/**
* Create a builder for a new entry. This is typically not needed, unless you are implementing a
* <a href="https://github.com/tterrag1098/Registrate/wiki/Custom-Builders">custom builder type</a>.
* <a href="https://github.com/ModularMCLib/RegistrateLib/wiki/Custom-Builders">custom builder type</a>.
*
* @param <R>
* Registry type
Expand Down
20 changes: 9 additions & 11 deletions src/main/java/com/modularmc/registrate/Registrate.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
package com.modularmc.registrate;

import com.modularmc.registrate.internal.util.RegistrateLogger;

import net.neoforged.bus.api.IEventBus;
import net.neoforged.fml.ModContainer;
import net.neoforged.fml.ModList;

import lombok.extern.log4j.Log4j2;
import org.apache.logging.log4j.Logger;

import java.util.Optional;

@Log4j2
public class Registrate extends AbstractRegistrate<Registrate> {

private static final Logger LOGGER = RegistrateLogger.core();

/**
* Create a new {@link Registrate} and register event listeners for registration and data generation. Used in lieu
* of adding side-effects to constructor, so that alternate initialization
Expand All @@ -26,15 +29,10 @@ public static Registrate create(String modid) {
Optional<IEventBus> modEventBus = ModList.get().getModContainerById(modid)
.map(ModContainer::getEventBus);

modEventBus.ifPresentOrElse(ret::registerEventListeners, () -> {
String message = "# [Registrate] Failed to register eventListeners for mod " + modid + ", This should be reported to this mod's dev #";

StringBuilder hashtags = new StringBuilder().append("#".repeat(message.length()));

log.fatal(hashtags.toString());
log.fatal(message);
log.fatal(hashtags.toString());
});
modEventBus.ifPresentOrElse(ret::registerEventListeners, () -> LOGGER.fatal(
RegistrateLogger.modMessage(
"Failed to locate the mod event bus during Registrate.create; registration listeners were not attached"),
modid));

return ret;
}
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/com/modularmc/registrate/RegistrateLib.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import net.neoforged.bus.api.IEventBus;
import net.neoforged.fml.common.Mod;

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

/**
* Runtime entrypoint for the ModularMCLib variant of Registrate.
*
Expand All @@ -15,7 +18,9 @@
@Mod(RegistrateLib.MOD_ID)
public final class RegistrateLib {

public static final String MOD_ID = "registrate";
public static final String MOD_ID = "registratelib";
public static final String MOD_NAME = "Registrate Lib";
public static final Logger LOGGER = LogManager.getLogger(MOD_NAME);

public RegistrateLib(IEventBus modEventBus) {}
}
Loading
Loading