This method (`getPotentialBonusSpawns`) seems to calculate the number of potential...
This method (getPotentialBonusSpawns
) seems to calculate the number of potential "bonus spawns" based on various factors related to a raid event in some game. Here's an explanation of what it does:
-
Input Parameters:
p_219829_
refers to the type of a raider (the entity participating in the raid, such as VINDICATOR, PILLAGER, EVOKER, etc.).p_219830_
is a random number source (RandomSource
), which is used for generating random numbers.p_219831_
is some integer (possibly the wave or stage in the raid).p_219832_
is aDifficultyInstance
representing the difficulty of the game for this computation.p_219833_
is a boolean, though it is unused in the provided code.
-
Difficulty Flags:
- The difficulty of the game is retrieved using
p_219832_.getDifficulty()
. Based on the difficulty, the following flags are set:flag
:true
if the difficulty isEASY
.flag1
:true
if the difficulty isNORMAL
.flag2
:true
if the difficulty isEXTREME
(possibly the hardest difficulty level).
- The difficulty of the game is retrieved using
-
Spawner Logic by Raider Type: Depending on the raider type (
p_219829_
), the code determines how many bonus spawns might occur:-
For
VINDICATOR
orPILLAGER
:- If the difficulty is
EASY
, the number of potential bonus spawns is a random number between 0 and 1 (RandomSource.nextInt(2)
). - For
NORMAL
difficulty, the number of bonus spawns is1
. - Otherwise (e.g.,
HARD
orEXTREME
), it is2
.
- If the difficulty is
-
For
WITCH
:- If the difficulty is
EASY
or the value ofp_219831_
(likely wave number) is ≤ 5, equal to 8, or ≥ 11, no bonus spawns are granted (returns0
). - Otherwise,
1
spawn is possible. ForEXTREME
difficulty and certainp_219831_
values, an additional condition gives1
.
- If the difficulty is
-
For
RAVAGER
:- If the difficulty is
EASY
, or if thep_219831_
wave is ≤ 3 or ≥ 6, no bonus spawns are granted (returns0
). - Otherwise,
1
spawn is possible. ForEXTREME
difficulty and certainp_219831_
values (4
or5
), an additional condition grants1
.
- If the difficulty is
-
For
EVOKER
orILLUSIONER
(and any non-specified types):- Always returns
0
.
- Always returns
-
-
Randomization of Spawns: For raiders where a base number of potential bonus spawns (
i
) is calculated:- If
i > 0
, the method generates a random number between0
andi
(inclusive) usingp_219830_.nextInt(i + 1)
. - If
i <= 0
, it returns0
.
- If
What Does the Code Do?
This code determines the number of random "bonus spawns" that can occur during a raid based on:
- The type of the raider entity (e.g., VINDICATOR, WITCH, etc.).
- The game difficulty (
EASY
,NORMAL
,EXTREME
). - The raid wave or stage (
p_219831_
). - Randomized behavior, where applicable (
RandomSource.nextInt
).
The method uses specific logic for each type of raider. For example:
- VINDICATORS generally spawn more as the difficulty increases.
- WITCHES and RAVAGERS have stricter limitations based on the wave number.
- Certain raiders like EVOKER or ILLUSIONER never spawn bonus entities.
Finally, it randomizes the computed number of potential spawns and returns the result.