|
2 | 2 |
|
3 | 3 | import net.minecraft.ChatFormatting; |
4 | 4 |
|
| 5 | +import net.minecraft.core.Holder; |
5 | 6 | import net.minecraft.core.registries.BuiltInRegistries; |
6 | 7 | import net.minecraft.network.chat.ClickEvent; |
7 | 8 | import net.minecraft.network.chat.Component; |
8 | 9 | import net.minecraft.network.chat.HoverEvent; |
9 | 10 | import net.minecraft.network.chat.Style; |
10 | 11 | import net.minecraft.resources.ResourceKey; |
11 | 12 | import net.minecraft.server.level.ServerPlayer; |
| 13 | +import net.minecraft.world.effect.MobEffect; |
12 | 14 | import net.minecraft.world.entity.Entity; |
13 | 15 | import net.minecraft.world.entity.player.Player; |
14 | 16 | import net.minecraft.world.level.Level; |
|
18 | 20 | import net.neoforged.neoforge.event.tick.PlayerTickEvent; |
19 | 21 | import org.jetbrains.annotations.NotNull; |
20 | 22 | import org.jetbrains.annotations.Nullable; |
| 23 | +import org.jspecify.annotations.NonNull; |
21 | 24 | import org.slf4j.Logger; |
22 | 25 | import org.slf4j.LoggerFactory; |
23 | 26 | import org.slf4j.Marker; |
|
33 | 36 |
|
34 | 37 | import java.util.ArrayList; |
35 | 38 | import java.util.Iterator; |
| 39 | +import java.util.List; |
36 | 40 | import java.util.Set; |
37 | 41 | import java.util.UUID; |
38 | 42 |
|
@@ -108,6 +112,18 @@ public static void onPlayerTick(PlayerTickEvent.Pre event) { |
108 | 112 | player.sendOverlayMessage(Component.translatable("area_control.notice.ride_disabled", riding.getDisplayName())); |
109 | 113 | player.stopRiding(); |
110 | 114 | } |
| 115 | + // Clear disallowed effects |
| 116 | + for (Holder<@NonNull MobEffect> effectId : List.copyOf(player.getActiveEffectsMap().keySet())) { |
| 117 | + var regKey = effectId.getKey(); |
| 118 | + if (regKey == null) { |
| 119 | + // This is impossible - no effect should lack registry id at runtime, unless it is unregistered. |
| 120 | + continue; |
| 121 | + } |
| 122 | + if (!AreaChecks.checkPropFor(currentArea, player, AreaProperties.ALLOW_ACTIVE_EFFECT, regKey.identifier(), AreaControlConfig.allowActiveEffect)) { |
| 123 | + player.removeEffect(effectId); |
| 124 | + player.sendOverlayMessage(Component.translatable("area_control.notice.clear_effect", effectId.value().getDisplayName())); |
| 125 | + } |
| 126 | + } |
111 | 127 |
|
112 | 128 | // 检查玩家的 Bypass 状态并更新。 |
113 | 129 | INSTANCE.updatePlayerExemptionStatus(player, status, prevArea); |
|
0 commit comments