This code appears to be part of a raid management...
This code appears to be part of a raid management system in a Minecraft-related context, possibly for modifying or creating custom raids in the game. Here's what the code does step by step:
Context:
- The code seems to involve entities participating in a raid, such as Ravagers, Pillagers, Vindicators, Evokers, and Illusioners.
- It uses difficulty levels (
EASY
,NORMAL
,EXTREME
) to determine what type of entity to spawn. - The class likely extends classes related to raids in Minecraft, and this piece of code defines how entities are handled for a wave or group of the raid.
Code Behavior:
-
Check if Entity Type is a Ravager:
if (raid$raidertype.entityType == EntityType.RAVAGER) {
This checks whether the current entity involved in the raid is a Ravager (a large hostile mob in raids).
-
Spawn a Raider Based on Difficulty: Depending on the difficulty level and group (
i
), it decides what type of raider entity to spawn:- For EASY difficulty:
It creates a Pillager entity if the current group numberif (i == this.getNumGroups(Difficulty.EASY)) { raider1 = EntityType.PILLAGER.create(this.level, EntitySpawnReason.EVENT); }
i
matches the number of groups set for EASY difficulty. - For NORMAL difficulty:
It creates a Vindicator entity ifelse if (i == this.getNumGroups(Difficulty.NORMAL)) { raider1 = EntityType.VINDICATOR.create(this.level, EntitySpawnReason.EVENT); }
i
matches the number of groups assigned for NORMAL difficulty. - For EXTREME difficulty:
If the groupelse if (i >= this.getNumGroups(Difficulty.EXTREME)) { if (k == 0) { raider1 = EntityType.EVOKER.create(this.level, EntitySpawnReason.EVENT); } else { raider1 = EntityType.ILLUSIONER.create(this.level, EntitySpawnReason.EVENT); } }
i
matches or exceeds the EXTREME difficulty group count:- It spawns an Evoker (powerful raid mob) if
k == 0
. - Otherwise, it spawns an Illusioner. (The Illusioner is a hostile mob in Minecraft's game files but isn't used in the default game.)
- It spawns an Evoker (powerful raid mob) if
- For EASY difficulty:
-
Increment Counter (
k
):k++;
The variable
k
keeps track of the spawn cycle within this group. -
Handle the Spawned Raider:
if (raider1 != null) { this.joinRaid(i, raider1, p_37756_, false); raider1.moveTo(p_37756_, 0.0F, 0.0F); raider1.startRiding(raider); }
If a raider was created (
raider1 != null
):- The entity (
raider1
) is added to the raid usingjoinRaid
. - The mob's position is set using
moveTo
. - The spawned raider starts riding the Ravager (
startRiding
), possibly making the Ravager a mount for the raider.
- The entity (
-
Update Raid State: After the entity logic is complete:
this.waveSpawnPos = Optional.empty(); this.groupsSpawned++; this.updateBossbar(); this.setDirty();
- Clears the wave spawn position (
waveSpawnPos
). - Increments the
groupsSpawned
counter to note that one more group has spawned. - Updates the boss bar (likely a visual representation of the raid progress for players).
- Marks the raid data as dirty using
setDirty
, indicating that the raid's state should be saved or updated.
- Clears the wave spawn position (
Conclusion:
This code handles spawning and managing entities for a raid in Minecraft, with customization based on difficulty and group number. It spawns specific types of raid participants (Pillagers, Vindicators, Evokers, Illusioners) and makes use of mechanics like mounting entities (e.g., spawning a raider to ride a Ravager). After processing the current wave, it updates various raid-related records for ongoing raid management.