fix bug with leavin game while knocked
This commit is contained in:
@@ -16,6 +16,7 @@ import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.network.PacketDistributor;
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent.PlayerLoggedOutEvent;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
import java.util.*;
|
||||
@@ -25,20 +26,15 @@ public class KnockedManager {
|
||||
private static final Map<UUID, Integer> knockedEntities = new HashMap<>();
|
||||
private static final Set<UUID> grippedEntities = new HashSet<>();
|
||||
private static final Set<UUID> killingNow = new HashSet<>();
|
||||
|
||||
public static void markKillInProgress(LivingEntity e) {
|
||||
killingNow.add(e.getUUID());
|
||||
}
|
||||
|
||||
public static void unmarkKillInProgress(LivingEntity e) {
|
||||
killingNow.remove(e.getUUID());
|
||||
}
|
||||
|
||||
|
||||
public static int getKnockedDuration() {
|
||||
return Config.COMMON.knockedDuration.get();
|
||||
}
|
||||
|
||||
public static void applyKnockedState(LivingEntity entity) {
|
||||
if (!(entity instanceof Player)) {
|
||||
return;
|
||||
@@ -224,6 +220,18 @@ public class KnockedManager {
|
||||
);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onPlayerLoggedOut(PlayerLoggedOutEvent event) {
|
||||
if (!(event.getEntity() instanceof ServerPlayer sp)) {
|
||||
return;
|
||||
}
|
||||
if (!isKnocked(sp)) {
|
||||
return;
|
||||
}
|
||||
killAndRemove(sp);
|
||||
}
|
||||
|
||||
|
||||
private static void applyKnockedEffects(Player player) {
|
||||
List<? extends String> configured = Config.COMMON.knockedPotionEffects.get();
|
||||
Map<MobEffect, MobEffectInstance> desiredEffects = new HashMap<>();
|
||||
|
||||
Reference in New Issue
Block a user