Removed Unused Imports

This commit is contained in:
IM23a-spirgif
2025-04-25 02:08:25 +02:00
parent 784b8bb9b5
commit 4216aea33e
2 changed files with 1 additions and 21 deletions
@@ -2,11 +2,9 @@ package net.fretux.knockedback;
import com.mojang.logging.LogUtils;
import net.fretux.knockedback.effects.KnockedEffect;
import net.minecraft.world.entity.player.Player;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.TickEvent;
import net.minecraftforge.event.entity.living.LivingDeathEvent;
import net.minecraftforge.event.entity.living.LivingHurtEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.common.Mod;
@@ -15,7 +13,6 @@ import net.minecraftforge.fml.config.ModConfig;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import org.slf4j.Logger;
import net.minecraft.world.damagesource.DamageSource;
@Mod(KnockedBack.MOD_ID)
public class KnockedBack {
@@ -11,15 +11,12 @@ import net.minecraftforge.event.entity.living.LivingHurtEvent;
import net.minecraftforge.event.entity.player.AttackEntityEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.network.PacketDistributor;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import static net.fretux.knockedback.NetworkHandlerHelper.getPlayerByUuid;
@Mod.EventBusSubscriber(modid = "knockedback", bus = Mod.EventBusSubscriber.Bus.FORGE)
public class PlayerExecutionHandler {
public static final double EXECUTION_RANGE = 2.0;
@@ -53,7 +50,6 @@ public class PlayerExecutionHandler {
private static class PlayerExecutionAttempt {
private final UUID executorUuid;
private int timeLeft;
public PlayerExecutionAttempt(UUID executorUuid) {
this.executorUuid = executorUuid;
this.timeLeft = EXECUTION_DELAY_TICKS;
@@ -69,7 +65,6 @@ public class PlayerExecutionHandler {
UUID knockedId = target.getUUID();
if (!KnockedManager.isKnocked(target)) return;
if (executionAttempts.containsKey(knockedId)) return;
executionAttempts.put(knockedId, new PlayerExecutionAttempt(executor.getUUID()));
executor.sendSystemMessage(Component.literal("Execution started..."));
target.sendSystemMessage(Component.literal("You're being executed!"));
@@ -82,7 +77,6 @@ public class PlayerExecutionHandler {
if (knocked != null) {
knocked.sendSystemMessage(Component.literal("Execution interrupted!"));
}
ServerPlayer executor = getPlayerByUuid(attempt.executorUuid);
if (executor != null) {
executor.sendSystemMessage(Component.literal("Your execution was interrupted!"));
@@ -93,7 +87,6 @@ public class PlayerExecutionHandler {
@SubscribeEvent
public static void onLivingHurt(LivingHurtEvent event) {
if (!(event.getEntity() instanceof ServerPlayer hurtPlayer)) return;
UUID hurtId = hurtPlayer.getUUID();
boolean wasExecutor = executionAttempts.values().removeIf(attempt -> attempt.executorUuid.equals(hurtId));
if (wasExecutor) {
@@ -118,38 +111,28 @@ public class PlayerExecutionHandler {
@SubscribeEvent
public static void onServerTick(TickEvent.ServerTickEvent event) {
if (event.phase != TickEvent.Phase.END || !event.side.isServer()) return;
Map<UUID, PlayerExecutionAttempt> updated = new HashMap<>();
for (Map.Entry<UUID, PlayerExecutionAttempt> entry : executionAttempts.entrySet()) {
UUID knockedId = entry.getKey();
PlayerExecutionAttempt attempt = entry.getValue();
ServerPlayer knocked = getPlayerByUuid(knockedId);
ServerPlayer executor = getPlayerByUuid(attempt.executorUuid);
if (knocked == null || executor == null || !KnockedManager.isKnocked(knocked)) {
continue; // Invalid players or no longer knocked
continue;
}
// If out of range, cancel the execution
if (executor.distanceTo(knocked) > EXECUTION_RANGE) {
cancelExecution(knockedId);
continue;
}
attempt.timeLeft--;
NetworkHandler.CHANNEL.send(PacketDistributor.PLAYER.with(() -> executor), new ExecutionProgressPacket(attempt.timeLeft));
NetworkHandler.CHANNEL.send(PacketDistributor.PLAYER.with(() -> knocked), new ExecutionProgressPacket(attempt.timeLeft));
if (attempt.timeLeft <= 0) {
executeKnockedPlayer(executor, knocked);
} else {
updated.put(knockedId, attempt);
}
}
executionAttempts.clear();
executionAttempts.putAll(updated);
}