The provided code appears to reside within a Minecraft-like mod...
The provided code appears to reside within a Minecraft-like mod or custom game codebase—it deals with raids and spawns of raider entities, such as Pillagers, Vindicators, Evokers, Illusioners, and Ravagers. Here's what the code does, step by step:
High-level Description:
-
Condition Check: The code begins by checking if the current raid involves a Ravager type (
raid$raidertype.entityType == EntityType.RAVAGER
). If this condition isn't met, none of the following code will execute. -
Raider Initialization: Four variables,
raider1
,raider2
,raider3
, andraider4
, are initialized asnull
. These will later hold specific raider entities depending on the conditions. -
Difficulty-Based Spawning:
- The code uses the value
i
(likely representing the current wave or group number in the raid) compared against thresholds for different difficulty levels (EASY
,NORMAL
,HARD
,EXTREME
). - Based on the current wave and difficulty:
- For EASY, it spawns a
PILLAGER
. - For NORMAL, it spawns a
VINDICATOR
. - For HARD, it spawns two raiders: a
PILLAGER
and aVINDICATOR
. - For EXTREME (a hypothetical higher difficulty level), additional raiders (
EVOKER
,ILLUSIONER
,VINDICATOR
,PILLAGER
) are spawned, provided certain conditions (k >= 0
) are met.
- For EASY, it spawns a
- The code uses the value
-
Joining a Raid:
- The spawned raiders (if not
null
) are added to the raid using thethis.joinRaid(...)
method. This associates the raiders with the current raid wave and positions them at a specified location (p_37756_
). - The raiders are also mounted on the Ravager (
raider.startRiding(raider);
), making them appear as if they're riding the larger Ravager entity.
- The spawned raiders (if not
-
Increment Counters:
- The variable
k
is incremented as raiders are processed, possibly tracking the number of spawned raiders or some other counter.
- The variable
-
Wave Management:
- After handling all the raiders in one wave:
this.waveSpawnPos
is reset toOptional.empty()
(clearing the spawn position).this.groupsSpawned
is incremented, tracking how many groups of raiders have spawned so far.- Methods like
this.updateBossbar()
andthis.setDirty()
update the raid boss bar and mark the raid state as dirty (needing to be saved/updated).
- After handling all the raiders in one wave:
In Summary:
This code manages the spawning of raiders during a raid when a Ravager is present. It dynamically spawns raider entities based on the current raid group (i
) and game difficulty. The spawned raiders are then added to the raid, positioned on the map, and potentially made to ride the Ravager.
Lastly, it updates the raid progress by incrementing the spawned group count, updating the UI (boss bar), and marking the raid state for further processing.