fix bug with leavin game while knocked
This commit is contained in:
+1
-1
@@ -50,7 +50,7 @@ mod_name=Knockedback
|
||||
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
||||
mod_license=MIT
|
||||
# The mod version. See https://semver.org/
|
||||
mod_version=1.5.2
|
||||
mod_version=1.5.3
|
||||
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
|
||||
# This should match the base package used for the mod sources.
|
||||
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
|
||||
@@ -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