This code is part of a Minecraft-related implementation that seems...
This code is part of a Minecraft-related implementation that seems to control the spawning behavior of entities during a raid, specifically handling situations where a Ravager (EntityType.RAVAGER
) is involved. Here's a breakdown of what the code does:
-
Conditional Check: The code first checks if a particular raider's type (
raid$raidertype.entityType
) matches theEntityType.RAVAGER
. -
Raider Entity Creation Based on Difficulty:
- Based on the wave number (
i
) and its comparison with a number of groups associated with different difficulties (Difficulty.EASY
,Difficulty.NORMAL
,Difficulty.HARD
), it decides what type of entities (PILLAGER
,VINDICATOR
, etc.) to spawn. - For extreme conditions, determined by
Difficulty.EXTREME
and whetheri >= this.getNumGroups(Difficulty.EXTREME)
, it spawns multiple entities, including more powerful ones likeEVOKER
,ILLUSIONER
, andVINDICATOR
.
- Based on the wave number (
-
Entity Creation:
- It attempts to create these new entities using the
EntityType.<type>.create()
method, passing parameters like the level (this.level
) and spawn reason (EntitySpawnReason.EVENT
).
- It attempts to create these new entities using the
-
Entity Joining the Raid:
- If new entities (
raider1
,raider2
,raider3
,raider4
) are successfully created:- They are added to the raid using
this.joinRaid()
. - Their positions are set using
moveTo(p_37756_, 0.0F, 0.0F)
(wherep_37756_
might represent the spawn position). - Each of the new entities is made to ride the
raider
(presumably the Ravager in this case) using.startRiding(raider)
.
- They are added to the raid using
- If new entities (
-
Wave Tracking:
- After the spawn logic, it performs wave tracking and raid progression:
this.waveSpawnPos = Optional.empty();
clears the spawn position.this.groupsSpawned++;
increments the spawned group counter.this.updateBossbar();
updates the raid boss bar (the visible raid progress bar).this.setDirty();
marks the raid state as dirty, likely prompting a save or update to the game state.
- After the spawn logic, it performs wave tracking and raid progression:
Summary
The code defines how additional raiders are spawned and joined to ride a Ravager during a raid, with the specific entities spawned depending on the raid difficulty (EASY
, NORMAL
, HARD
, EXTREME
) and wave progression (i
). It also handles raid progression mechanics such as updating the boss bar and tracking spawn groups.