Skip to content

Commit

Permalink
apply logic to color picking as well
Browse files Browse the repository at this point in the history
  • Loading branch information
xGinko committed Nov 14, 2023
1 parent e9c2e64 commit 1848571
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public FireworkEffects() {
int tries = 0;
while (secondary_color.equals(primary_color)) { // Avoid rolling the same color
if (tries > 100) break; // Avoid infinite loop on bad config
secondary_color = parsedColors.get(new Random().nextInt(parsedColors.size()));
secondary_color = parsedColors.get(new Random().nextInt(parsedColors.size() + 1) - 1);
tries++;
}
this.fireWorkEffects.add(FireworkEffect.builder()
Expand Down Expand Up @@ -100,6 +100,11 @@ public void disable() {
HandlerList.unregisterAll(this);
}

private FireworkEffect getRandomEffect() {
// Try to get a 0 naturally without having an origin value in Random (I hate using old jdk's)
return this.fireWorkEffects.get(new Random().nextInt(this.fireWorkEffects.size() + 1) - 1);
}

@EventHandler(priority = EventPriority.LOWEST)
private void onPostPumpkinExplode(PostPumpkinExplodeEvent event) {
if (event.hasExploded()) {
Expand All @@ -125,9 +130,4 @@ private void onPostPumpkinHeadExplode(PostPumpkinHeadEntityExplodeEvent event) {
firework.detonate();
}
}

private FireworkEffect getRandomEffect() {
// Try to get a 0 naturally without having an origin value in Random (I hate using old jdk's)
return this.fireWorkEffects.get(new Random().nextInt(this.fireWorkEffects.size() + 1) - 1);
}
}

0 comments on commit 1848571

Please sign in to comment.