mirror of
https://github.com/Xiao-MoMi/Custom-Nameplates.git
synced 2025-12-30 20:29:07 +00:00
3.0.8
This commit is contained in:
@@ -21,6 +21,7 @@ import dev.dejvokep.boostedyaml.YamlDocument;
|
||||
import net.momirealms.customnameplates.api.ConfigManager;
|
||||
import net.momirealms.customnameplates.api.CustomNameplates;
|
||||
import net.momirealms.customnameplates.api.feature.ConfiguredCharacter;
|
||||
import net.momirealms.customnameplates.api.feature.image.Animation;
|
||||
import net.momirealms.customnameplates.api.feature.image.Image;
|
||||
import net.momirealms.customnameplates.api.feature.image.ImageManager;
|
||||
import net.momirealms.customnameplates.api.util.ConfigUtils;
|
||||
@@ -73,8 +74,11 @@ public class ImageManagerImpl implements ImageManager {
|
||||
String id = configFile.getName().substring(0, configFile.getName().lastIndexOf("."));
|
||||
Image image = Image.builder()
|
||||
.id(id)
|
||||
.hasShadow(!config.getBoolean("shadow.remove", false))
|
||||
.opacity(config.getInt("shadow.opacity", 254))
|
||||
.animation(config.contains("animation") ? new Animation(
|
||||
config.getInt("animation.speed", 64),
|
||||
config.getInt("animation.frames", 1)
|
||||
) : null)
|
||||
.removeShadow(!config.getBoolean("shadow", true))
|
||||
.character(ConfiguredCharacter.create(
|
||||
ConfigUtils.getFileInTheSameFolder(configFile, config.getString("image") + ".png"),
|
||||
config.getInt("ascent", 8),
|
||||
|
||||
@@ -29,6 +29,7 @@ import net.momirealms.customnameplates.api.feature.OffsetFont;
|
||||
import net.momirealms.customnameplates.api.feature.advance.CharacterFontAdvanceData;
|
||||
import net.momirealms.customnameplates.api.feature.background.Background;
|
||||
import net.momirealms.customnameplates.api.feature.bubble.Bubble;
|
||||
import net.momirealms.customnameplates.api.feature.image.Animation;
|
||||
import net.momirealms.customnameplates.api.feature.image.Image;
|
||||
import net.momirealms.customnameplates.api.feature.nameplate.Nameplate;
|
||||
import net.momirealms.customnameplates.api.feature.pack.ResourcePackManager;
|
||||
@@ -321,11 +322,53 @@ public class ResourcePackManagerImpl implements ResourcePackManager {
|
||||
jo.add("chars", ja);
|
||||
list.add(jo);
|
||||
try {
|
||||
File targetFile = new File(texturesFolder,
|
||||
ConfigManager.imagePath().replace("\\", File.separator) + character.imageFile().getName());
|
||||
FileUtils.copyFile(
|
||||
new File(plugin.getDataFolder(),
|
||||
"contents" + File.separator + "images" + File.separator + character.imageFile().getName()),
|
||||
new File(texturesFolder,
|
||||
ConfigManager.imagePath().replace("\\", File.separator) + character.imageFile().getName()));
|
||||
"contents" + File.separator + "images" + File.separator + character.imageFile().getName()), targetFile);
|
||||
if (image.removeShadow() || image.animation() != null) {
|
||||
BufferedImage bufferedImage = ImageIO.read(targetFile);
|
||||
if (image.removeShadow()) {
|
||||
for (int y = 0; y < bufferedImage.getHeight(); y++) {
|
||||
for (int x = 0; x < bufferedImage.getWidth(); x++) {
|
||||
int argb = bufferedImage.getRGB(x, y);
|
||||
int alpha = (argb >> 24) & 0xff;
|
||||
if (alpha != 0) {
|
||||
int rgb = argb & 0x00ffffff;
|
||||
int newArgb = (254 << 24) | rgb;
|
||||
bufferedImage.setRGB(x, y, newArgb);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Animation animation = image.animation();
|
||||
if (animation != null) {
|
||||
int height = bufferedImage.getHeight();
|
||||
int extra = height % animation.frames();
|
||||
if (extra > 0) {
|
||||
plugin.getPluginLogger().warn("Image height is not a multiple of frame rate: " + image.id());
|
||||
continue;
|
||||
}
|
||||
int eachFrameHeight = height / animation.frames();
|
||||
int width = bufferedImage.getWidth();
|
||||
int speed = Math.min(Math.max(animation.speed(), 1), 255);
|
||||
|
||||
int alpha = 1;
|
||||
int red = speed;
|
||||
int green = width;
|
||||
int blue = eachFrameHeight;
|
||||
int argb = (alpha << 24) | (red << 16) | (green << 8) | blue;
|
||||
|
||||
for (int i = 0; i < animation.frames(); i++) {
|
||||
int y = i * eachFrameHeight;
|
||||
bufferedImage.setRGB(0, y, argb);
|
||||
}
|
||||
}
|
||||
|
||||
ImageIO.write(bufferedImage, "png", targetFile);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
@@ -583,6 +626,7 @@ public class ResourcePackManagerImpl implements ResourcePackManager {
|
||||
" 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" +
|
||||
" } else ";
|
||||
|
||||
public static final String Hide_ScoreBoard_Numbers =
|
||||
"\n" +
|
||||
" if (Position.z == 0.0\n" +
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
image: bell
|
||||
height: 10
|
||||
ascent: 4
|
||||
ascent: 4
|
||||
shadow: false
|
||||
@@ -1,3 +1,4 @@
|
||||
image: bubble
|
||||
height: 10
|
||||
ascent: 4
|
||||
ascent: 4
|
||||
shadow: false
|
||||
@@ -1,3 +1,4 @@
|
||||
image: clock
|
||||
height: 10
|
||||
ascent: 4
|
||||
ascent: 4
|
||||
shadow: false
|
||||
@@ -1,3 +1,4 @@
|
||||
image: coin
|
||||
height: 10
|
||||
ascent: -14
|
||||
ascent: -14
|
||||
shadow: false
|
||||
@@ -1,3 +1,4 @@
|
||||
image: compass
|
||||
height: 10
|
||||
ascent: 4
|
||||
ascent: 4
|
||||
shadow: false
|
||||
@@ -1,3 +1,4 @@
|
||||
image: stamina_0
|
||||
height: 9
|
||||
ascent: -16
|
||||
ascent: -16
|
||||
shadow: false
|
||||
@@ -1,3 +1,4 @@
|
||||
image: stamina_1
|
||||
height: 9
|
||||
ascent: -16
|
||||
ascent: -16
|
||||
shadow: false
|
||||
@@ -1,3 +1,4 @@
|
||||
image: stamina_2
|
||||
height: 9
|
||||
ascent: -16
|
||||
ascent: -16
|
||||
shadow: false
|
||||
@@ -1,3 +1,4 @@
|
||||
image: weather
|
||||
height: 10
|
||||
ascent: 4
|
||||
ascent: 4
|
||||
shadow: false
|
||||
Reference in New Issue
Block a user