mirror of
https://github.com/wisplite/crystalline-sky.git
synced 2026-10-30 13:32:18 -05:00
Multiloader III
start loader-specific mod classes
This commit is contained in:
@@ -1,18 +1,16 @@
|
|||||||
package io.github.slimeistdev.crystalline_sky;
|
package io.github.slimeistdev.crystalline_sky;
|
||||||
|
|
||||||
import net.fabricmc.api.ModInitializer;
|
|
||||||
import net.minecraft.core.Registry;
|
import net.minecraft.core.Registry;
|
||||||
import net.minecraft.resources.ResourceKey;
|
import net.minecraft.resources.ResourceKey;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
public class CrystallineSky implements ModInitializer {
|
public class CrystallineSky {
|
||||||
public static final String ID = "crystalline_sky";
|
public static final String ID = "crystalline_sky";
|
||||||
public static final Logger LOG = LoggerFactory.getLogger(ID);
|
public static final Logger LOG = LoggerFactory.getLogger(ID);
|
||||||
|
|
||||||
@Override
|
public static void init() {
|
||||||
public void onInitialize() {
|
|
||||||
ModSetup.init();
|
ModSetup.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+10
-9
@@ -1,28 +1,29 @@
|
|||||||
package io.github.slimeistdev.crystalline_sky;
|
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.mixin_ducks.client.DebugRenderer_Duck;
|
||||||
import io.github.slimeistdev.crystalline_sky.registry.CrystallineBlocks;
|
import io.github.slimeistdev.crystalline_sky.registry.CrystallineBlocks;
|
||||||
import io.github.slimeistdev.crystalline_sky.registry.CrystallineItems;
|
import io.github.slimeistdev.crystalline_sky.registry.CrystallineItems;
|
||||||
import io.github.slimeistdev.crystalline_sky.registry.client.CrystallineRenderTypes;
|
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.blockrenderlayer.v1.BlockRenderLayerMap;
|
||||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
|
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
|
||||||
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
|
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
|
||||||
import net.minecraft.world.level.block.LightBlock;
|
import net.minecraft.ChatFormatting;
|
||||||
import net.minecraft.client.renderer.item.ItemProperties;
|
|
||||||
import net.minecraft.client.KeyMapping;
|
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.core.component.DataComponents;
|
||||||
import net.minecraft.world.item.component.BlockItemStateProperties;
|
|
||||||
import net.minecraft.network.chat.CommonComponents;
|
import net.minecraft.network.chat.CommonComponents;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.ChatFormatting;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import net.minecraft.world.item.component.BlockItemStateProperties;
|
||||||
|
import net.minecraft.world.level.block.LightBlock;
|
||||||
import org.lwjgl.glfw.GLFW;
|
import org.lwjgl.glfw.GLFW;
|
||||||
|
|
||||||
public class CrystallineSkyClient implements ClientModInitializer {
|
@Environment(EnvType.CLIENT)
|
||||||
@Override
|
public class CrystallineSkyClient {
|
||||||
public void onInitializeClient() {
|
public static void init() {
|
||||||
BlockRenderLayerMap.INSTANCE.putBlock(CrystallineBlocks.SKY, CrystallineRenderTypes.SKY);
|
BlockRenderLayerMap.INSTANCE.putBlock(CrystallineBlocks.SKY, CrystallineRenderTypes.SKY);
|
||||||
BlockRenderLayerMap.INSTANCE.putBlock(CrystallineBlocks.WEEPING_SKY, CrystallineRenderTypes.SKY);
|
BlockRenderLayerMap.INSTANCE.putBlock(CrystallineBlocks.WEEPING_SKY, CrystallineRenderTypes.SKY);
|
||||||
|
|
||||||
|
|||||||
+33
@@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
+14
@@ -0,0 +1,14 @@
|
|||||||
|
package io.github.slimeistdev.crystalline_sky.fabric;
|
||||||
|
|
||||||
|
import io.github.slimeistdev.crystalline_sky.CrystallineSkyClient;
|
||||||
|
import net.fabricmc.api.ClientModInitializer;
|
||||||
|
import net.fabricmc.api.EnvType;
|
||||||
|
import net.fabricmc.api.Environment;
|
||||||
|
|
||||||
|
@Environment(EnvType.CLIENT)
|
||||||
|
public class CrystallineSkyClientImpl implements ClientModInitializer {
|
||||||
|
@Override
|
||||||
|
public void onInitializeClient() {
|
||||||
|
CrystallineSkyClient.init();
|
||||||
|
}
|
||||||
|
}
|
||||||
+12
@@ -0,0 +1,12 @@
|
|||||||
|
package io.github.slimeistdev.crystalline_sky.fabric;
|
||||||
|
|
||||||
|
import io.github.slimeistdev.crystalline_sky.CrystallineSky;
|
||||||
|
import net.fabricmc.api.ModInitializer;
|
||||||
|
|
||||||
|
public class CrystallineSkyImpl implements ModInitializer {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onInitialize() {
|
||||||
|
CrystallineSky.init();
|
||||||
|
}
|
||||||
|
}
|
||||||
+15
@@ -0,0 +1,15 @@
|
|||||||
|
package io.github.slimeistdev.crystalline_sky.multiloader.fabric;
|
||||||
|
|
||||||
|
import io.github.slimeistdev.crystalline_sky.annotation.multiloader.ImplClass;
|
||||||
|
import io.github.slimeistdev.crystalline_sky.multiloader.Env;
|
||||||
|
import net.fabricmc.api.EnvType;
|
||||||
|
import net.fabricmc.loader.api.FabricLoader;
|
||||||
|
import org.jetbrains.annotations.ApiStatus.Internal;
|
||||||
|
|
||||||
|
@ImplClass
|
||||||
|
public class EnvImpl {
|
||||||
|
@Internal
|
||||||
|
public static Env getCurrent() {
|
||||||
|
return FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT ? Env.CLIENT : Env.SERVER;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"required": true,
|
||||||
|
"minVersion": "0.8",
|
||||||
|
"mixinextras": {
|
||||||
|
"minVersion": "0.5.0"
|
||||||
|
},
|
||||||
|
"package": "io.github.slimeistdev.crystalline_sky.fabric.mixin",
|
||||||
|
"plugin": "io.github.slimeistdev.crystalline_sky.mixin.CrystallineSkyMixinPlugin",
|
||||||
|
"compatibilityLevel": "JAVA_21",
|
||||||
|
"mixins": [
|
||||||
|
],
|
||||||
|
"client": [
|
||||||
|
],
|
||||||
|
"server": [
|
||||||
|
],
|
||||||
|
"injectors": {
|
||||||
|
"defaultRequire": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
+4
-3
@@ -18,7 +18,8 @@
|
|||||||
"license": "${license}",
|
"license": "${license}",
|
||||||
"icon": "assets/${modId}/icon.png",
|
"icon": "assets/${modId}/icon.png",
|
||||||
"mixins": [
|
"mixins": [
|
||||||
"${modId}.mixins.json"
|
"${modId}.mixins.json",
|
||||||
|
"${modId}-common.mixins.json"
|
||||||
],
|
],
|
||||||
"depends": {
|
"depends": {
|
||||||
"minecraft": ">=${mc}",
|
"minecraft": ">=${mc}",
|
||||||
@@ -29,10 +30,10 @@
|
|||||||
},
|
},
|
||||||
"entrypoints": {
|
"entrypoints": {
|
||||||
"main": [
|
"main": [
|
||||||
"io.github.slimeistdev.crystalline_sky.CrystallineSky"
|
"io.github.slimeistdev.crystalline_sky.fabric.CrystallineSkyImpl"
|
||||||
],
|
],
|
||||||
"client": [
|
"client": [
|
||||||
"io.github.slimeistdev.crystalline_sky.CrystallineSkyClient"
|
"io.github.slimeistdev.crystalline_sky.fabric.CrystallineSkyClientImpl"
|
||||||
],
|
],
|
||||||
"fabric-datagen": [
|
"fabric-datagen": [
|
||||||
"io.github.slimeistdev.crystalline_sky.datagen.CrystallineSkyDataGenerator"
|
"io.github.slimeistdev.crystalline_sky.datagen.CrystallineSkyDataGenerator"
|
||||||
+15
@@ -0,0 +1,15 @@
|
|||||||
|
package io.github.slimeistdev.crystalline_sky.multiloader.neoforge;
|
||||||
|
|
||||||
|
import io.github.slimeistdev.crystalline_sky.annotation.multiloader.ImplClass;
|
||||||
|
import io.github.slimeistdev.crystalline_sky.multiloader.Env;
|
||||||
|
import net.neoforged.api.distmarker.Dist;
|
||||||
|
import net.neoforged.fml.loading.FMLEnvironment;
|
||||||
|
import org.jetbrains.annotations.ApiStatus.Internal;
|
||||||
|
|
||||||
|
@ImplClass
|
||||||
|
public class EnvImpl {
|
||||||
|
@Internal
|
||||||
|
public static Env getCurrent() {
|
||||||
|
return FMLEnvironment.dist == Dist.CLIENT ? Env.CLIENT : Env.SERVER;
|
||||||
|
}
|
||||||
|
}
|
||||||
+9
@@ -0,0 +1,9 @@
|
|||||||
|
package io.github.slimeistdev.crystalline_sky.neoforge;
|
||||||
|
|
||||||
|
import io.github.slimeistdev.crystalline_sky.CrystallineSkyClient;
|
||||||
|
|
||||||
|
public class CrystallineSkyClientImpl {
|
||||||
|
public static void init() {
|
||||||
|
CrystallineSkyClient.init();
|
||||||
|
}
|
||||||
|
}
|
||||||
+14
@@ -0,0 +1,14 @@
|
|||||||
|
package io.github.slimeistdev.crystalline_sky.neoforge;
|
||||||
|
|
||||||
|
import io.github.slimeistdev.crystalline_sky.CrystallineSky;
|
||||||
|
import io.github.slimeistdev.crystalline_sky.multiloader.Env;
|
||||||
|
import net.neoforged.fml.common.Mod;
|
||||||
|
|
||||||
|
@Mod(CrystallineSky.ID)
|
||||||
|
public class CrystallineSkyImpl {
|
||||||
|
public CrystallineSkyImpl() {
|
||||||
|
CrystallineSky.init();
|
||||||
|
//noinspection Convert2MethodRef
|
||||||
|
Env.CLIENT.runIfCurrent(() -> () -> CrystallineSkyClientImpl.init());
|
||||||
|
}
|
||||||
|
}
|
||||||
+2
-16
@@ -12,18 +12,11 @@ authors = "${members}"
|
|||||||
displayURL = "${homepage}"
|
displayURL = "${homepage}"
|
||||||
logoFile = "assets/${modId}/icon.png"
|
logoFile = "assets/${modId}/icon.png"
|
||||||
|
|
||||||
[[mixins]]
|
|
||||||
config="${modId}-common.mixins.json"
|
|
||||||
|
|
||||||
[[mixins]]
|
[[mixins]]
|
||||||
config="${modId}.mixins.json"
|
config="${modId}.mixins.json"
|
||||||
|
|
||||||
[[dependencies."${ modId }"]]
|
[[mixins]]
|
||||||
modId = "connector"
|
config="${modId}-common.mixins.json"
|
||||||
type = "required"
|
|
||||||
versionRange = "*"
|
|
||||||
ordering = "NONE"
|
|
||||||
side = "BOTH"
|
|
||||||
|
|
||||||
[[dependencies."${ modId }"]]
|
[[dependencies."${ modId }"]]
|
||||||
modId = "neoforge"
|
modId = "neoforge"
|
||||||
@@ -38,10 +31,3 @@ type = "required"
|
|||||||
versionRange = "[${mc},)"
|
versionRange = "[${mc},)"
|
||||||
ordering = "NONE"
|
ordering = "NONE"
|
||||||
side = "BOTH"
|
side = "BOTH"
|
||||||
|
|
||||||
[[dependencies."${ modId }"]]
|
|
||||||
modId = "fabric_api"
|
|
||||||
type = "required"
|
|
||||||
versionRange = "[${fapi},)"
|
|
||||||
ordering = "NONE"
|
|
||||||
side = "BOTH"
|
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"required": true,
|
||||||
|
"minVersion": "0.8",
|
||||||
|
"mixinextras": {
|
||||||
|
"minVersion": "0.5.0"
|
||||||
|
},
|
||||||
|
"package": "io.github.slimeistdev.crystalline_sky.neoforge.mixin",
|
||||||
|
"plugin": "io.github.slimeistdev.crystalline_sky.mixin.CrystallineSkyMixinPlugin",
|
||||||
|
"compatibilityLevel": "JAVA_21",
|
||||||
|
"mixins": [
|
||||||
|
],
|
||||||
|
"client": [
|
||||||
|
],
|
||||||
|
"server": [
|
||||||
|
],
|
||||||
|
"injectors": {
|
||||||
|
"defaultRequire": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user