[CHORE] Cleanup API's that's unused by any mod currently
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
}
|
@@ -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();
|
||||
}
|
||||
|
||||
}
|
@@ -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")));
|
||||
}
|
||||
|
||||
}
|
@@ -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();
|
||||
}
|
||||
}
|
||||
|
@@ -12,6 +12,7 @@ public class ServiceUtil {
|
||||
|
||||
/**
|
||||
* Try to load a service
|
||||
*
|
||||
* @param clazz The service class type to load
|
||||
* @return The loaded class
|
||||
*/
|
||||
|
Reference in New Issue
Block a user