[CHORE] Cleanup API's that's unused by any mod currently

This commit is contained in:
2024-01-01 21:42:14 +02:00
parent 8aa8c3b62c
commit 8b4172cfef
125 changed files with 194 additions and 3355 deletions

View File

@@ -1,22 +0,0 @@
package com.hypherionmc.craterlib.util;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import java.util.function.ToIntFunction;
/**
* @author HypherionSA
* Helper class to create light levels from BlockState values
*/
public class BlockStateUtils {
public static ToIntFunction<BlockState> lightLevelFromLitBlockState(int litLevel) {
return state -> state.getValue(BlockStateProperties.LIT) ? litLevel : 0;
}
public static ToIntFunction<BlockState> lightLevelFromPoweredBlockState(int litLevel) {
return state -> state.getValue(BlockStateProperties.POWERED) ? litLevel : 0;
}
}

View File

@@ -1,34 +0,0 @@
package com.hypherionmc.craterlib.util;
import com.hypherionmc.craterlib.common.item.BlockItemDyable;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.renderer.item.ClampedItemPropertyFunction;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.DyeColor;
import net.minecraft.world.item.ItemStack;
import org.jetbrains.annotations.Nullable;
/**
* @author HypherionSA
*/
public class ColorPropertyFunction implements ClampedItemPropertyFunction {
private final BlockItemDyable item;
public ColorPropertyFunction(BlockItemDyable item) {
this.item = item;
}
@Override
public float call(ItemStack itemStack, @Nullable ClientLevel clientLevel, @Nullable LivingEntity livingEntity, int i) {
return Mth.clamp(this.unclampedCall(itemStack, clientLevel, livingEntity, i), 0.0F, 15.0F);
}
@Override
public float unclampedCall(ItemStack itemStack, @Nullable ClientLevel clientLevel, @Nullable LivingEntity livingEntity, int i) {
DyeColor color = item.getColorFromNBT(itemStack);
return color.getId();
}
}

View File

@@ -1,31 +0,0 @@
package com.hypherionmc.craterlib.util;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.DyeColor;
import net.minecraft.world.level.material.Fluid;
import net.minecraft.world.level.material.Fluids;
/**
* @author HypherionSA
* Utility class for interacting with fluids across modloaders
*/
public class FluidUtils {
public static int fluidColorFromDye(DyeColor color) {
return color.getMapColor().col | 0xFF000000;
}
public static void putFluid(CompoundTag compound, String key, Fluid fluidVariant) {
compound.putString("tankFluid", BuiltInRegistries.FLUID.getKey(fluidVariant).toString());
}
public static Fluid getFluidCompatible(CompoundTag tag) {
if (tag == null || !tag.contains("tankFluid"))
return Fluids.EMPTY;
return BuiltInRegistries.FLUID.get(new ResourceLocation(tag.getString("tankFluid")));
}
}

View File

@@ -41,6 +41,15 @@ public class RenderUtils {
}
}
public static int renderColorFromDye(DyeColor color) {
return color.getMapColor().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();
}
public static class ARGB32 {
public static int alpha(int pPackedColor) {
return pPackedColor >>> 24;
@@ -58,13 +67,4 @@ public class RenderUtils {
return pPackedColor & 255;
}
}
public static int renderColorFromDye(DyeColor color) {
return color.getMapColor().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();
}
}

View File

@@ -12,6 +12,7 @@ public class ServiceUtil {
/**
* Try to load a service
*
* @param clazz The service class type to load
* @return The loaded class
*/