1
0
Fork 0
mirror of https://github.com/PaperMC/Paper.git synced 2025-03-20 22:18:58 +01:00

Prevent duplicate raider in RaidSpawnWaveEvent list ()

This commit is contained in:
Lulu13022002 2025-02-08 20:55:57 +01:00 committed by GitHub
parent cb6c57e0f8
commit 51acc802b8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 16 additions and 38 deletions
paper-server
patches/sources/net/minecraft/world/entity/raid
src/main/java/org/bukkit/craftbukkit/event

View file

@ -99,42 +99,20 @@
this.stop();
return;
}
@@ -491,6 +_,10 @@
@@ -486,7 +_,7 @@
private void spawnGroup(BlockPos pos) {
boolean flag = false;
- int i = this.groupsSpawned + 1;
+ int i = this.groupsSpawned + 1; final int wave = i; // Paper - OBFHELPER
this.totalHealth = 0.0F;
DifficultyInstance currentDifficultyAt = this.level.getCurrentDifficultyAt(pos);
boolean shouldSpawnBonusGroup = this.shouldSpawnBonusGroup();
+ // CraftBukkit start
+ Raider leader = null;
+ List<Raider> raiders = new java.util.ArrayList<>();
+ // CraftBukkit end
for (Raid.RaiderType raiderType : Raid.RaiderType.VALUES) {
int i1 = this.getDefaultNumSpawns(raiderType, i, shouldSpawnBonusGroup)
+ this.getPotentialBonusSpawns(raiderType, this.random, i, currentDifficultyAt, shouldSpawnBonusGroup);
@@ -506,9 +_,11 @@
raider.setPatrolLeader(true);
this.setLeader(i, raider);
flag = true;
+ leader = raider; // CraftBukkit
}
this.joinRaid(i, raider, pos, false);
+ raiders.add(raider); // CraftBukkit
if (raiderType.entityType == EntityType.RAVAGER) {
Raider raider1 = null;
if (i == this.getNumGroups(Difficulty.NORMAL)) {
@@ -526,6 +_,7 @@
this.joinRaid(i, raider1, pos, false);
raider1.moveTo(pos, 0.0F, 0.0F);
raider1.startRiding(raider);
+ raiders.add(raider); // CraftBukkit
}
}
}
@@ -535,6 +_,7 @@
this.groupsSpawned++;
this.updateBossbar();
this.setDirty();
+ org.bukkit.craftbukkit.event.CraftEventFactory.callRaidSpawnWaveEvent(this, leader, raiders); // CraftBukkit
+ org.bukkit.craftbukkit.event.CraftEventFactory.callRaidSpawnWaveEvent(this, java.util.Objects.requireNonNull(this.getLeader(wave)), this.groupRaiderMap.get(wave)); // CraftBukkit
}
public void joinRaid(int wave, Raider raider, @Nullable BlockPos pos, boolean isRecruited) {

View file

@ -12,6 +12,7 @@ import java.util.Collections;
import java.util.EnumMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.annotation.Nullable;
@ -87,7 +88,6 @@ import org.bukkit.craftbukkit.damage.CraftDamageSource;
import org.bukkit.craftbukkit.entity.CraftEntity;
import org.bukkit.craftbukkit.entity.CraftLivingEntity;
import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.craftbukkit.entity.CraftRaider;
import org.bukkit.craftbukkit.entity.CraftSpellcaster;
import org.bukkit.craftbukkit.inventory.CraftInventoryCrafting;
import org.bukkit.craftbukkit.inventory.CraftItemStack;
@ -2015,14 +2015,14 @@ public class CraftEventFactory {
Bukkit.getPluginManager().callEvent(event);
}
public static void callRaidSpawnWaveEvent(Raid raid, net.minecraft.world.entity.raid.Raider leader, List<net.minecraft.world.entity.raid.Raider> raiders) {
Raider craftLeader = (CraftRaider) leader.getBukkitEntity();
List<Raider> craftRaiders = new ArrayList<>();
for (net.minecraft.world.entity.raid.Raider entityRaider : raiders) {
craftRaiders.add((Raider) entityRaider.getBukkitEntity());
public static void callRaidSpawnWaveEvent(Raid raid, net.minecraft.world.entity.raid.Raider leader, Set<net.minecraft.world.entity.raid.Raider> raiders) {
Raider bukkitLeader = (Raider) leader.getBukkitEntity();
List<Raider> bukkitRaiders = new ArrayList<>(raiders.size());
for (net.minecraft.world.entity.raid.Raider raider : raiders) {
bukkitRaiders.add((Raider) raider.getBukkitEntity());
}
RaidSpawnWaveEvent event = new RaidSpawnWaveEvent(new CraftRaid(raid), raid.getLevel().getWorld(), craftLeader, craftRaiders);
Bukkit.getPluginManager().callEvent(event);
RaidSpawnWaveEvent event = new RaidSpawnWaveEvent(new CraftRaid(raid), raid.getLevel().getWorld(), bukkitLeader, bukkitRaiders);
event.callEvent();
}
public static LootGenerateEvent callLootGenerateEvent(Container inventory, LootTable lootTable, LootContext lootInfo, List<ItemStack> loot, boolean plugin) {