
ColorableLib
SuperbWarfare车辆着色简易库。
查看大图用于轻松实现SuperbWarfare载具涂装的库。
ColorableLib是一个专为SuperbWarfare扩展包设计的轻量级库。ColorableLib基于Capability逻辑实现,并实现了管理引擎与自动的服务端-客户端同步,同时也能够修改SuperbWarfare载具的渲染器。
import colorable.capability.EntityColorCapability;
import net.minecraft.world.entity.Entity;
/**
* ColorableLib API使用示例。
*/
public class ColorableExample {
/**
* 演示如何操作实体涂装层。
*
* @param targetEntity 要涂装的实体(必须支持该Capability)。
* @param color 颜色,十进制或十六进制格式(如0xFF0000表示红色)。
*/
public void exampleMethod(Entity targetEntity, int color) {
// 获取目标实体的涂装Capability
targetEntity.getCapability(EntityColorCapability.CAPABILITY).ifPresent(cap -> {
if (!targetEntity.level().isClientSide) {
// 添加或更新指定的涂装层
cap.setLayer(targetEntity, "example_id", color);
// 移除指定的涂装层
cap.removeLayer(targetEntity, "example_id");
}
});
}
}
还没有人评论,去客户端里说两句吧。
评论在新手盒子客户端中发表,这里同步展示。