Skip to content

Commit 5e00153

Browse files
committed
add particles to make it rain
Took 12 minutes
1 parent 7c1db90 commit 5e00153

1 file changed

Lines changed: 20 additions & 12 deletions

File tree

src/main/java/dev/oribuin/fishing/model/augment/impl/AugmentMakeItRain.java

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package dev.oribuin.fishing.model.augment.impl;
22

3+
import com.destroystokyo.paper.ParticleBuilder;
34
import dev.oribuin.fishing.FishingPlugin;
4-
import dev.oribuin.fishing.api.event.impl.FishCatchEvent;
55
import dev.oribuin.fishing.api.event.impl.InitialFishCatchEvent;
66
import dev.oribuin.fishing.manager.TierManager;
77
import dev.oribuin.fishing.model.augment.Augment;
@@ -12,7 +12,8 @@
1212
import dev.rosewood.rosegarden.config.CommentedConfigurationSection;
1313
import dev.rosewood.rosegarden.utils.StringPlaceholders;
1414
import org.bukkit.Location;
15-
import org.bukkit.World;
15+
import org.bukkit.Material;
16+
import org.bukkit.Particle;
1617
import org.bukkit.event.player.PlayerFishEvent;
1718
import org.jetbrains.annotations.NotNull;
1819
import org.jetbrains.annotations.Nullable;
@@ -29,13 +30,10 @@
2930
*/
3031
public 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

Comments
 (0)