2024-12-14 22:12:42 +01:00
|
|
|
--- a/net/minecraft/world/effect/MobEffectUtil.java
|
|
|
|
+++ b/net/minecraft/world/effect/MobEffectUtil.java
|
2024-12-20 12:00:24 +01:00
|
|
|
@@ -47,18 +_,38 @@
|
2024-12-14 22:12:42 +01:00
|
|
|
public static List<ServerPlayer> addEffectToPlayersAround(
|
|
|
|
ServerLevel level, @Nullable Entity source, Vec3 pos, double radius, MobEffectInstance effect, int duration
|
|
|
|
) {
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ return MobEffectUtil.addEffectToPlayersAround(level, source, pos, radius, effect, duration, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.UNKNOWN);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static List<ServerPlayer> addEffectToPlayersAround(ServerLevel level, @Nullable Entity source, Vec3 pos, double radius, MobEffectInstance effect, int duration, org.bukkit.event.entity.EntityPotionEffectEvent.Cause cause) {
|
|
|
|
+ // Paper start - Add ElderGuardianAppearanceEvent
|
|
|
|
+ return addEffectToPlayersAround(level, source, pos, radius, effect, duration, cause, null);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static List<ServerPlayer> addEffectToPlayersAround(ServerLevel level, @Nullable Entity source, Vec3 pos, double radius, MobEffectInstance effect, int duration, org.bukkit.event.entity.EntityPotionEffectEvent.Cause cause, @Nullable java.util.function.Predicate<ServerPlayer> playerPredicate) {
|
|
|
|
+ // Paper end - Add ElderGuardianAppearanceEvent
|
|
|
|
+ // CraftBukkit end
|
|
|
|
Holder<MobEffect> effect1 = effect.getEffect();
|
2024-12-20 12:00:24 +01:00
|
|
|
List<ServerPlayer> players = level.getPlayers(
|
2024-12-14 22:12:42 +01:00
|
|
|
- serverPlayer -> serverPlayer.gameMode.isSurvival()
|
2024-12-20 12:00:24 +01:00
|
|
|
+ // Paper start - Add ElderGuardianAppearanceEvent
|
|
|
|
+ serverPlayer -> {
|
|
|
|
+ final boolean condition = serverPlayer.gameMode.isSurvival()
|
|
|
|
&& (source == null || !source.isAlliedTo(serverPlayer))
|
|
|
|
&& pos.closerThan(serverPlayer.position(), radius)
|
|
|
|
&& (
|
2024-12-14 22:12:42 +01:00
|
|
|
- !serverPlayer.hasEffect(effect1)
|
|
|
|
- || serverPlayer.getEffect(effect1).getAmplifier() < effect.getAmplifier()
|
|
|
|
- || serverPlayer.getEffect(effect1).endsWithin(duration - 1)
|
|
|
|
- )
|
|
|
|
- );
|
|
|
|
- players.forEach(serverPlayer -> serverPlayer.addEffect(new MobEffectInstance(effect), source));
|
2024-12-20 12:00:24 +01:00
|
|
|
+ !serverPlayer.hasEffect(effect1)
|
|
|
|
+ || serverPlayer.getEffect(effect1).getAmplifier() < effect.getAmplifier()
|
|
|
|
+ || serverPlayer.getEffect(effect1).endsWithin(duration - 1)
|
|
|
|
+ );
|
2024-12-14 22:12:42 +01:00
|
|
|
+ if (condition) {
|
2024-12-20 12:00:24 +01:00
|
|
|
+ return playerPredicate == null || playerPredicate.test(serverPlayer); // Only test the player AFTER it is true
|
2024-12-14 22:12:42 +01:00
|
|
|
+ } else {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ });
|
2024-12-20 12:00:24 +01:00
|
|
|
+ // Paper end - Add ElderGuardianAppearanceEvent
|
2024-12-14 22:12:42 +01:00
|
|
|
+ players.forEach(serverPlayer -> serverPlayer.addEffect(new MobEffectInstance(effect), source, cause)); // CraftBukkit
|
|
|
|
return players;
|
|
|
|
}
|
|
|
|
}
|