This method, `getPotentialBonusSpawns`, appears to determine the number of "bonus...
This method, getPotentialBonusSpawns
, appears to determine the number of "bonus spawns" (or additional entity spawns) for a raid in a game-like simulation. Here's a breakdown of what the code does:
Parameters:
p_219829_
: The type of raider/monster (Raid.RaiderType
), such as Vindicator, Pillager, Witch, Ravager, etc.p_219830_
: A random number generator (RandomSource
) used to calculate chance-based values.p_219831_
: Presumably the wave level or current progress of the raid (wave number, raid phase, or similar).p_219832_
: The difficulty of the instance (DifficultyInstance
), which determines how challenging the scenario is.p_219833_
: A boolean flag likely related to some external condition (not used in the method, though).
Functionality:
The goal of the method is to determine a random number of additional ("bonus") spawns for given raider types, based on the difficulty, raid wave, and type of raider. Here's how it works:
-
Difficulty Determination:
- It retrieves the current
Difficulty
fromp_219832_
and sets flags forEASY
,NORMAL
, and an assumed more challengingEXTREME
difficulty.
- It retrieves the current
-
Switch Statement on
p_219829_
(Raider Type):-
The method branches its behavior based on the type of raider.
-
VINDICATOR
andPILLAGER
:- Depending on the difficulty:
- For
EASY
orEXTREME
, it randomly selects0
or1
bonus spawns. - For
NORMAL
, it adds exactly1
spawn. - Otherwise, it adds
2
spawns.
- For
- Depending on the difficulty:
-
EVOKER
andDefault
:- These cases always return
0
, meaning no bonus spawns are generated for these types.
- These cases always return
-
WITCH
:- For
EASY
,EXTREME
, or if the wave (p_219831_
) is<=5
,==7
, or>=11
, this returns0
, meaning no bonus spawns. - Otherwise, it adds
1
spawn.
- For
-
RAVAGER
:- For
EASY
,EXTREME
, or if the wave (p_219831_
) is>=6
, this returns0
, meaning no bonus spawns. - Otherwise, it adds
1
spawn.
- For
-
-
Final Calculation and Return:
- If the calculated
i
(number of possible bonus spawns) is greater than0
, it generates a random number between0
andi
(inclusive) using the random generator (p_219830_
). - Otherwise, it simply returns
0
.
- If the calculated
Example Output:
- For a
PILLAGER
onEASY
difficulty, the result will always be a random number between0
and1
. - For a
WITCH
on wave 4 (and not inEASY
orEXTREME
), the result will be exactly1
.
Summary:
The method calculates the potential number of bonus spawns for a raid wave based on difficulty, raider type, and wave number. The calculation involves:
- Determining the conditional maximum bonus spawns (
i
) for various raider types. - Using the random generator to return a random number of spawns between
0
andi
.