9
0
mirror of https://github.com/Xiao-MoMi/Custom-Nameplates.git synced 2025-12-30 20:29:07 +00:00
This commit is contained in:
XiaoMoMi
2023-07-09 03:55:07 +08:00
parent b49c859fa3
commit 5dd53236a3
5 changed files with 96 additions and 45 deletions

View File

@@ -55,6 +55,8 @@ public class ConfigManager extends Function {
public static boolean enableImages;
public static int default_width;
public static boolean enable1_20_Unicode;
public static boolean hideScoreboardNumber;
public static boolean iaShaderSupport;
@Override
public void load(){
@@ -95,6 +97,8 @@ public class ConfigManager extends Function {
extractShader = section.getBoolean("extract-shader",true);
extractBars = section.getBoolean("extract-bar-image",true);
enable1_20_Unicode = section.getBoolean("support-1_20-unicodes",false);
hideScoreboardNumber = section.getBoolean("hide-scoreboard-number",true);
iaShaderSupport = section.getBoolean("ItemsAdder-text-effect-support",true);
}
}

View File

@@ -169,6 +169,75 @@ public class ResourceManager {
plugin.saveResource(path + "rendertype_text.fsh", true);
plugin.saveResource(path + "rendertype_text.json", true);
plugin.saveResource(path + "rendertype_text.vsh", true);
String line;
StringBuilder sb = new StringBuilder();
try (BufferedReader reader = new BufferedReader(
new InputStreamReader(
new FileInputStream(
new File(plugin.getDataFolder(), path + "rendertype_text.vsh")
), StandardCharsets.UTF_8
)
)) {
while ((line = reader.readLine()) != null) {
sb.append(line).append(System.lineSeparator());
}
} catch (IOException e) {
e.printStackTrace();
}
File outPut = new File(plugin.getDataFolder(), path + "rendertype_text.vsh");
try (BufferedWriter writer = new BufferedWriter(
new OutputStreamWriter(new FileOutputStream(outPut), StandardCharsets.UTF_8))) {
writer.write(sb.toString()
.replace("{hide}", !ConfigManager.hideScoreboardNumber ? "" : "if (Position.z == 0.0\n" +
" && gl_Position.x >= 0.94\n" +
" && gl_Position.y >= -0.35\n" +
" && vertexColor.g == 84.0/255.0\n" +
" && vertexColor.g == 84.0/255.0\n" +
" && vertexColor.r == 252.0/255.0\n" +
" && gl_VertexID <= 7\n" +
" ) {\n" +
" gl_Position = ProjMat * ModelViewMat * vec4(ScreenSize + 100.0, 0.0, ScreenSize + 100.0);\n" +
" }"
)
.replace("{IA}", !ConfigManager.iaShaderSupport ? "" : "if (Color.xyz == vec3(255., 255., 254.) / 255.) {\n" +
" gl_Position = ProjMat * ModelViewMat * vertex;\n" +
" vertexColor = ((.6 + .6 * cos(6. * (gl_Position.x + GameTime * 1000.) + vec4(0, 23, 21, 1))) + vec4(0., 0., 0., 1.)) * texelFetch(Sampler2, UV2 / 16, 0);\n" +
" } else if(Color.xyz == vec3(255., 255., 253.) / 255.) {\n" +
" gl_Position = ProjMat * ModelViewMat * vertex;\n" +
" vertexColor = Color * texelFetch(Sampler2, UV2 / 16, 0);\n" +
" gl_Position.y = gl_Position.y + sin(GameTime * 12000. + (gl_Position.x * 6)) / 150.;\n" +
" } else if (Color.xyz == vec3(255., 255., 252.) / 255.) {\n" +
" gl_Position = ProjMat * ModelViewMat * vertex;\n" +
" vertexColor = ((.6 + .6 * cos(6. * (gl_Position.x + GameTime * 1000.) + vec4(0, 23, 21, 1))) + vec4(0., 0., 0., 1.)) * texelFetch(Sampler2, UV2 / 16, 0);\n" +
" gl_Position.y = gl_Position.y + sin(GameTime*12000. + (gl_Position.x*6)) / 150.;\n" +
" } else if (Color.xyz == vec3(255., 255., 251.) / 255.) {\n" +
" vertexColor = Color * texelFetch(Sampler2, UV2 / 16, 0);\n" +
" float vertexId = mod(gl_VertexID, 4.0);\n" +
" if (vertex.z <= 0.) {\n" +
" if (vertexId == 3. || vertexId == 0.) vertex.y += cos(GameTime * 12000. / 4) * 0.1;\n" +
" vertex.y += max(cos(GameTime*12000. / 4) * 0.1, 0.);\n" +
" } else {\n" +
" if (vertexId == 3. || vertexId == 0.) vertex.y -= cos(GameTime * 12000. / 4) * 3;\n" +
" vertex.y -= max(cos(GameTime*12000. / 4) * 4, 0.);\n" +
" }\n" +
" gl_Position = ProjMat * ModelViewMat * vertex;\n" +
" } else if (Color.xyz == vec3(255., 254., 254.) / 255.) {\n" +
" float vertexId = mod(gl_VertexID, 4.0);\n" +
" if (vertex.z <= 0.) {\n" +
" if (vertexId == 3. || vertexId == 0.) vertex.y += cos(GameTime * 12000. / 4) * 0.1;\n" +
" vertex.y += max(cos(GameTime*12000. / 4) * 0.1, 0.);\n" +
" } else {\n" +
" if (vertexId == 3. || vertexId == 0.) vertex.y -= cos(GameTime * 12000. / 4) * 3;\n" +
" vertex.y -= max(cos(GameTime*12000. / 4) * 4, 0.);\n" +
" }\n" +
" vertexColor = ((.6 + .6 * cos(6. * (gl_Position.x + GameTime * 1000.) + vec4(0, 23, 21, 1))) + vec4(0., 0., 0., 1.)) * texelFetch(Sampler2, UV2 / 16, 0);\n" +
" gl_Position = ProjMat * ModelViewMat * vertex;\n" +
" }")
);
} catch (IOException e) {
e.printStackTrace();
}
}
if (ConfigManager.extractBars) {
String path = "ResourcePack" + File.separator + "assets" + File.separator + "minecraft" + File.separator + "textures" + File.separator + "gui" + File.separator;

View File

@@ -1,4 +1,6 @@
#version 150
#moj_import <fog.glsl>
in vec3 Position;
in vec4 Color;
in vec2 UV0;
@@ -7,56 +9,28 @@ in ivec2 UV2;
uniform sampler2D Sampler0,Sampler2;
uniform mat4 ModelViewMat;
uniform mat4 ProjMat;
uniform mat3 IViewRotMat;
uniform float GameTime;
uniform int FogShape;
uniform vec2 ScreenSize;
out float vertexDistance;
flat out vec4 vertexColor;
out vec2 texCoord0;
void main(){
vec4 vertex=vec4(Position, 1.0);
if(Color.xyz==vec3(255., 255., 254.)/ 255.){
(gl_Position=ProjMat*ModelViewMat*vertex);
(vertexColor=((.6+.6*cos(6.*(gl_Position.x+GameTime*1000.)+vec4(0, 23, 21, 1)))+vec4(0., 0., 0., 1.))*texelFetch(Sampler2, UV2 / 16, 0));
}else if(Color.xyz==vec3(255., 255., 253.)/ 255.){
(gl_Position=ProjMat*ModelViewMat*vertex);
(vertexColor=Color*texelFetch(Sampler2, UV2 / 16, 0));
(gl_Position.y=gl_Position.y+sin(GameTime*12000.+(gl_Position.x*6))/ 150.);
}else if(Color.xyz==vec3(255., 255., 252.)/ 255.){
(gl_Position=ProjMat*ModelViewMat*vertex);
(vertexColor=((.6+.6*cos(6.*(gl_Position.x+GameTime*1000.)+vec4(0, 23, 21, 1)))+vec4(0., 0., 0., 1.))*texelFetch(Sampler2, UV2 / 16, 0));
(gl_Position.y=gl_Position.y+sin(GameTime*12000.+(gl_Position.x*6))/ 150.);
}else if(Color.xyz==vec3(255., 255., 251.)/ 255.){
(vertexColor=Color*texelFetch(Sampler2, UV2 / 16, 0));
float vertexId = mod(gl_VertexID, 4.0);
if(vertex.z <= 0.){
if(vertexId==3.||vertexId==0.)vertex.y += cos(GameTime*12000. / 4)*0.1;
vertex.y += max(cos(GameTime*12000. / 4)*0.1, 0.);
}else{
if(vertexId==3.||vertexId==0.)vertex.y-=cos(GameTime*12000. / 4)*3;
vertex.y-=max(cos(GameTime*12000. / 4)*4, 0.);
}
(gl_Position=ProjMat*ModelViewMat*vertex);
}else if(Color.xyz==vec3(255., 254., 254.)/ 255.){
float vertexId = mod(gl_VertexID, 4.0);
if(vertex.z <= 0.){
if(vertexId==3.||vertexId==0.)vertex.y += cos(GameTime*12000. / 4)*0.1;
vertex.y += max(cos(GameTime*12000. / 4)*0.1, 0.);
}else{
if(vertexId==3.||vertexId==0.)vertex.y-=cos(GameTime*12000. / 4)*3;
vertex.y-=max(cos(GameTime*12000. / 4)*4, 0.);
}
(vertexColor=((.6+.6*cos(6.*(gl_Position.x+GameTime*1000.)+vec4(0, 23, 21, 1)))+vec4(0., 0., 0., 1.))*texelFetch(Sampler2, UV2 / 16, 0));
(gl_Position=ProjMat*ModelViewMat*vertex);
}else if(Color.xyz==vec3(255., 254., 253.)/ 255.){
(vertexColor=Color*texelFetch(Sampler2, UV2 / 16, 0));
vec4 vertex = vec4(Position, 1.0);
vertexDistance = fog_distance(ModelViewMat, IViewRotMat * Position, FogShape);
texCoord0 = UV0;
{IA}
if (Color.xyz == vec3(255., 254., 253.) / 255.) {
vertexColor = Color*texelFetch(Sampler2, UV2 / 16, 0);
vertex.y+= 1;
vertex.x+= 1;
(gl_Position=ProjMat*ModelViewMat*vertex);
}else{
(gl_Position=ProjMat*ModelViewMat*vertex);
(vertexColor=Color*texelFetch(Sampler2, UV2 / 16, 0));
gl_Position = ProjMat * ModelViewMat * vertex;
} else {
vertexColor = Color*texelFetch(Sampler2, UV2 / 16, 0);
gl_Position = ProjMat * ModelViewMat * vertex;
}
vertexDistance=length((ModelViewMat*vertex).xyz);
texCoord0=UV0;
}
{hide}
}

View File

@@ -1,5 +1,5 @@
# Do not change
config-version: '17'
config-version: '18'
# bStats
metrics: true
@@ -65,6 +65,10 @@ resource-pack:
# Unicode Support for 1.20+ clients
# This would make your resource pack about 900KB bigger
support-1_20-unicodes: true
# Hide scoreboard numbers
hide-scoreboard-number: true
# Added ItemsAdder text effect shader support
ItemsAdder-text-effect-support: true
other-settings:
# default width