This code seems to be part of a Minecraft-like raid...
This code seems to be part of a Minecraft-like raid system, where entities (or mobs) are spawned in groups during a raid based on the current game difficulty level. Here's a breakdown of the functionality of this code:
-
Joining a raid:
this.joinRaid(i, raider, p_37756_, false);
- This line adds a "raider" (a hostile mob) to a specific raid wave (
i
) and likely sets its initial position or state in the raid.
- This line adds a "raider" (a hostile mob) to a specific raid wave (
-
Ravager-specific logic:
- The code checks if the current raider type is a
RAVAGER
. If true, it determines the type of supporting entity (raider1
) to spawn based on the current wave number (i
) and the game difficulty (Difficulty.EASY
,Difficulty.NORMAL
,Difficulty.HARD
,Difficulty.EXTREME
).
- The code checks if the current raider type is a
-
Entity creation:
- Depending on the difficulty and wave number, new entities (e.g.,
PILLAGER
,VINDICATOR
,EVOKER
,ILLUSIONER
) are created:- On EASY difficulty: A
PILLAGER
is created. - On NORMAL difficulty: A
VINDICATOR
is created. - On HARD difficulty (if
k < 1
): APILLAGER
is created. - On EXTREME difficulty (if
i >= this.getNumGroups(Difficulty.EXTREME)
andk > 4
): Multiple entities are created sequentially (EVOKER
,ILLUSIONER
,VINDICATOR
,PILLAGER
), overwritingraider1
each time (likely unintended, as later entities will replace the earlier ones).
- On EASY difficulty: A
- Depending on the difficulty and wave number, new entities (e.g.,
-
Handling spawned entities:
- If a supporting entity (
raider1
) is successfully created, it:- Joins the current raid wave (
this.joinRaid(i, raider1, p_37756_, false)
). - Is positioned at
p_37756_
usingraider1.moveTo(p_37756_, 0.0F, 0.0F)
. - Starts riding the
raider
(possibly implementing a mounting mechanic like mobs riding each other) usingraider1.startRiding(raider)
.
- Joins the current raid wave (
- If a supporting entity (
-
State updates after wave processing:
- After processing the wave:
- Clears the current spawn position (
this.waveSpawnPos = Optional.empty()
). - Increments the count of groups spawned (
this.groupsSpawned++
). - Updates the raid boss bar display (
this.updateBossbar()
). - Marks the raid state as dirty for persistence or further processing (
this.setDirty()
).
- Clears the current spawn position (
- After processing the wave:
Summary:
This code manages mob spawning during a raid. It determines what types of mobs to spawn based on the game difficulty and raid wave number. If a RAVAGER
is involved, it may also spawn escort mobs (PILLAGER
, VINDICATOR
, etc.) that can ride on the RAVAGER
. After completing mob spawning for the wave, it updates relevant raid state variables and the in-game boss bar.
However, there might be some issues in the code, such as overwriting raider1
multiple times in the EXTREME difficulty case, which may result in only the last entity being processed.