class snowflake {
public float x;
public float y;
public float size;
public float alpha;
}
int snowflake_count = 59;
public List<snowflake> sfs = new ArrayList<snowflake>();
boolean created = false;
private final TimerUtil bolvan = new TimerUtil();
protected void renderSnowflake(MatrixStack matrixStack, snowflake snowflake) {
Fonts.msLight[new Random().nextInt(15, 22)].drawString(matrixStack, "*", snowflake.x, snowflake.y, ColorUtil.rgba(255, 255, 255, snowflake.alpha));
}
protected void createSnowflakeList() {
if(!created) {
for (int i = 1; i <= snowflake_count; i++) {
snowflake s = new snowflake();
s.x = new Random().nextInt(140, 1900);
s.y = new Random().nextInt(-192, 33);
s.alpha = new Random().nextInt(60, 255);
s.size = 1;
sfs.add(s);
if (i == snowflake_count) { created = true; }
}
}
}
int f = 1;
protected void createSnowflakes(MatrixStack matrixStack) {
if(!created) { return; }
long l = 10;
if(bolvan.hasTimeElapsed(l)) {
for (int i = 1; i <= sfs.size()-1; i++) {
sfs.get(i).x = sfs.get(i).x - 1;
sfs.get(i).y = sfs.get(i).y + 1;
if(i <= sfs.size()-1) { bolvan.reset(); }
}
}
for(int i = 0; i <= sfs.size()-1; i++){
renderSnowflake(matrixStack, sfs.get(i));
}
if (sfs.get(sfs.size()-8).y > 60*f) {
created = false;
f++;
}
if(sfs.get(sfs.size()-8).y > 1050){
for (int i = 1; i <= snowflake_count; i++) { sfs.remove(i); f-=0.5; }
}
}
public void renderSnow(MatrixStack matrixStack) {
createSnowflakeList();
createSnowflakes(matrixStack);
}