Fix color bug (argb <> rgb), fix particles defaulting to size 0
This commit is contained in:
@@ -150,6 +150,7 @@ public class ParticleConfig {
|
||||
* @return A ParticleSet created from the ParticleData
|
||||
*/
|
||||
public ParticleSet convertToParticleSet(ParticleData particleData) {
|
||||
log.info("Converting ParticleData to ParticleSet for {}", particleData.getParticleName());
|
||||
List<Frame> loadedFrames = new ArrayList<>();
|
||||
double randomOffset = particleData.getRandomOffset();
|
||||
|
||||
@@ -168,35 +169,7 @@ public class ParticleConfig {
|
||||
Class<?> dataType = particleType.getDataType();
|
||||
|
||||
// Handle different particle data types
|
||||
if (dataType.equals(Particle.DustOptions.class)) {
|
||||
if (particleInfo.getColor() != null) {
|
||||
particleBuilder.color(getColor(particleInfo.getColor()),
|
||||
particleInfo.getSize());
|
||||
}
|
||||
} else if (dataType.equals(Particle.DustTransition.class)) {
|
||||
if (particleInfo.getColorGradientEnd() != null) {
|
||||
particleBuilder.colorTransition(getColor(particleInfo.getColor()),
|
||||
getColor(particleInfo.getColorGradientEnd()),
|
||||
particleInfo.getSize());
|
||||
}
|
||||
}
|
||||
else if (dataType.equals(Color.class)) {
|
||||
particleBuilder.color(getColor(particleInfo.getColor()));
|
||||
} else if (dataType.equals(BlockData.class)) {
|
||||
particleBuilder.data(Material.STONE.createBlockData());
|
||||
//TODO implement
|
||||
} else if (dataType.equals(Integer.class)) {
|
||||
particleBuilder.data(1);
|
||||
//TODO implement
|
||||
} else if (dataType.equals(Float.class)) {
|
||||
particleBuilder.data(1f);
|
||||
//TODO implement
|
||||
} else if (dataType.equals(ItemStack.class)) {
|
||||
particleBuilder.data(new ItemStack(Material.STONE));
|
||||
//TODO implement
|
||||
} else if (particleInfo.getExtra() != null) {
|
||||
particleBuilder.extra(particleInfo.getExtra());
|
||||
}
|
||||
setParticleType(particleInfo, dataType, particleBuilder);
|
||||
|
||||
//Add 0.2 to adjust for the player model being 1.6 blocks high
|
||||
aParticleList.add(new AParticle(x, y + 0.2, z, randomOffset, particleBuilder));
|
||||
@@ -223,13 +196,58 @@ public class ParticleConfig {
|
||||
);
|
||||
}
|
||||
|
||||
private Color getColor(String hexColor) {
|
||||
int color = HexFormat.fromHexDigits(hexColor);
|
||||
if (hexColor.length() == 6) {
|
||||
return Color.fromARGB(color);
|
||||
} else {
|
||||
return Color.fromRGB(color);
|
||||
private void setParticleType(ParticleInfo particleInfo, Class<?> dataType, ParticleBuilder particleBuilder) {
|
||||
String color = particleInfo.getColor();
|
||||
if (dataType.equals(Particle.DustOptions.class)) {
|
||||
if (color != null) {
|
||||
particleBuilder.color(getColor(color),
|
||||
particleInfo.getSize());
|
||||
} else {
|
||||
log.error("Dust particle must have a color");
|
||||
}
|
||||
} else if (dataType.equals(Particle.DustTransition.class)) {
|
||||
if (color == null || particleInfo.getColorGradientEnd() != null) {
|
||||
particleBuilder.colorTransition(getColor(color),
|
||||
getColor(particleInfo.getColorGradientEnd()),
|
||||
particleInfo.getSize());
|
||||
} else {
|
||||
log.error("Dust transition particle must have a color gradient start and end");
|
||||
}
|
||||
}
|
||||
else if (dataType.equals(Color.class)) {
|
||||
particleBuilder.color(getColor(color));
|
||||
} else if (dataType.equals(BlockData.class)) {
|
||||
particleBuilder.data(Material.STONE.createBlockData());
|
||||
log.warn("Block data particles are not yet supported");
|
||||
//TODO implement
|
||||
} else if (dataType.equals(Integer.class)) {
|
||||
particleBuilder.data(1);
|
||||
log.warn("Integer data particles are not yet supported");
|
||||
//TODO implement
|
||||
} else if (dataType.equals(Float.class)) {
|
||||
particleBuilder.data(1f);
|
||||
log.warn("Float data particles are not yet supported");
|
||||
//TODO implement
|
||||
} else if (dataType.equals(ItemStack.class)) {
|
||||
particleBuilder.data(new ItemStack(Material.STONE));
|
||||
log.warn("ItemStack data particles are not yet supported");
|
||||
//TODO implement
|
||||
} else if (particleInfo.getExtra() != null) {
|
||||
particleBuilder.extra(particleInfo.getExtra());
|
||||
} else {
|
||||
log.debug("No relevant data type: {}", dataType.getName());
|
||||
}
|
||||
}
|
||||
|
||||
private Color getColor(String hexColor) {
|
||||
int hexFormatColor = HexFormat.fromHexDigits(hexColor);
|
||||
Color color;
|
||||
if (hexColor.length() == 6) {
|
||||
color = Color.fromRGB(hexFormatColor);
|
||||
} else {
|
||||
color = Color.fromARGB(hexFormatColor);
|
||||
}
|
||||
return color;
|
||||
}
|
||||
|
||||
public static void reload() {
|
||||
|
||||
Reference in New Issue
Block a user