11package dev .oribuin .fishing .model .augment .impl ;
22
3+ import com .destroystokyo .paper .ParticleBuilder ;
34import dev .oribuin .fishing .FishingPlugin ;
4- import dev .oribuin .fishing .api .event .impl .FishCatchEvent ;
55import dev .oribuin .fishing .api .event .impl .InitialFishCatchEvent ;
66import dev .oribuin .fishing .manager .TierManager ;
77import dev .oribuin .fishing .model .augment .Augment ;
1212import dev .rosewood .rosegarden .config .CommentedConfigurationSection ;
1313import dev .rosewood .rosegarden .utils .StringPlaceholders ;
1414import org .bukkit .Location ;
15- import org .bukkit .World ;
15+ import org .bukkit .Material ;
16+ import org .bukkit .Particle ;
1617import org .bukkit .event .player .PlayerFishEvent ;
1718import org .jetbrains .annotations .NotNull ;
1819import org .jetbrains .annotations .Nullable ;
2930 */
3031public class AugmentMakeItRain extends Augment {
3132
32- private Map <UUID , Long > cooldown = new HashMap <>();
3333 private String chanceFormula = "%level% * 0.5" ;
3434 private int minAttempts = 2 ;
3535 private int maxAttempts = 6 ;
36-
37- public static final Duration COOLDOWN = Duration .ofSeconds (10 );
38-
36+
3937 /**
4038 * Create a new type of augment with a name and description.
4139 * <p>
@@ -62,8 +60,8 @@ public AugmentMakeItRain() {
6260 public void onInitialCatch (InitialFishCatchEvent event , int level ) {
6361 StringPlaceholders plc = StringPlaceholders .of ("level" , level );
6462 double chance = FishUtils .evaluate (plc .apply (this .chanceFormula ));
65- // double current = this.random.nextDouble(100);
66- // if (current <= chance) return;
63+ double current = this .random .nextDouble (100 );
64+ if (current <= chance ) return ;
6765
6866 List <Fish > result = new ArrayList <>();
6967 for (int i = this .minAttempts ; i < this .maxAttempts ; i ++) {
@@ -72,11 +70,21 @@ public void onInitialCatch(InitialFishCatchEvent event, int level) {
7270 }
7371
7472 Location location = event .getPlayer ().getLocation ().clone ();
75- result .forEach (fish -> {
76- double randX = FishUtils .RANDOM .nextDouble (-0.5 , 0.5 );
77- double randZ = FishUtils .RANDOM .nextDouble (-0.5 , 0.5 );
73+ ParticleBuilder rainCloud = new ParticleBuilder (Particle .FALLING_DUST ) // falling dust looks better than cloud
74+ .data (Material .WHITE_CONCRETE .createBlockData ())
75+ .count (20 )
76+ .extra (0 )
77+ .offset (0.5 , 0.5 , 0.5 );
7878
79- location .getWorld ().dropItem (location .clone ().add (randX , 3 , randZ ), fish .createItemStack ());
79+ result .forEach (fish -> {
80+ double randX = FishUtils .RANDOM .nextDouble (-1 , 1 );
81+ double randZ = FishUtils .RANDOM .nextDouble (-1 , 1 );
82+ Location spawnPoint = location .clone ().add (randX , 4 , randZ );
83+
84+ location .getWorld ().dropItem (spawnPoint , fish .createItemStack ());
85+ rainCloud .clone ().location (spawnPoint )
86+ .receivers (10 )
87+ .spawn (); // spawn rain clouds
8088 });
8189 }
8290
0 commit comments