2525package org .spongepowered .common .raid ;
2626
2727
28+ import net .minecraft .server .level .ServerLevel ;
2829import org .spongepowered .api .entity .living .monster .raider .Raider ;
2930import org .spongepowered .api .raid .Raid ;
3031import org .spongepowered .api .raid .RaidWave ;
@@ -56,11 +57,7 @@ public boolean isBonus() {
5657 * If the wave is not a final wave, the bonus waves occur after the final wave.
5758 * If our wave was before the final wave, the amount of normal raids (which is set by the difficulty) would be greater than our wave's id.
5859 */
59- if (this .isFinal () || this .waveId < ((RaidAccessor ) this .raid ).accessor$numGroups ()) {
60- return false ;
61- }
62-
63- return true ;
60+ return !this .isFinal () && this .waveId >= ((RaidAccessor ) this .raid ).accessor$numGroups ();
6461 }
6562
6663 @ Override
@@ -78,14 +75,18 @@ public Optional<Raider> leader() {
7875 @ Override
7976 public boolean addRaider (Raider raider , boolean addToRaidHealth ) {
8077 Objects .requireNonNull (raider , "Raider cannot be null." );
81- return this .raid .addWaveMob (this .waveId , (net .minecraft .world .entity .raid .Raider ) raider , addToRaidHealth );
78+ // We only support adding raiders to server worlds
79+ if (raider .world () instanceof ServerLevel sl ) {
80+ return this .raid .addWaveMob (sl , this .waveId , (net .minecraft .world .entity .raid .Raider ) raider , addToRaidHealth );
81+ }
82+ return false ;
8283 }
8384
8485 @ Override
8586 public boolean removeRaider (Raider raider ) {
8687 Objects .requireNonNull (raider , "Raider cannot be null." );
87- if (raider .raidWave ().isPresent () && this .equals (raider .raidWave ().get ().get ())) {
88- this .raid .removeFromRaid ((net .minecraft .world .entity .raid .Raider ) raider , true );
88+ if (raider .raidWave ().isPresent () && this .equals (raider .raidWave ().get ().get ()) && raider . world () instanceof ServerLevel sl ) {
89+ this .raid .removeFromRaid (sl , (net .minecraft .world .entity .raid .Raider ) raider , true );
8990 return true ;
9091 }
9192
@@ -94,11 +95,10 @@ public boolean removeRaider(Raider raider) {
9495
9596 @ Override
9697 public boolean equals (Object obj ) {
97- if (obj instanceof SpongeRaidWave ) {
98- SpongeRaidWave other = (SpongeRaidWave ) obj ;
98+ if (obj instanceof SpongeRaidWave other ) {
9999 // Minecraft Tracks it's raids via an ID which is handled by the RaidManager.
100100 // Each world has it's own raid manager so we have to verify that the world the raids are in is also equal.
101- if (this .waveId == other .waveId && this .raid . getLevel () == other .raid . getLevel () && this .raid .getId () == other .raid .getId ()) {
101+ if (this .waveId == other .waveId && this .raid == other .raid && this .raid .getCenter () == other .raid .getCenter ()) {
102102 return true ;
103103 }
104104 }
0 commit comments