More Utility Classes
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
package me.hypherionmc.craterlib.platform;
|
||||
|
||||
import me.hypherionmc.craterlib.CraterConstants;
|
||||
import me.hypherionmc.craterlib.platform.services.IPlatformHelper;
|
||||
import me.hypherionmc.craterlib.platform.services.LibClientHelper;
|
||||
|
||||
import java.util.ServiceLoader;
|
||||
|
||||
public class Services {
|
||||
|
||||
//public static final IPlatformHelper PLATFORM = load(IPlatformHelper.class);
|
||||
public static final IPlatformHelper PLATFORM = load(IPlatformHelper.class);
|
||||
|
||||
public static final LibClientHelper CLIENT_HELPER = load(LibClientHelper.class);
|
||||
|
||||
|
@@ -5,6 +5,8 @@ import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.item.DyeColor;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
public class RenderUtils {
|
||||
|
||||
public static Vector4f colorIntToRGBA(int color) {
|
||||
@@ -56,4 +58,9 @@ public class RenderUtils {
|
||||
public static int renderColorFromDye(DyeColor color) {
|
||||
return color.getMaterialColor().col | 0xFF000000;
|
||||
}
|
||||
|
||||
public static int alphaColorFromDye(DyeColor color, float alpha) {
|
||||
float[] colors = color.getTextureDiffuseColors();
|
||||
return new Color(colors[0], colors[1], colors[2], alpha).getRGB();
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,26 @@
|
||||
package me.hypherionmc.craterlib.common;
|
||||
|
||||
import me.hypherionmc.craterlib.platform.services.IPlatformHelper;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
* @date 07/08/2022
|
||||
*/
|
||||
public class FabricPlatformHelper implements IPlatformHelper {
|
||||
|
||||
@Override
|
||||
public String getPlatformName() {
|
||||
return "Fabric";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModLoaded(String modId) {
|
||||
return FabricLoader.getInstance().isModLoaded(modId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDevelopmentEnvironment() {
|
||||
return FabricLoader.getInstance().isDevelopmentEnvironment();
|
||||
}
|
||||
}
|
@@ -0,0 +1 @@
|
||||
me.hypherionmc.craterlib.common.FabricPlatformHelper
|
@@ -0,0 +1,27 @@
|
||||
package me.hypherionmc.craterlib.common;
|
||||
|
||||
import me.hypherionmc.craterlib.platform.services.IPlatformHelper;
|
||||
import net.minecraftforge.fml.ModList;
|
||||
import net.minecraftforge.fml.loading.FMLLoader;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
* @date 07/08/2022
|
||||
*/
|
||||
public class ForgePlatformHelper implements IPlatformHelper {
|
||||
|
||||
@Override
|
||||
public String getPlatformName() {
|
||||
return "Forge";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModLoaded(String modId) {
|
||||
return ModList.get().isLoaded(modId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDevelopmentEnvironment() {
|
||||
return !FMLLoader.isProduction();
|
||||
}
|
||||
}
|
@@ -0,0 +1 @@
|
||||
me.hypherionmc.craterlib.common.ForgePlatformHelper
|
@@ -1,7 +1,7 @@
|
||||
# Project
|
||||
version_major=1
|
||||
version_minor=0
|
||||
version_patch=10d
|
||||
version_patch=11d
|
||||
group=me.hypherionmc.craterlib
|
||||
|
||||
# Common
|
||||
|
Reference in New Issue
Block a user