Начинающий
- Статус
- Оффлайн
- Регистрация
- 9 Дек 2022
- Сообщения
- 45
- Реакции
- 1
Перед прочтением основного контента ниже, пожалуйста, обратите внимание на обновление внутри секции Майна на нашем форуме. У нас появились:
- бесплатные читы для Майнкрафт — любое использование на свой страх и риск;
- маркетплейс Майнкрафт — абсолютно любая коммерция, связанная с игрой, за исключением продажи читов (аккаунты, предоставления услуг, поиск кодеров читов и так далее);
- приватные читы для Minecraft — в этом разделе только платные хаки для игры, покупайте группу "Продавец" и выставляйте на продажу свой софт;
- обсуждения и гайды — всё тот же раздел с вопросами, но теперь модернизированный: поиск нужных хаков, пати с игроками-читерами и другая полезная информация.
Спасибо!
Здраствуйте я делаю чит на mcp 1.21.4 недавно делал рендер и сейчас сделал фонты но в чем прикол все стоит по директории правильно но оно не находит его ниже скину все что надо для фикса либо я долбоеб либо я хз вот дефолтная ошибка при не нахождение чего либо Caused by: java.io.FileNotFoundException: luxury:fonts/sf.json
package dev.luxury.font;
import dev.luxury.font.api.Font;
import dev.luxury.font.api.msdf.MsdfFont;
import dev.luxury.utils.Client;
public class FontManager {
public Font[] CONSOLAS;
public Font[] CIRCULAR;
public Font[] BENZIN;
public Font[] TAHOMA;
public Font[] U2000;
public Font[] SFPRO;
public Font[] SFPD;
public Font[] SFUI;
public Font[] SF;
public Font[][] FONTS;
public FontManager() {
String[] paths = {
"luxury/fonts/sf",
"luxury/fonts/sfui",
"luxury/fonts/sfpd",
"luxury/fonts/sfpro",
"luxury/fonts/u2000",
"luxury/fonts/tahoma",
"luxury/fonts/benzin",
"luxury/fonts/circular",
"luxury/fonts/consolas"
};
Font[] fonts = {
new Font(MsdfFont.builder().fromPath(paths[0]).build()),
new Font(MsdfFont.builder().fromPath(paths[1]).build()),
new Font(MsdfFont.builder().fromPath(paths[2]).build()),
new Font(MsdfFont.builder().fromPath(paths[3]).build()),
new Font(MsdfFont.builder().fromPath(paths[4]).build()),
new Font(MsdfFont.builder().fromPath(paths[5]).build()),
new Font(MsdfFont.builder().fromPath(paths[6]).build()),
new Font(MsdfFont.builder().fromPath(paths[7]).build()),
new Font(MsdfFont.builder().fromPath(paths[8]).build())
};
SF = new Font[]{
fonts[0].withSize(14.f),
fonts[0].withSize(16.f),
fonts[0].withSize(18.f),
};
SFUI = new Font[]{
fonts[1].withSize(14.f),
fonts[1].withSize(16.f),
fonts[1].withSize(18.f),
};
SFPD = new Font[]{
fonts[2].withSize(14.f),
fonts[2].withSize(16.f),
fonts[2].withSize(18.f),
fonts[2].withSize(24.f),
};
SFPRO = new Font[]{
fonts[3].withSize(14.f),
fonts[3].withSize(16.f),
fonts[3].withSize(18.f),
};
U2000 = new Font[]{
fonts[4].withSize(14.f),
fonts[4].withSize(16.f),
fonts[4].withSize(18.f),
};
TAHOMA = new Font[]{
fonts[5].withSize(14.f),
fonts[5].withSize(16.f),
fonts[5].withSize(18.f),
};
BENZIN = new Font[]{
fonts[6].withSize(14.f),
fonts[6].withSize(16.f),
fonts[6].withSize(18.f),
fonts[6].withSize(24.f),
};
CIRCULAR = new Font[]{
fonts[7].withSize(14.f),
fonts[7].withSize(16.f),
fonts[7].withSize(18.f),
};
CONSOLAS = new Font[]{
fonts[8].withSize(14.f),
fonts[8].withSize(16.f),
fonts[8].withSize(18.f),
};
FONTS = new Font[][] {
CONSOLAS,
CIRCULAR,
BENZIN,
TAHOMA,
SFPRO,
SFPD,
SFUI,
SF
};
}
}
package dev.luxury.font.api.msdf;
import java.awt.*;
import java.util.HashMap;
import java.util.Map;
import java.util.stream.Collectors;
import com.mojang.blaze3d.vertex.VertexConsumer;
import dev.luxury.utils.resource.ResourceUtil;
import net.minecraft.client.renderer.texture.AbstractTexture;
import net.minecraft.resources.ResourceLocation;
import org.joml.Matrix4f;
import com.mojang.blaze3d.systems.RenderSystem;
import static dev.luxury.utils.IMinecraft.mc;
public final class MsdfFont {
private final String name;
private final AbstractTexture texture;
private final FontData.AtlasData atlas;
private final FontData.MetricsData metrics;
private final Map<Integer, MsdfGlyph> glyphs;
private final Map<Integer, Map<Integer, Float>> kernings;
private final int[] colorCode = new int[32];
private MsdfFont(String name, AbstractTexture texture, FontData.AtlasData atlas, FontData.MetricsData metrics, Map<Integer, MsdfGlyph> glyphs, Map<Integer, Map<Integer, Float>> kernings) {
this.name = name;
this.texture = texture;
this.atlas = atlas;
this.metrics = metrics;
this.glyphs = glyphs;
this.kernings = kernings;
this.setupMinecraftColorcodes();
}
public int getTextureId() {
return this.texture.getId();
}
public void applyGlyphs(Matrix4f matrix, VertexConsumer consumer, String text, float size, float thickness, float spacing, float x, float y, float z, int color) {
int prevChar = -1;
for (int i = 0; i < text.length(); i++) {
int _char = (int) text.charAt(i);
if (String.valueOf((char)_char).equals("\u00a7")) {
int colorIndex = "0123456789abcdefklmnor".indexOf(text.charAt(i + 1));
color = new Color(this.colorCode[colorIndex] >> 16 & 0xFF, this.colorCode[colorIndex] >> 8 & 0xFF, this.colorCode[colorIndex] & 0xFF, color >> 24 & 0xFF).hashCode();
i++;
continue;
}
MsdfGlyph glyph = this.glyphs.get(_char);
if (glyph == null) continue;
Map<Integer, Float> kerning = this.kernings.get(prevChar);
if (kerning != null) {
x += kerning.getOrDefault(_char, 0.0f) * size;
}
x += glyph.apply(matrix, consumer, size, x, y, z, color) + thickness + spacing;
prevChar = _char;
}
}
public float getWidth(String text, float size) {
int prevChar = -1;
float width = 0.0f;
for (int i = 0; i < text.length(); i++) {
int _char = (int) text.charAt(i);
if (String.valueOf((char)_char).equals("\u00a7")) {
i++;
continue;
}
MsdfGlyph glyph = this.glyphs.get(_char);
if (glyph == null)
continue;
Map<Integer, Float> kerning = this.kernings.get(prevChar);
if (kerning != null) {
width += kerning.getOrDefault(_char, 0.0f) * size;
}
width += glyph.getWidth(size);
prevChar = _char;
}
return width;
}
public String getName() {
return this.name;
}
public FontData.AtlasData getAtlas() {
return this.atlas;
}
public FontData.MetricsData getMetrics() {
return this.metrics;
}
public static MsdfFont.Builder builder() {
return new Builder();
}
public static class Builder {
private String name = "?";
private ResourceLocation dataIdentifer;
private ResourceLocation atlasIdentifier;
private Builder() {}
public MsdfFont.Builder name(String name) {
this.name = name;
return this;
}
public MsdfFont.Builder fromPath(String path) {
this.dataIdentifer = new ResourceLocation(dev.luxury.utils.Client.NAMESPACE, "fonts/" + path.substring(path.lastIndexOf("/") + 1) + ".json");
this.atlasIdentifier = new ResourceLocation(dev.luxury.utils.Client.NAMESPACE, "fonts/" + path.substring(path.lastIndexOf("/") + 1) + ".png");
return this;
}
public MsdfFont.Builder data(String dataFileName) {
this.dataIdentifer = ResourceLocation.withDefaultNamespace(dataFileName + ".json");
return this;
}
public MsdfFont.Builder atlas(String atlasFileName) {
this.atlasIdentifier = ResourceLocation.withDefaultNamespace(atlasFileName + ".png");
return this;
}
public MsdfFont build() {
FontData data = ResourceUtil.fromJsonToInstance(this.dataIdentifer, FontData.class);
AbstractTexture texture = mc.getTextureManager().getTexture(this.atlasIdentifier);
if (data == null) {
throw new RuntimeException("Failed to read font data file: " + this.dataIdentifer.toString() +
"; Are you sure this is json file? Try to check the correctness of its syntax.");
}
RenderSystem.recordRenderCall(() -> texture.setFilter(true, false));
float aWidth = data.atlas().width();
float aHeight = data.atlas().height();
Map<Integer, MsdfGlyph> glyphs = data.glyphs().stream()
.collect(Collectors.<FontData.GlyphData, Integer, MsdfGlyph>toMap(
(glyphData) -> glyphData.unicode(),
(glyphData) -> new MsdfGlyph(glyphData, aWidth, aHeight)
));
Map<Integer, Map<Integer, Float>> kernings = new HashMap<>();
data.kernings().forEach((kerning) -> {
Map<Integer, Float> map = kernings.get(kerning.leftChar());
if (map == null) {
map = new HashMap<>();
kernings.put(kerning.leftChar(), map);
}
map.put(kerning.rightChar(), kerning.advance());
});
return new MsdfFont(this.name, texture, data.atlas(), data.metrics(), glyphs, kernings);
}
}
private void setupMinecraftColorcodes() {
for (int index = 0; index < 32; ++index) {
int noClue = (index >> 3 & 1) * 85;
int red = (index >> 2 & 1) * 170 + noClue;
int green = (index >> 1 & 1) * 170 + noClue;
int blue = (index >> 0 & 1) * 170 + noClue;
if (index == 6)
red += 85;
if (index >= 16) {
red /= 4;
green /= 4;
blue /= 4;
}
this.colorCode[index] = (red & 0xFF) << 16 | (green & 0xFF) << 8 | blue & 0xFF;
}
}
}
package dev.luxury.font;
import dev.luxury.font.api.Font;
import dev.luxury.font.api.msdf.MsdfFont;
import dev.luxury.utils.Client;
public class FontManager {
public Font[] CONSOLAS;
public Font[] CIRCULAR;
public Font[] BENZIN;
public Font[] TAHOMA;
public Font[] U2000;
public Font[] SFPRO;
public Font[] SFPD;
public Font[] SFUI;
public Font[] SF;
public Font[][] FONTS;
public FontManager() {
String[] paths = {
"luxury/fonts/sf",
"luxury/fonts/sfui",
"luxury/fonts/sfpd",
"luxury/fonts/sfpro",
"luxury/fonts/u2000",
"luxury/fonts/tahoma",
"luxury/fonts/benzin",
"luxury/fonts/circular",
"luxury/fonts/consolas"
};
Font[] fonts = {
new Font(MsdfFont.builder().fromPath(paths[0]).build()),
new Font(MsdfFont.builder().fromPath(paths[1]).build()),
new Font(MsdfFont.builder().fromPath(paths[2]).build()),
new Font(MsdfFont.builder().fromPath(paths[3]).build()),
new Font(MsdfFont.builder().fromPath(paths[4]).build()),
new Font(MsdfFont.builder().fromPath(paths[5]).build()),
new Font(MsdfFont.builder().fromPath(paths[6]).build()),
new Font(MsdfFont.builder().fromPath(paths[7]).build()),
new Font(MsdfFont.builder().fromPath(paths[8]).build())
};
SF = new Font[]{
fonts[0].withSize(14.f),
fonts[0].withSize(16.f),
fonts[0].withSize(18.f),
};
SFUI = new Font[]{
fonts[1].withSize(14.f),
fonts[1].withSize(16.f),
fonts[1].withSize(18.f),
};
SFPD = new Font[]{
fonts[2].withSize(14.f),
fonts[2].withSize(16.f),
fonts[2].withSize(18.f),
fonts[2].withSize(24.f),
};
SFPRO = new Font[]{
fonts[3].withSize(14.f),
fonts[3].withSize(16.f),
fonts[3].withSize(18.f),
};
U2000 = new Font[]{
fonts[4].withSize(14.f),
fonts[4].withSize(16.f),
fonts[4].withSize(18.f),
};
TAHOMA = new Font[]{
fonts[5].withSize(14.f),
fonts[5].withSize(16.f),
fonts[5].withSize(18.f),
};
BENZIN = new Font[]{
fonts[6].withSize(14.f),
fonts[6].withSize(16.f),
fonts[6].withSize(18.f),
fonts[6].withSize(24.f),
};
CIRCULAR = new Font[]{
fonts[7].withSize(14.f),
fonts[7].withSize(16.f),
fonts[7].withSize(18.f),
};
CONSOLAS = new Font[]{
fonts[8].withSize(14.f),
fonts[8].withSize(16.f),
fonts[8].withSize(18.f),
};
FONTS = new Font[][] {
CONSOLAS,
CIRCULAR,
BENZIN,
TAHOMA,
SFPRO,
SFPD,
SFUI,
SF
};
}
}
package dev.luxury.font.api.msdf;
import java.awt.*;
import java.util.HashMap;
import java.util.Map;
import java.util.stream.Collectors;
import com.mojang.blaze3d.vertex.VertexConsumer;
import dev.luxury.utils.resource.ResourceUtil;
import net.minecraft.client.renderer.texture.AbstractTexture;
import net.minecraft.resources.ResourceLocation;
import org.joml.Matrix4f;
import com.mojang.blaze3d.systems.RenderSystem;
import static dev.luxury.utils.IMinecraft.mc;
public final class MsdfFont {
private final String name;
private final AbstractTexture texture;
private final FontData.AtlasData atlas;
private final FontData.MetricsData metrics;
private final Map<Integer, MsdfGlyph> glyphs;
private final Map<Integer, Map<Integer, Float>> kernings;
private final int[] colorCode = new int[32];
private MsdfFont(String name, AbstractTexture texture, FontData.AtlasData atlas, FontData.MetricsData metrics, Map<Integer, MsdfGlyph> glyphs, Map<Integer, Map<Integer, Float>> kernings) {
this.name = name;
this.texture = texture;
this.atlas = atlas;
this.metrics = metrics;
this.glyphs = glyphs;
this.kernings = kernings;
this.setupMinecraftColorcodes();
}
public int getTextureId() {
return this.texture.getId();
}
public void applyGlyphs(Matrix4f matrix, VertexConsumer consumer, String text, float size, float thickness, float spacing, float x, float y, float z, int color) {
int prevChar = -1;
for (int i = 0; i < text.length(); i++) {
int _char = (int) text.charAt(i);
if (String.valueOf((char)_char).equals("\u00a7")) {
int colorIndex = "0123456789abcdefklmnor".indexOf(text.charAt(i + 1));
color = new Color(this.colorCode[colorIndex] >> 16 & 0xFF, this.colorCode[colorIndex] >> 8 & 0xFF, this.colorCode[colorIndex] & 0xFF, color >> 24 & 0xFF).hashCode();
i++;
continue;
}
MsdfGlyph glyph = this.glyphs.get(_char);
if (glyph == null) continue;
Map<Integer, Float> kerning = this.kernings.get(prevChar);
if (kerning != null) {
x += kerning.getOrDefault(_char, 0.0f) * size;
}
x += glyph.apply(matrix, consumer, size, x, y, z, color) + thickness + spacing;
prevChar = _char;
}
}
public float getWidth(String text, float size) {
int prevChar = -1;
float width = 0.0f;
for (int i = 0; i < text.length(); i++) {
int _char = (int) text.charAt(i);
if (String.valueOf((char)_char).equals("\u00a7")) {
i++;
continue;
}
MsdfGlyph glyph = this.glyphs.get(_char);
if (glyph == null)
continue;
Map<Integer, Float> kerning = this.kernings.get(prevChar);
if (kerning != null) {
width += kerning.getOrDefault(_char, 0.0f) * size;
}
width += glyph.getWidth(size);
prevChar = _char;
}
return width;
}
public String getName() {
return this.name;
}
public FontData.AtlasData getAtlas() {
return this.atlas;
}
public FontData.MetricsData getMetrics() {
return this.metrics;
}
public static MsdfFont.Builder builder() {
return new Builder();
}
public static class Builder {
private String name = "?";
private ResourceLocation dataIdentifer;
private ResourceLocation atlasIdentifier;
private Builder() {}
public MsdfFont.Builder name(String name) {
this.name = name;
return this;
}
public MsdfFont.Builder fromPath(String path) {
this.dataIdentifer = new ResourceLocation(dev.luxury.utils.Client.NAMESPACE, "fonts/" + path.substring(path.lastIndexOf("/") + 1) + ".json");
this.atlasIdentifier = new ResourceLocation(dev.luxury.utils.Client.NAMESPACE, "fonts/" + path.substring(path.lastIndexOf("/") + 1) + ".png");
return this;
}
public MsdfFont.Builder data(String dataFileName) {
this.dataIdentifer = ResourceLocation.withDefaultNamespace(dataFileName + ".json");
return this;
}
public MsdfFont.Builder atlas(String atlasFileName) {
this.atlasIdentifier = ResourceLocation.withDefaultNamespace(atlasFileName + ".png");
return this;
}
public MsdfFont build() {
FontData data = ResourceUtil.fromJsonToInstance(this.dataIdentifer, FontData.class);
AbstractTexture texture = mc.getTextureManager().getTexture(this.atlasIdentifier);
if (data == null) {
throw new RuntimeException("Failed to read font data file: " + this.dataIdentifer.toString() +
"; Are you sure this is json file? Try to check the correctness of its syntax.");
}
RenderSystem.recordRenderCall(() -> texture.setFilter(true, false));
float aWidth = data.atlas().width();
float aHeight = data.atlas().height();
Map<Integer, MsdfGlyph> glyphs = data.glyphs().stream()
.collect(Collectors.<FontData.GlyphData, Integer, MsdfGlyph>toMap(
(glyphData) -> glyphData.unicode(),
(glyphData) -> new MsdfGlyph(glyphData, aWidth, aHeight)
));
Map<Integer, Map<Integer, Float>> kernings = new HashMap<>();
data.kernings().forEach((kerning) -> {
Map<Integer, Float> map = kernings.get(kerning.leftChar());
if (map == null) {
map = new HashMap<>();
kernings.put(kerning.leftChar(), map);
}
map.put(kerning.rightChar(), kerning.advance());
});
return new MsdfFont(this.name, texture, data.atlas(), data.metrics(), glyphs, kernings);
}
}
private void setupMinecraftColorcodes() {
for (int index = 0; index < 32; ++index) {
int noClue = (index >> 3 & 1) * 85;
int red = (index >> 2 & 1) * 170 + noClue;
int green = (index >> 1 & 1) * 170 + noClue;
int blue = (index >> 0 & 1) * 170 + noClue;
if (index == 6)
red += 85;
if (index >= 16) {
red /= 4;
green /= 4;
blue /= 4;
}
this.colorCode[index] = (red & 0xFF) << 16 | (green & 0xFF) << 8 | blue & 0xFF;
}
}
}