Skip to content

Commit 2a03338

Browse files
committed
Bump version
1 parent ddea528 commit 2a03338

12 files changed

+181
-62
lines changed

build.gradle

+42-54
Original file line numberDiff line numberDiff line change
@@ -6,74 +6,62 @@ plugins {
66
id 'fabric-loom' version '0.12-SNAPSHOT'
77
}
88

9-
allprojects {
10-
apply plugin: 'java'
11-
apply plugin: 'checkstyle'
12-
apply plugin: 'fabric-loom'
9+
apply plugin: 'java'
10+
apply plugin: 'checkstyle'
11+
apply plugin: 'fabric-loom'
1312

14-
group = project.maven_group
15-
version = project.mod_version
16-
archivesBaseName = "${project.mod_id}-mc${project.minecraft_version}"
13+
group = project.maven_group
14+
version = project.mod_version
15+
archivesBaseName = "${project.mod_id}-mc${project.minecraft_version}"
1716

18-
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_17
17+
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_17
1918

2019
// Declare dependencies
21-
dependencies {
22-
// Fabric
23-
minecraft "com.mojang:minecraft:${project.minecraft_version}"
24-
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
25-
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
26-
27-
// Mods
28-
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
29-
modImplementation "com.terraformersmc:modmenu:${project.mod_menu_version}"
30-
31-
// Code Quality
32-
compileOnly "org.jetbrains:annotations:${project.jetbrains_annotations_version}"
33-
testImplementation "org.junit.jupiter:junit-jupiter-api:${project.junit_jupiter_version}"
34-
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${project.junit_jupiter_version}"
35-
36-
// Subprojects
37-
subprojects.each {
38-
implementation project(path: ":${it.name}", configuration: 'namedElements')
39-
include project("${it.name}:") // nest within distribution
40-
}
41-
}
20+
dependencies {
21+
// Fabric
22+
minecraft "com.mojang:minecraft:${project.minecraft_version}"
23+
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
24+
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
25+
26+
// Mods
27+
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
28+
modImplementation "com.terraformersmc:modmenu:${project.mod_menu_version}"
29+
30+
// Code Quality
31+
compileOnly "org.jetbrains:annotations:${project.jetbrains_annotations_version}"
32+
}
4233

4334
// Produce a sources distribution
44-
java {
45-
withSourcesJar()
46-
}
35+
java {
36+
withSourcesJar()
37+
}
4738

4839
// Add the licence to all distributions
49-
tasks.withType(Jar).configureEach {
50-
it.from rootProject.file('LICENSE.txt')
51-
}
40+
tasks.withType(Jar).configureEach {
41+
it.from rootProject.file('LICENSE.txt')
42+
}
5243

5344
// Process any resources
54-
processResources {
55-
inputs.property 'id', project.mod_id
56-
inputs.property 'name', project.mod_name
57-
inputs.property 'version', project.version
58-
59-
// fabric.mod.json
60-
filesMatching('fabric.mod.json') {
61-
expand(['id': project.mod_id, 'name': project.mod_name, 'version': project.version])
62-
}
45+
processResources {
46+
inputs.property 'id', project.mod_id
47+
inputs.property 'name', project.mod_name
48+
inputs.property 'version', project.version
49+
filesMatching('fabric.mod.json') {
50+
expand(['id': project.mod_id, 'name': project.mod_name, 'version': project.version])
6351
}
52+
}
6453

6554
// Perform linting using Checkstyle
66-
checkstyle {
67-
configFile rootProject.file('.checkstyle.xml')
68-
toolVersion project.checkstyle_version
69-
}
55+
checkstyle {
56+
configFile rootProject.file('.checkstyle.xml')
57+
toolVersion project.checkstyle_version
58+
}
7059

7160
// Add any additional repositories
72-
repositories {
73-
mavenCentral()
74-
maven { name 'Fabric'; url 'https://maven.fabricmc.net/' }
75-
maven { name 'TerraformersMC'; url 'https://maven.terraformersmc.com/' }
76-
}
61+
repositories {
62+
mavenCentral()
63+
maven { name 'Fabric'; url 'https://maven.fabricmc.net/' }
64+
maven { name 'TerraformersMC'; url 'https://maven.terraformersmc.com/' }
7765
}
7866

7967
// Define how artifacts are published to Modrinth (https://modrinth.com)
@@ -92,7 +80,7 @@ modrinth {
9280
// Set the release version
9381
versionNumber = project.version
9482
// Set the release notes
95-
changelog = "For a list of changes, please refer to https://github.com/${project.github_repo}/releases/tag/v${project.version}"
83+
changelog = "For a list of changes, please refer to https://github.com/${project.github_repo}/releases/tag/${project.version}"
9684
// Add all supported mod loaders
9785
loaders = ['fabric']
9886
// Add all supported game versions

gradle.properties

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
mod_name = Mudrock
33
mod_id = mudrock
44
## {x-release-please-start-version}
5-
mod_version = 0.1.0
5+
mod_version = 0.1.1
66
## {x-release-please-end}
77

88
# Fabric
@@ -19,10 +19,10 @@ jetbrains_annotations_version = 23.0.0
1919
junit_jupiter_version = 5.8.2
2020

2121
# Modrinth
22-
mr_project_id = dohojEfz
22+
mr_project_id = 8abHI823
2323
mr_game_versions = 1.18, 1.18.1, 1.18.2
2424
mr_relations_required = P7dR8mSH
25-
mr_relations_optional = mOgUt4GM
25+
mr_relations_optional =
2626
mr_relations_incompatible =
2727

2828
# Publish

src/main/java/dev/intelligentcreations/mudrock/Mudrock.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import dev.intelligentcreations.mudrock.event.MudrockEventHandler;
44

5+
import dev.intelligentcreations.mudrock.registry.MudrockRegistry;
56
import net.fabricmc.api.ModInitializer;
67
import org.slf4j.Logger;
78
import org.slf4j.LoggerFactory;
@@ -14,7 +15,8 @@ public class Mudrock implements ModInitializer
1415
public void onInitialize()
1516
{
1617
LOGGER.info("Mudrock is getting ready...");
17-
LOGGER.info("Loaded " + MudrockEventHandler.getListenerCount() + " event listeners.");
18+
LOGGER.info("Loaded " + MudrockRegistry.getLoadedRegistryCount() + " registry handler(s).");
19+
LOGGER.info("Loaded " + MudrockEventHandler.getListenerCount() + " event listener(s).");
1820
LOGGER.info("Initialized.");
1921
}
2022
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package dev.intelligentcreations.mudrock;
2+
3+
import dev.intelligentcreations.mudrock.event.MudrockClientEventHandler;
4+
import net.fabricmc.api.ClientModInitializer;
5+
6+
public class MudrockClient implements ClientModInitializer
7+
{
8+
@Override
9+
public void onInitializeClient()
10+
{
11+
Mudrock.LOGGER.info("Loaded " + MudrockClientEventHandler.getListenerCount() + " client listeners.");
12+
}
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package dev.intelligentcreations.mudrock.event;
2+
3+
import dev.intelligentcreations.mudrock.Mudrock;
4+
import dev.intelligentcreations.mudrock.event.listeners.client.MudrockClientEventListener;
5+
import net.fabricmc.api.EnvType;
6+
import net.fabricmc.api.Environment;
7+
8+
import java.lang.reflect.InvocationTargetException;
9+
import java.util.ArrayList;
10+
import java.util.List;
11+
12+
/**
13+
* Event handler for all client-sided Mudrock events.
14+
*/
15+
@Environment(EnvType.CLIENT)
16+
public class MudrockClientEventHandler
17+
{
18+
/**
19+
* The list of client-sided listeners.
20+
* To get the list of listeners, use the getter.
21+
*/
22+
private static final List<MudrockClientEventListener> listeners = new ArrayList<>();
23+
24+
/**
25+
* Register a client-sided listener.
26+
* The listener must implement one of the interfaces that extends {@link MudrockClientEventListener}.
27+
*/
28+
public static <T extends MudrockClientEventListener> void registerListener(Class<T> listenerClass)
29+
{
30+
try
31+
{
32+
T listener = listenerClass.getDeclaredConstructor().newInstance();
33+
listeners.add(listener);
34+
Mudrock.LOGGER.info("Registered client-sided listener " + listenerClass.getName());
35+
} catch (NoSuchMethodException | InvocationTargetException | InstantiationException | IllegalAccessException e)
36+
{
37+
e.printStackTrace();
38+
throw new RuntimeException("No valid constructor found for: " + listenerClass.getName());
39+
}
40+
}
41+
42+
/**
43+
* Get the number of the loaded client-sided listeners.
44+
*/
45+
public static int getListenerCount()
46+
{
47+
return getListeners().size();
48+
}
49+
50+
/**
51+
* Get the list of the loaded listeners.
52+
*/
53+
public static List<MudrockClientEventListener> getListeners() {
54+
return listeners;
55+
}
56+
}

src/main/java/dev/intelligentcreations/mudrock/event/MudrockEventHandler.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import java.util.List;
99

1010
/**
11-
* Event handler for all Mudrock events.
11+
* Event handler for all (both-sided) Mudrock events.
1212
*/
1313
public class MudrockEventHandler
1414
{
@@ -41,7 +41,7 @@ public static <T extends MudrockEventListener> void registerListener(Class<T> li
4141
*/
4242
public static int getListenerCount()
4343
{
44-
return listeners.size();
44+
return getListeners().size();
4545
}
4646

4747
/**
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package dev.intelligentcreations.mudrock.event.listeners.client;
2+
3+
import net.minecraft.client.util.math.MatrixStack;
4+
import net.minecraft.util.Identifier;
5+
6+
public interface InGameHudAdder extends MudrockClientEventListener
7+
{
8+
Identifier getTexture();
9+
10+
void onHudRender(MatrixStack matrices, float tickDelta);
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package dev.intelligentcreations.mudrock.event.listeners.client;
2+
3+
/**
4+
* Creates a client-sided event listener.
5+
* To create your own client-sided event listener, simply extend this class (And also remember to find somewhere to use it).
6+
*/
7+
public interface MudrockClientEventListener
8+
{
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package dev.intelligentcreations.mudrock.mixin.client;
2+
3+
import dev.intelligentcreations.mudrock.event.MudrockClientEventHandler;
4+
import dev.intelligentcreations.mudrock.event.listeners.client.InGameHudAdder;
5+
import net.minecraft.client.gui.hud.InGameHud;
6+
import net.minecraft.client.util.math.MatrixStack;
7+
import org.spongepowered.asm.mixin.Mixin;
8+
import org.spongepowered.asm.mixin.injection.At;
9+
import org.spongepowered.asm.mixin.injection.Inject;
10+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
11+
12+
@Mixin(InGameHud.class)
13+
public class InGameHudMixin {
14+
@Inject(method = "render", at = @At("RETURN"))
15+
public void onRender(MatrixStack matrices, float tickDelta, CallbackInfo ci)
16+
{
17+
if (!MudrockClientEventHandler.getListeners().isEmpty())
18+
{
19+
for (int i = 0; i < MudrockClientEventHandler.getListeners().size(); ++i)
20+
{
21+
if (MudrockClientEventHandler.getListeners().get(i) instanceof InGameHudAdder listener)
22+
{
23+
listener.onHudRender(matrices, tickDelta);
24+
}
25+
}
26+
}
27+
}
28+
}

src/main/java/dev/intelligentcreations/mudrock/registry/MudrockRegistry.java

+7
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ public class MudrockRegistry
2727
private List<Identifier> blockIdentifierList = new ArrayList<>();
2828
private List<Block> blockList = new ArrayList<>();
2929

30+
private static int loadedRegistryCount = 0;
31+
3032
public MudrockRegistry(String namespace, String name, ItemGroup group)
3133
{
3234
this.namespace = namespace;
@@ -77,10 +79,15 @@ public void build()
7779
Registry.register(Registry.BLOCK, blockIdentifierList.get(i), blockList.get(i));
7880
Registry.register(Registry.ITEM, blockIdentifierList.get(i), new BlockItem(blockList.get(i), new FabricItemSettings().group(group)));
7981
}
82+
loadedRegistryCount = loadedRegistryCount + 1;
8083
// Refresh the lists
8184
this.itemIdentifierList = new ArrayList<>();
8285
this.itemList = new ArrayList<>();
8386
this.blockIdentifierList = new ArrayList<>();
8487
this.blockList = new ArrayList<>();
8588
}
89+
90+
public static int getLoadedRegistryCount() {
91+
return loadedRegistryCount;
92+
}
8693
}

src/main/resources/fabric.mod.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,17 @@
1313
"entrypoints": {
1414
"main": [
1515
"dev.intelligentcreations.mudrock.Mudrock"
16+
],
17+
"client": [
18+
"dev.intelligentcreations.mudrock.MudrockClient"
1619
]
1720
},
1821
"mixins": [
1922
"mudrock.mixins.json"
2023
],
2124
"depends": {
2225
"java": ">=17",
23-
"minecraft": "1.18.x",
26+
"minecraft": ">=1.18.2",
2427
"fabricloader": ">=0.11.3",
2528
"fabric": "*"
2629
},

src/main/resources/mudrock.mixins.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
"ItemStackMixin"
99
],
1010
"server": [],
11-
"client": [],
11+
"client": [
12+
"client.InGameHudMixin"
13+
],
1214
"injectors": {
1315
"defaultRequire": 1
1416
}

0 commit comments

Comments
 (0)