mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 23:38:25 +01:00
Add ElderGuardianAppearanceEvent
This commit is contained in:
parent
4198f9a836
commit
f67092fe39
2 changed files with 16 additions and 3 deletions
|
@ -1,6 +1,6 @@
|
|||
--- a/net/minecraft/world/effect/MobEffectUtil.java
|
||||
+++ b/net/minecraft/world/effect/MobEffectUtil.java
|
||||
@@ -50,13 +50,19 @@
|
||||
@@ -50,13 +50,32 @@
|
||||
}
|
||||
|
||||
public static List<ServerPlayer> addEffectToPlayersAround(ServerLevel world, @Nullable Entity entity, Vec3 origin, double range, MobEffectInstance statusEffectInstance, int duration) {
|
||||
|
@ -12,10 +12,23 @@
|
|||
+ }
|
||||
+
|
||||
+ public static List<ServerPlayer> addEffectToPlayersAround(ServerLevel worldserver, @Nullable Entity entity, Vec3 vec3d, double d0, MobEffectInstance mobeffect, int i, org.bukkit.event.entity.EntityPotionEffectEvent.Cause cause) {
|
||||
+ // Paper start - Add ElderGuardianAppearanceEvent
|
||||
+ return addEffectToPlayersAround(worldserver, entity, vec3d, d0, mobeffect, i, cause, null);
|
||||
+ }
|
||||
+
|
||||
+ public static List<ServerPlayer> addEffectToPlayersAround(ServerLevel worldserver, @Nullable Entity entity, Vec3 vec3d, double d0, MobEffectInstance mobeffect, int i, org.bukkit.event.entity.EntityPotionEffectEvent.Cause cause, @Nullable java.util.function.Predicate<ServerPlayer> playerPredicate) {
|
||||
+ // Paper end - Add ElderGuardianAppearanceEvent
|
||||
+ // CraftBukkit end
|
||||
+ Holder<MobEffect> holder = mobeffect.getEffect();
|
||||
+ List<ServerPlayer> list = worldserver.getPlayers((entityplayer) -> {
|
||||
+ return entityplayer.gameMode.isSurvival() && (entity == null || !entity.isAlliedTo((Entity) entityplayer)) && vec3d.closerThan(entityplayer.position(), d0) && (!entityplayer.hasEffect(holder) || entityplayer.getEffect(holder).getAmplifier() < mobeffect.getAmplifier() || entityplayer.getEffect(holder).endsWithin(i - 1));
|
||||
+ // Paper start - Add ElderGuardianAppearanceEvent
|
||||
+ boolean condition = entityplayer.gameMode.isSurvival() && (entity == null || !entity.isAlliedTo((Entity) entityplayer)) && vec3d.closerThan(entityplayer.position(), d0) && (!entityplayer.hasEffect(holder) || entityplayer.getEffect(holder).getAmplifier() < mobeffect.getAmplifier() || entityplayer.getEffect(holder).endsWithin(i - 1));
|
||||
+ if (condition) {
|
||||
+ return playerPredicate == null || playerPredicate.test(entityplayer); // Only test the player AFTER it is true
|
||||
+ } else {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // Paper ned - Add ElderGuardianAppearanceEvent
|
||||
});
|
||||
|
||||
list.forEach((entityplayer) -> {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
if ((this.tickCount + this.getId()) % 1200 == 0) {
|
||||
MobEffectInstance mobeffect = new MobEffectInstance(MobEffects.DIG_SLOWDOWN, 6000, 2);
|
||||
- List<ServerPlayer> list = MobEffectUtil.addEffectToPlayersAround(world, this, this.position(), 50.0D, mobeffect, 1200);
|
||||
+ List<ServerPlayer> list = MobEffectUtil.addEffectToPlayersAround(world, this, this.position(), 50.0D, mobeffect, 1200, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit
|
||||
+ List<ServerPlayer> list = MobEffectUtil.addEffectToPlayersAround(world, this, this.position(), 50.0D, mobeffect, 1200, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK, (player) -> new io.papermc.paper.event.entity.ElderGuardianAppearanceEvent((org.bukkit.entity.ElderGuardian) this.getBukkitEntity(), player.getBukkitEntity()).callEvent()); // CraftBukkit // Paper - Add ElderGuardianAppearanceEvent
|
||||
|
||||
list.forEach((entityplayer) -> {
|
||||
entityplayer.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.GUARDIAN_ELDER_EFFECT, this.isSilent() ? 0.0F : 1.0F));
|
||||
|
|
Loading…
Reference in a new issue