Skip to content

Commit

Permalink
Fixed DataGen not working on Fabric?
Browse files Browse the repository at this point in the history
  • Loading branch information
MeAlam1 committed Jan 3, 2025
1 parent c02d157 commit a4a3729
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 7 deletions.
6 changes: 6 additions & 0 deletions fabric/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ dependencies {
modImplementation "net.fabricmc.fabric-api:fabric-api:${fabric_version}"
}

fabricApi {
configureDataGeneration() {
client = true
}
}

loom {
def aw = project(':common').file("src/main/resources/${mod_id}.accesswidener")
if (aw.exists()) {
Expand Down
18 changes: 11 additions & 7 deletions fabric/src/main/java/software/bluelib/BlueLib.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

package software.bluelib;

import net.fabricmc.api.EnvType;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
import net.fabricmc.fabric.api.message.v1.ServerMessageEvents;
import net.fabricmc.loader.api.FabricLoader;
import software.bluelib.event.ChatHandler;
import software.bluelib.example.event.ReloadHandler;
import software.bluelib.test.TestRegistry;
Expand Down Expand Up @@ -51,13 +53,15 @@ public class BlueLib implements ModInitializer {
@Override
public void onInitialize() {
registerModEventListeners();
ClientTickEvents.END_CLIENT_TICK.register(client -> {
if (!hasInitialized) {
hasInitialized = true;
BlueLibCommon.init();
TestRegistry.registerTests();
}
});
TestRegistry.registerTests();
if (FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT) {
ClientTickEvents.END_CLIENT_TICK.register(client -> {
if (!hasInitialized) {
hasInitialized = true;
BlueLibCommon.init();
}
});
}
}

/**
Expand Down
14 changes: 14 additions & 0 deletions fabric/src/main/java/software/bluelib/datagen/DataGenerator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright (c) BlueLib. Licensed under the MIT License.

package software.bluelib.datagen;

import net.fabricmc.fabric.api.datagen.v1.DataGeneratorEntrypoint;
import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator;

public class DataGenerator implements DataGeneratorEntrypoint {

@Override
public void onInitializeDataGenerator(FabricDataGenerator generator) {
//FabricDataGenerator.Pack pack = generator.createPack();
}
}
2 changes: 2 additions & 0 deletions fabric/src/main/java/software/bluelib/event/ChatHandler.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Copyright (c) BlueLib. Licensed under the MIT License.

package software.bluelib.event;

import java.util.Objects;
Expand Down

0 comments on commit a4a3729

Please sign in to comment.