PreCreatureSpawnEvent fires before vanilla placement checks in isValidSpawnPostitionForType, inflating per-player mobBackoffCounts in air/water

オープン
#14,475 コメント 0 件 リアクション 1 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
68/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
java
領域
backend, game-dev

調査の方向性

Start in NaturalSpawner.isValidSpawnPostitionForType and trace how its return status reaches spawnCategoryForPosition and updateFailurePlayerMobTypeMap. Check the existing placement checks and PreCreatureSpawnEvent call order, then run the relevant spawning tests. Done means the event fires only after placement checks pass and invalid coordinates do not inflate player mob backoff counts.

索引モデルが issue の本文から書いたものです。

説明

status: needs triage version: 26.3
Expected behavior

In NaturalSpawner.isValidSpawnPostitionForType, PreCreatureSpawnEvent should only be called after the vanilla placement checks (SpawnPlacements.isSpawnPositionOk, SpawnPlacements.checkSpawnRules, level.noCollision) succeed, so that impossible mid-air/water coordinates return PreSpawnStatus.FAIL instead of triggering plugin cancellations and inflating mobBackoffCounts via updateFailurePlayerMobTypeMap.

Observed/Actual behavior

In NaturalSpawner.isValidSpawnPostitionForType (lines 387–406), PreCreatureSpawnEvent is fired at the very start of the method, before SpawnPlacements.isSpawnPositionOk, SpawnPlacements.checkSpawnRules, and level.noCollision:

  1. NaturalSpawner.getRandomPosWithin picks a random (x, y, z) between minY and the highest block in the chunk.
  2. isValidSpawnPostitionForType immediately fires PreCreatureSpawnEvent even if pos is mid-air (void) or water where the chosen mob could never spawn.
  3. When a plugin (such as WorldGuard with regions.use-pre-creature-spawn-event: true and mob-spawning: deny) cancels the event, isValidSpawnPostitionForType returns PreSpawnStatus.CANCELLED.
  4. NaturalSpawner.spawnCategoryForPosition (line 303) then calls chunkMap.updateFailurePlayerMobTypeMap, incrementing ServerPlayer.mobBackoffCounts for every random mid-air/water hit.
  5. As a result, /paper playermobcaps immediately maxes out (e.g. 70/70 monsters with 0 actual monsters in the world) and completely starves natural spawning in valid areas above/outside the region.

Moving the PreCreatureSpawnEvent call to the end of isValidSpawnPostitionForType (after the boolean placement checks pass) still avoids entity instantiation (getMobForSpawn / finalizeSpawn), avoids spamming plugins with thousands of mid-air events, and prevents false backoff inflation.

Steps/models to reproduce
  1. Start a Paper server with WorldGuard installed and set regions.use-pre-creature-spawn-event: true in plugins/WorldGuard/config.yml (WorldGuard had to disable this by default in 7.0.20 due to this exact issue, see EngineHub/WorldGuard#2314).
  2. Create a flat water world (/mv create waterworld normal -t FLAT -gs {"biome":"minecraft:ocean","layers":[{"block":"minecraft:water","height":128}]}) or a Skyblock/void world.
  3. Create a WorldGuard region covering the water/air layer (-200, -64, -200 to 200, 64, 200) with mob-spawning: deny.
  4. Build a closed dark stone box above the region (e.g. from -50, 70, -50 to 50, 100, 50) and stand near it.
  5. Check /paper playermobcaps: the MONSTER cap is permanently full via mobBackoffCounts with 0 real monsters, and almost nothing spawns in the dark box.
Plugin and Datapack List

Plugins (3): Multiverse-Core, WorldEdit, WorldGuard
Datapacks: vanilla, paper

Paper version

This server is running Paper version 26.3-248-main@0727243 (2026-11-10T11:35:52Z) (Implementing API version 26.3.build.248-stable)
You are running the latest version

Other

Related WorldGuard issue: https://github.com/EngineHub/WorldGuard/issues/2314

主要言語
Java
スター
12.8k
フォーク
3.6k
平均マージ
3日 7時間
マージ済み PR(30日)
19

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

PaperMC/Paper のほかの issue

PaperMC/Paper の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。