diff --git a/src/main/java/net/neoforged/neoforge/common/CommonHooks.java b/src/main/java/net/neoforged/neoforge/common/CommonHooks.java index a57b8c7a5f..dd63e6a209 100644 --- a/src/main/java/net/neoforged/neoforge/common/CommonHooks.java +++ b/src/main/java/net/neoforged/neoforge/common/CommonHooks.java @@ -184,7 +184,11 @@ import net.neoforged.neoforge.event.entity.living.LivingUseTotemEvent; import net.neoforged.neoforge.event.entity.living.MobEffectEvent; import net.neoforged.neoforge.event.entity.living.ShieldBlockEvent; -import net.neoforged.neoforge.event.entity.player.*; +import net.neoforged.neoforge.event.entity.player.AnvilRepairEvent; +import net.neoforged.neoforge.event.entity.player.AttackEntityEvent; +import net.neoforged.neoforge.event.entity.player.CriticalHitEvent; +import net.neoforged.neoforge.event.entity.player.PlayerChangeGameModeEvent; +import net.neoforged.neoforge.event.entity.player.PlayerInteractEvent; import net.neoforged.neoforge.event.level.BlockDropsEvent; import net.neoforged.neoforge.event.level.BlockEvent; import net.neoforged.neoforge.event.level.NoteBlockEvent; diff --git a/src/main/java/net/neoforged/neoforge/common/NeoForgeEventHandler.java b/src/main/java/net/neoforged/neoforge/common/NeoForgeEventHandler.java index 0548e3cdd8..7220e61383 100644 --- a/src/main/java/net/neoforged/neoforge/common/NeoForgeEventHandler.java +++ b/src/main/java/net/neoforged/neoforge/common/NeoForgeEventHandler.java @@ -32,7 +32,6 @@ import net.neoforged.neoforge.event.TagsUpdatedEvent; import net.neoforged.neoforge.event.entity.EntityJoinLevelEvent; import net.neoforged.neoforge.event.entity.player.PlayerLoggedInEvent; -import net.neoforged.neoforge.event.entity.player.ServerPlayerEvent; import net.neoforged.neoforge.event.level.ChunkEvent; import net.neoforged.neoforge.event.level.LevelEvent; import net.neoforged.neoforge.event.tick.ServerTickEvent; diff --git a/src/main/java/net/neoforged/neoforge/event/EventHooks.java b/src/main/java/net/neoforged/neoforge/event/EventHooks.java index 3aaccf2886..c4259ed831 100644 --- a/src/main/java/net/neoforged/neoforge/event/EventHooks.java +++ b/src/main/java/net/neoforged/neoforge/event/EventHooks.java @@ -137,10 +137,29 @@ import net.neoforged.neoforge.event.entity.living.MobSpawnEvent.SpawnPlacementCheck; import net.neoforged.neoforge.event.entity.living.MobSplitEvent; import net.neoforged.neoforge.event.entity.living.SpawnClusterSizeEvent; -import net.neoforged.neoforge.event.entity.player.*; import net.neoforged.neoforge.event.entity.player.AdvancementEvent.AdvancementEarnEvent; import net.neoforged.neoforge.event.entity.player.AdvancementEvent.AdvancementProgressEvent; import net.neoforged.neoforge.event.entity.player.AdvancementEvent.AdvancementProgressEvent.ProgressType; +import net.neoforged.neoforge.event.entity.player.ArrowLooseEvent; +import net.neoforged.neoforge.event.entity.player.ArrowNockEvent; +import net.neoforged.neoforge.event.entity.player.BonemealEvent; +import net.neoforged.neoforge.event.entity.player.CanContinueSleepingEvent; +import net.neoforged.neoforge.event.entity.player.CanPlayerSleepEvent; +import net.neoforged.neoforge.event.entity.player.ItemEntityPickupEvent; +import net.neoforged.neoforge.event.entity.player.ItemTooltipEvent; +import net.neoforged.neoforge.event.entity.player.PermissionsChangedEvent; +import net.neoforged.neoforge.event.entity.player.PlayerChangedDimensionEvent; +import net.neoforged.neoforge.event.entity.player.PlayerDestroyItemEvent; +import net.neoforged.neoforge.event.entity.player.PlayerEvent; +import net.neoforged.neoforge.event.entity.player.PlayerFlyableFallEvent; +import net.neoforged.neoforge.event.entity.player.PlayerHeartTypeEvent; +import net.neoforged.neoforge.event.entity.player.PlayerLoggedInEvent; +import net.neoforged.neoforge.event.entity.player.PlayerLoggedOutEvent; +import net.neoforged.neoforge.event.entity.player.PlayerRespawnEvent; +import net.neoforged.neoforge.event.entity.player.PlayerRespawnPositionEvent; +import net.neoforged.neoforge.event.entity.player.PlayerSetSpawnEvent; +import net.neoforged.neoforge.event.entity.player.PlayerSpawnPhantomsEvent; +import net.neoforged.neoforge.event.entity.player.PlayerWakeUpEvent; import net.neoforged.neoforge.event.furnace.FurnaceFuelBurnTimeEvent; import net.neoforged.neoforge.event.level.AlterGroundEvent; import net.neoforged.neoforge.event.level.AlterGroundEvent.StateProvider; @@ -561,7 +580,7 @@ public static void onPlayerFall(Player player, float distance, float multiplier) NeoForge.EVENT_BUS.post(new PlayerFlyableFallEvent(player, distance, multiplier)); } - public static boolean onPlayerSpawnSet(Player player, ResourceKey levelKey, BlockPos pos, boolean forced) { + public static boolean onPlayerSpawnSet(ServerPlayer player, ResourceKey levelKey, BlockPos pos, boolean forced) { return NeoForge.EVENT_BUS.post(new PlayerSetSpawnEvent(player, levelKey, pos, forced)).isCanceled(); } diff --git a/src/main/java/net/neoforged/neoforge/event/entity/player/PermissionsChangedEvent.java b/src/main/java/net/neoforged/neoforge/event/entity/player/PermissionsChangedEvent.java index 5b4c9e0c2c..61d592a92b 100644 --- a/src/main/java/net/neoforged/neoforge/event/entity/player/PermissionsChangedEvent.java +++ b/src/main/java/net/neoforged/neoforge/event/entity/player/PermissionsChangedEvent.java @@ -6,7 +6,6 @@ package net.neoforged.neoforge.event.entity.player; import net.minecraft.server.level.ServerPlayer; -import net.minecraft.world.entity.player.Player; import net.neoforged.bus.api.ICancellableEvent; /** diff --git a/src/main/java/net/neoforged/neoforge/event/entity/player/PlayerChangedDimensionEvent.java b/src/main/java/net/neoforged/neoforge/event/entity/player/PlayerChangedDimensionEvent.java index 57bdae745e..dc96fb6f92 100644 --- a/src/main/java/net/neoforged/neoforge/event/entity/player/PlayerChangedDimensionEvent.java +++ b/src/main/java/net/neoforged/neoforge/event/entity/player/PlayerChangedDimensionEvent.java @@ -12,6 +12,7 @@ public class PlayerChangedDimensionEvent extends ServerPlayerEvent { private final ResourceKey originalDimension; private final ResourceKey newDimension; + public PlayerChangedDimensionEvent(ServerPlayer player, ResourceKey originalDimension, ResourceKey newDimension) { super(player); this.originalDimension = originalDimension; diff --git a/src/main/java/net/neoforged/neoforge/event/entity/player/PlayerSetSpawnEvent.java b/src/main/java/net/neoforged/neoforge/event/entity/player/PlayerSetSpawnEvent.java index 7ff59acf84..65500e2bc4 100644 --- a/src/main/java/net/neoforged/neoforge/event/entity/player/PlayerSetSpawnEvent.java +++ b/src/main/java/net/neoforged/neoforge/event/entity/player/PlayerSetSpawnEvent.java @@ -7,7 +7,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.resources.ResourceKey; -import net.minecraft.world.entity.player.Player; +import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.level.Level; import net.neoforged.bus.api.ICancellableEvent; import org.jetbrains.annotations.Nullable; @@ -16,13 +16,13 @@ * This event is fired when a player's spawn point is set or reset.
* The event can be canceled, which will prevent the spawn point from being changed. */ -public class PlayerSetSpawnEvent extends PlayerEvent implements ICancellableEvent { +public class PlayerSetSpawnEvent extends ServerPlayerEvent implements ICancellableEvent { private final ResourceKey spawnLevel; private final boolean forced; @Nullable private final BlockPos newSpawn; - public PlayerSetSpawnEvent(Player player, ResourceKey spawnLevel, @Nullable BlockPos newSpawn, boolean forced) { + public PlayerSetSpawnEvent(ServerPlayer player, ResourceKey spawnLevel, @Nullable BlockPos newSpawn, boolean forced) { super(player); this.spawnLevel = spawnLevel; this.newSpawn = newSpawn; diff --git a/src/main/java/net/neoforged/neoforge/event/entity/player/ServerPlayerEvent.java b/src/main/java/net/neoforged/neoforge/event/entity/player/ServerPlayerEvent.java index 932558f199..96cab2ec29 100644 --- a/src/main/java/net/neoforged/neoforge/event/entity/player/ServerPlayerEvent.java +++ b/src/main/java/net/neoforged/neoforge/event/entity/player/ServerPlayerEvent.java @@ -15,4 +15,4 @@ protected ServerPlayerEvent(ServerPlayer entity) { public ServerPlayer getEntity() { return ((ServerPlayer) super.getEntity()); } -} \ No newline at end of file +} diff --git a/testframework/src/main/java/net/neoforged/testframework/impl/TestFrameworkImpl.java b/testframework/src/main/java/net/neoforged/testframework/impl/TestFrameworkImpl.java index 3b438573b8..e726e1ec4e 100644 --- a/testframework/src/main/java/net/neoforged/testframework/impl/TestFrameworkImpl.java +++ b/testframework/src/main/java/net/neoforged/testframework/impl/TestFrameworkImpl.java @@ -45,7 +45,6 @@ import net.neoforged.neoforge.event.RegisterGameTestsEvent; import net.neoforged.neoforge.event.entity.player.PlayerLoggedInEvent; import net.neoforged.neoforge.event.entity.player.PlayerLoggedOutEvent; -import net.neoforged.neoforge.event.entity.player.ServerPlayerEvent; import net.neoforged.neoforge.event.server.ServerStartedEvent; import net.neoforged.neoforge.event.server.ServerStoppedEvent; import net.neoforged.neoforge.network.PacketDistributor; diff --git a/tests/src/main/java/net/neoforged/neoforge/debug/entity/player/PlayerEventTests.java b/tests/src/main/java/net/neoforged/neoforge/debug/entity/player/PlayerEventTests.java index c6cbe59de7..bf29f12616 100644 --- a/tests/src/main/java/net/neoforged/neoforge/debug/entity/player/PlayerEventTests.java +++ b/tests/src/main/java/net/neoforged/neoforge/debug/entity/player/PlayerEventTests.java @@ -31,7 +31,14 @@ import net.minecraft.world.level.portal.DimensionTransition; import net.neoforged.bus.api.EventPriority; import net.neoforged.neoforge.event.StatAwardEvent; -import net.neoforged.neoforge.event.entity.player.*; +import net.neoforged.neoforge.event.entity.player.ItemEntityPickupEvent; +import net.neoforged.neoforge.event.entity.player.PermissionsChangedEvent; +import net.neoforged.neoforge.event.entity.player.PlayerChangeGameModeEvent; +import net.neoforged.neoforge.event.entity.player.PlayerEvent; +import net.neoforged.neoforge.event.entity.player.PlayerInteractEvent; +import net.neoforged.neoforge.event.entity.player.PlayerRespawnEvent; +import net.neoforged.neoforge.event.entity.player.PlayerRespawnPositionEvent; +import net.neoforged.neoforge.event.entity.player.UseItemOnBlockEvent; import net.neoforged.testframework.DynamicTest; import net.neoforged.testframework.annotation.ForEachTest; import net.neoforged.testframework.annotation.TestHolder;