This code appears to be part of a system related...
This code appears to be part of a system related to managing raids in a game, most likely Minecraft, as it uses familiar terms like "Raid" and "RaiderType." Here's what the individual methods do:
1. getDefaultNumSpawns
private int getDefaultNumSpawns(Raid.RaiderType p_37731_, int p_37732_, boolean p_37733_) {
return p_37733_ ? p_37731_.spawnsPerWaveBeforeBonus[this.numGroups] : p_37731_.spawnsPerWaveBeforeBonus[p_37732_];
}
This method computes the default number of mobs ("spawns") for a specific raider type in a raid wave.
-
Parameters:
p_37731_
: The type of raider (e.g., VINDICATOR, PILLAGER).p_37732_
: An index or a specific wave number.p_37733_
: A boolean flag that determines whether to usethis.numGroups
(an object field) orp_37732_
as the index.
-
Logic:
- If
p_37733_
istrue
, it usesthis.numGroups
to access the raider's spawn count in thespawnsPerWaveBeforeBonus
array. - Otherwise, it uses the value of
p_37732_
to retrieve the spawn count.
- If
-
Purpose: This method is used to retrieve the baseline number of raiders of a given type that spawn in a specific wave of a raid (before applying any bonuses).
2. getPotentialBonusSpawns
private int getPotentialBonusSpawns(Raid.RaiderType p_219829_, RandomSource p_219830_, int p_219831_, DifficultyInstance p_219832_, boolean p_219833_) {
// ...
}
This method computes the potential additional spawns for a raider type in a raid wave, based on the game's difficulty and the wave number.
-
Parameters:
p_219829_
: The type of raider (e.g., VINDICATOR, WITCH).p_219830_
: A random number source used to generate random bonus spawns.p_219831_
: The current wave number in the raid.p_219832_
: ADifficultyInstance
object that represents the current game difficulty (EASY, NORMAL, EXTREME, etc.).p_219833_
: A boolean flag (not explicitly used in the current code).
-
Logic:
- It begins by determining the current game difficulty (
Difficulty
) and sets flags forEASY
,NORMAL
, andEXTREME
difficulties. - A
switch
statement handles the logic for each raider type:- VINDICATOR and PILLAGER:
- If difficulty is EASY, it allows a 0 or 1 bonus spawn (
nextInt(2)
). - If NORMAL, it grants 1 bonus spawn.
- Otherwise, it grants 2 bonus spawns.
- If difficulty is EASY, it allows a 0 or 1 bonus spawn (
- EVOKER and ILLUSIONER: No bonus spawns are added (
return 0
). - WITCH:
- Some specific rules are based on wave numbers. Bonus spawns are not allowed for certain waves (e.g., ≤5, ==8, ≥11).
- In EXTREME difficulty (
flag2
), additional conditions apply for waves ≥5 to generate a bonus spawn.
- RAVAGER:
- No bonus spawns are allowed for wave numbers ≤3 or ≥6.
- In EXTREME difficulty, it checks specific waves (4 or 5) to allow a bonus spawn.
- VINDICATOR and PILLAGER:
- It begins by determining the current game difficulty (
-
Purpose: This method determines the random bonus spawns to add to the default number of raiders in a raid wave. The decision depends on raider type, wave number, and difficulty.
3. isActive
public boolean isActive() {
return this.active;
}
This is a straightforward method that returns whether the raid is currently active.
Overall Functionality:
The code is responsible for determining the number of mobs that spawn during a raid in a game, based on the raider type, wave number, and difficulty. It also provides a way to check the raid's active status.