Multiloader III

start loader-specific mod classes
This commit is contained in:
techno-sam
2026-04-05 21:28:29 +02:00
parent 581a236a6b
commit 7c20d34844
15 changed files with 220 additions and 32 deletions
@@ -1,18 +1,16 @@
package io.github.slimeistdev.crystalline_sky;
import net.fabricmc.api.ModInitializer;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class CrystallineSky implements ModInitializer {
public class CrystallineSky {
public static final String ID = "crystalline_sky";
public static final Logger LOG = LoggerFactory.getLogger(ID);
@Override
public void onInitialize() {
public static void init() {
ModSetup.init();
}
@@ -1,28 +1,29 @@
package io.github.slimeistdev.crystalline_sky;
import com.mojang.blaze3d.platform.InputConstants;
import io.github.slimeistdev.crystalline_sky.mixin_ducks.client.DebugRenderer_Duck;
import io.github.slimeistdev.crystalline_sky.registry.CrystallineBlocks;
import io.github.slimeistdev.crystalline_sky.registry.CrystallineItems;
import io.github.slimeistdev.crystalline_sky.registry.client.CrystallineRenderTypes;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.minecraft.world.level.block.LightBlock;
import net.minecraft.client.renderer.item.ItemProperties;
import net.minecraft.ChatFormatting;
import net.minecraft.client.KeyMapping;
import com.mojang.blaze3d.platform.InputConstants;
import net.minecraft.client.renderer.item.ItemProperties;
import net.minecraft.core.component.DataComponents;
import net.minecraft.world.item.component.BlockItemStateProperties;
import net.minecraft.network.chat.CommonComponents;
import net.minecraft.network.chat.Component;
import net.minecraft.ChatFormatting;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.component.BlockItemStateProperties;
import net.minecraft.world.level.block.LightBlock;
import org.lwjgl.glfw.GLFW;
public class CrystallineSkyClient implements ClientModInitializer {
@Override
public void onInitializeClient() {
@Environment(EnvType.CLIENT)
public class CrystallineSkyClient {
public static void init() {
BlockRenderLayerMap.INSTANCE.putBlock(CrystallineBlocks.SKY, CrystallineRenderTypes.SKY);
BlockRenderLayerMap.INSTANCE.putBlock(CrystallineBlocks.WEEPING_SKY, CrystallineRenderTypes.SKY);
@@ -0,0 +1,33 @@
/*
* Steam 'n' Rails
* Copyright (c) 2025 The Railways Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package io.github.slimeistdev.crystalline_sky.annotation.multiloader;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Used to mark classes that are used via abstracted loader-specific methods.
* <p>
* Meant purely for documentation and does not exist at compile-time or runtime.
*/
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.SOURCE)
public @interface ImplClass { }
@@ -0,0 +1,52 @@
/*
* Steam 'n' Rails
* Copyright (c) 2022-2024 The Railways Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package io.github.slimeistdev.crystalline_sky.multiloader;
import dev.architectury.injectables.annotations.ExpectPlatform;
import org.jetbrains.annotations.ApiStatus.Internal;
import java.util.function.Supplier;
public enum Env {
CLIENT, SERVER;
public static final Env CURRENT = getCurrent();
public boolean isCurrent() {
return this == CURRENT;
}
public void runIfCurrent(Supplier<Runnable> run) {
if (isCurrent())
run.get().run();
}
public static <T> T unsafeRunForDist(Supplier<Supplier<T>> clientTarget, Supplier<Supplier<T>> serverTarget) {
return switch (Env.CURRENT) {
case CLIENT -> clientTarget.get().get();
case SERVER -> serverTarget.get().get();
};
}
@Internal
@ExpectPlatform
private static Env getCurrent() {
throw new AssertionError();
}
}
@@ -1,47 +0,0 @@
modLoader = "javafml"
loaderVersion = "[4,)"
license = "${license}"
issueTrackerURL = "${issues}"
[[mods]]
modId = "${modId}"
version = "${version}"
displayName = "${modName}"
description = '''${modDescription}'''
authors = "${members}"
displayURL = "${homepage}"
logoFile = "assets/${modId}/icon.png"
[[mixins]]
config="${modId}-common.mixins.json"
[[mixins]]
config="${modId}.mixins.json"
[[dependencies."${ modId }"]]
modId = "connector"
type = "required"
versionRange = "*"
ordering = "NONE"
side = "BOTH"
[[dependencies."${ modId }"]]
modId = "neoforge"
type = "required"
versionRange = "*"
ordering = "NONE"
side = "BOTH"
[[dependencies."${ modId }"]]
modId = "minecraft"
type = "required"
versionRange = "[${mc},)"
ordering = "NONE"
side = "BOTH"
[[dependencies."${ modId }"]]
modId = "fabric_api"
type = "required"
versionRange = "[${fapi},)"
ordering = "NONE"
side = "BOTH"
-41
View File
@@ -1,41 +0,0 @@
{
"schemaVersion": 1,
"id": "${modId}",
"version": "${version}",
"name": "${modName}",
"description": "${modDescription}",
"authors": [
"${authors}"
],
"contributors": [
"${contributors}"
],
"contact": {
"homepage": "${homepage}",
"issues": "${issues}",
"sources": "${sources}"
},
"license": "${license}",
"icon": "assets/${modId}/icon.png",
"mixins": [
"${modId}.mixins.json"
],
"depends": {
"minecraft": ">=${mc}",
"fabricloader": ">=${fl}",
"fabric-api": ">=${fapi}"
},
"suggests": {
},
"entrypoints": {
"main": [
"io.github.slimeistdev.crystalline_sky.CrystallineSky"
],
"client": [
"io.github.slimeistdev.crystalline_sky.CrystallineSkyClient"
],
"fabric-datagen": [
"io.github.slimeistdev.crystalline_sky.datagen.CrystallineSkyDataGenerator"
]
}
}