diff options
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/world/entity/raid/Raid.java.patch')
-rw-r--r-- | patch-remap/mache-spigotflower/net/minecraft/world/entity/raid/Raid.java.patch | 805 |
1 files changed, 805 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/world/entity/raid/Raid.java.patch b/patch-remap/mache-spigotflower/net/minecraft/world/entity/raid/Raid.java.patch new file mode 100644 index 0000000000..a9036dbc86 --- /dev/null +++ b/patch-remap/mache-spigotflower/net/minecraft/world/entity/raid/Raid.java.patch @@ -0,0 +1,805 @@ +--- a/net/minecraft/world/entity/raid/Raid.java ++++ b/net/minecraft/world/entity/raid/Raid.java +@@ -41,10 +41,10 @@ + import net.minecraft.world.effect.MobEffects; + import net.minecraft.world.entity.Entity; + import net.minecraft.world.entity.EntityType; ++import net.minecraft.world.entity.EnumMobSpawn; + import net.minecraft.world.entity.EquipmentSlot; ++import net.minecraft.world.entity.GroupDataEntity; + import net.minecraft.world.entity.LivingEntity; +-import net.minecraft.world.entity.MobSpawnType; +-import net.minecraft.world.entity.SpawnGroupData; + import net.minecraft.world.entity.SpawnPlacements; + import net.minecraft.world.entity.player.Player; + import net.minecraft.world.item.BlockItem; +@@ -88,65 +88,65 @@ + public static final int RAID_REMOVAL_THRESHOLD_SQR = 12544; + private final Map<Integer, Raider> groupToLeaderMap = Maps.newHashMap(); + private final Map<Integer, Set<Raider>> groupRaiderMap = Maps.newHashMap(); +- private final Set<UUID> heroesOfTheVillage = Sets.newHashSet(); +- private long ticksActive; ++ public final Set<UUID> heroesOfTheVillage = Sets.newHashSet(); ++ public long ticksActive; + private BlockPos center; + private final ServerLevel level; + private boolean started; + private final int id; +- private float totalHealth; +- private int badOmenLevel; ++ public float totalHealth; ++ public int badOmenLevel; + private boolean active; + private int groupsSpawned; + private final ServerBossEvent raidEvent; + private int postRaidTicks; + private int raidCooldownTicks; + private final RandomSource random; +- private final int numGroups; ++ public final int numGroups; + private Raid.RaidStatus status; + private int celebrationTicks; + private Optional<BlockPos> waveSpawnPos; + +- public Raid(int i, ServerLevel serverlevel, BlockPos blockpos) { ++ public Raid(int id, ServerLevel level, BlockPos center) { + this.raidEvent = new ServerBossEvent(Raid.RAID_NAME_COMPONENT, BossEvent.BossBarColor.RED, BossEvent.BossBarOverlay.NOTCHED_10); + this.random = RandomSource.create(); + this.waveSpawnPos = Optional.empty(); +- this.id = i; +- this.level = serverlevel; ++ this.id = id; ++ this.level = level; + this.active = true; + this.raidCooldownTicks = 300; + this.raidEvent.setProgress(0.0F); +- this.center = blockpos; +- this.numGroups = this.getNumGroups(serverlevel.getDifficulty()); ++ this.center = center; ++ this.numGroups = this.getNumGroups(level.getDifficulty()); + this.status = Raid.RaidStatus.ONGOING; + } + +- public Raid(ServerLevel serverlevel, CompoundTag compoundtag) { ++ public Raid(ServerLevel level, CompoundTag compound) { + this.raidEvent = new ServerBossEvent(Raid.RAID_NAME_COMPONENT, BossEvent.BossBarColor.RED, BossEvent.BossBarOverlay.NOTCHED_10); + this.random = RandomSource.create(); + this.waveSpawnPos = Optional.empty(); +- this.level = serverlevel; +- this.id = compoundtag.getInt("Id"); +- this.started = compoundtag.getBoolean("Started"); +- this.active = compoundtag.getBoolean("Active"); +- this.ticksActive = compoundtag.getLong("TicksActive"); +- this.badOmenLevel = compoundtag.getInt("BadOmenLevel"); +- this.groupsSpawned = compoundtag.getInt("GroupsSpawned"); +- this.raidCooldownTicks = compoundtag.getInt("PreRaidTicks"); +- this.postRaidTicks = compoundtag.getInt("PostRaidTicks"); +- this.totalHealth = compoundtag.getFloat("TotalHealth"); +- this.center = new BlockPos(compoundtag.getInt("CX"), compoundtag.getInt("CY"), compoundtag.getInt("CZ")); +- this.numGroups = compoundtag.getInt("NumGroups"); +- this.status = Raid.RaidStatus.getByName(compoundtag.getString("Status")); ++ this.level = level; ++ this.id = compound.getInt("Id"); ++ this.started = compound.getBoolean("Started"); ++ this.active = compound.getBoolean("Active"); ++ this.ticksActive = compound.getLong("TicksActive"); ++ this.badOmenLevel = compound.getInt("BadOmenLevel"); ++ this.groupsSpawned = compound.getInt("GroupsSpawned"); ++ this.raidCooldownTicks = compound.getInt("PreRaidTicks"); ++ this.postRaidTicks = compound.getInt("PostRaidTicks"); ++ this.totalHealth = compound.getFloat("TotalHealth"); ++ this.center = new BlockPos(compound.getInt("CX"), compound.getInt("CY"), compound.getInt("CZ")); ++ this.numGroups = compound.getInt("NumGroups"); ++ this.status = Raid.RaidStatus.getByName(compound.getString("Status")); + this.heroesOfTheVillage.clear(); +- if (compoundtag.contains("HeroesOfTheVillage", 9)) { +- ListTag listtag = compoundtag.getList("HeroesOfTheVillage", 11); +- Iterator iterator = listtag.iterator(); ++ if (compound.contains("HeroesOfTheVillage", 9)) { ++ ListTag nbttaglist = compound.getList("HeroesOfTheVillage", 11); ++ Iterator iterator = nbttaglist.iterator(); + + while (iterator.hasNext()) { +- Tag tag = (Tag) iterator.next(); ++ Tag nbtbase = (Tag) iterator.next(); + +- this.heroesOfTheVillage.add(NbtUtils.loadUUID(tag)); ++ this.heroesOfTheVillage.add(NbtUtils.loadUUID(nbtbase)); + } + } + +@@ -176,6 +176,12 @@ + return this.status == Raid.RaidStatus.LOSS; + } + ++ // CraftBukkit start ++ public boolean isInProgress() { ++ return this.status == RaidStatus.ONGOING; ++ } ++ // CraftBukkit end ++ + public float getTotalHealth() { + return this.totalHealth; + } +@@ -206,10 +212,10 @@ + } + + private Predicate<ServerPlayer> validPlayer() { +- return (serverplayer) -> { +- BlockPos blockpos = serverplayer.blockPosition(); ++ return (entityplayer) -> { ++ BlockPos blockposition = entityplayer.blockPosition(); + +- return serverplayer.isAlive() && this.level.getRaidAt(blockpos) == this; ++ return entityplayer.isAlive() && this.level.getRaidAt(blockposition) == this; + }; + } + +@@ -218,21 +224,21 @@ + List<ServerPlayer> list = this.level.getPlayers(this.validPlayer()); + Iterator iterator = list.iterator(); + +- ServerPlayer serverplayer; ++ ServerPlayer entityplayer; + + while (iterator.hasNext()) { +- serverplayer = (ServerPlayer) iterator.next(); +- if (!set.contains(serverplayer)) { +- this.raidEvent.addPlayer(serverplayer); ++ entityplayer = (ServerPlayer) iterator.next(); ++ if (!set.contains(entityplayer)) { ++ this.raidEvent.addPlayer(entityplayer); + } + } + + iterator = set.iterator(); + + while (iterator.hasNext()) { +- serverplayer = (ServerPlayer) iterator.next(); +- if (!list.contains(serverplayer)) { +- this.raidEvent.removePlayer(serverplayer); ++ entityplayer = (ServerPlayer) iterator.next(); ++ if (!list.contains(entityplayer)) { ++ this.raidEvent.removePlayer(entityplayer); + } + } + +@@ -246,8 +252,8 @@ + return this.badOmenLevel; + } + +- public void setBadOmenLevel(int i) { +- this.badOmenLevel = i; ++ public void setBadOmenLevel(int badOmenLevel) { ++ this.badOmenLevel = badOmenLevel; + } + + public void absorbBadOmen(Player player) { +@@ -272,6 +278,7 @@ + + this.active = this.level.hasChunkAt(this.center); + if (this.level.getDifficulty() == Difficulty.PEACEFUL) { ++ org.bukkit.craftbukkit.event.CraftEventFactory.callRaidStopEvent(this, org.bukkit.event.raid.RaidStopEvent.Reason.PEACE); // CraftBukkit + this.stop(); + return; + } +@@ -291,13 +298,16 @@ + if (!this.level.isVillage(this.center)) { + if (this.groupsSpawned > 0) { + this.status = Raid.RaidStatus.LOSS; ++ org.bukkit.craftbukkit.event.CraftEventFactory.callRaidFinishEvent(this, new java.util.ArrayList<>()); // CraftBukkit + } else { ++ org.bukkit.craftbukkit.event.CraftEventFactory.callRaidStopEvent(this, org.bukkit.event.raid.RaidStopEvent.Reason.NOT_IN_VILLAGE); // CraftBukkit + this.stop(); + } + } + + ++this.ticksActive; + if (this.ticksActive >= 48000L) { ++ org.bukkit.craftbukkit.event.CraftEventFactory.callRaidStopEvent(this, org.bukkit.event.raid.RaidStopEvent.Reason.TIMEOUT); // CraftBukkit + this.stop(); + return; + } +@@ -357,13 +367,13 @@ + int j = 0; + + while (this.shouldSpawnGroup()) { +- BlockPos blockpos = this.waveSpawnPos.isPresent() ? (BlockPos) this.waveSpawnPos.get() : this.findRandomSpawnPos(j, 20); ++ BlockPos blockposition = this.waveSpawnPos.isPresent() ? (BlockPos) this.waveSpawnPos.get() : this.findRandomSpawnPos(j, 20); + +- if (blockpos != null) { ++ if (blockposition != null) { + this.started = true; +- this.spawnGroup(blockpos); ++ this.spawnGroup(blockposition); + if (!flag1) { +- this.playSound(blockpos); ++ this.playSound(blockposition); + flag1 = true; + } + } else { +@@ -371,6 +381,7 @@ + } + + if (j > 3) { ++ org.bukkit.craftbukkit.event.CraftEventFactory.callRaidStopEvent(this, org.bukkit.event.raid.RaidStopEvent.Reason.UNSPAWNABLE); // CraftBukkit + this.stop(); + break; + } +@@ -383,24 +394,27 @@ + this.status = Raid.RaidStatus.VICTORY; + Iterator iterator = this.heroesOfTheVillage.iterator(); + ++ List<org.bukkit.entity.Player> winners = new java.util.ArrayList<>(); // CraftBukkit + while (iterator.hasNext()) { + UUID uuid = (UUID) iterator.next(); + Entity entity = this.level.getEntity(uuid); + + if (entity instanceof LivingEntity) { +- LivingEntity livingentity = (LivingEntity) entity; ++ LivingEntity entityliving = (LivingEntity) entity; + + if (!entity.isSpectator()) { +- livingentity.addEffect(new MobEffectInstance(MobEffects.HERO_OF_THE_VILLAGE, 48000, this.badOmenLevel - 1, false, false, true)); +- if (livingentity instanceof ServerPlayer) { +- ServerPlayer serverplayer = (ServerPlayer) livingentity; ++ entityliving.addEffect(new MobEffectInstance(MobEffects.HERO_OF_THE_VILLAGE, 48000, this.badOmenLevel - 1, false, false, true)); ++ if (entityliving instanceof ServerPlayer) { ++ ServerPlayer entityplayer = (ServerPlayer) entityliving; + +- serverplayer.awardStat(Stats.RAID_WIN); +- CriteriaTriggers.RAID_WIN.trigger(serverplayer); ++ entityplayer.awardStat(Stats.RAID_WIN); ++ CriteriaTriggers.RAID_WIN.trigger(entityplayer); ++ winners.add(entityplayer.getBukkitEntity()); // CraftBukkit + } + } + } + } ++ org.bukkit.craftbukkit.event.CraftEventFactory.callRaidFinishEvent(this, winners); // CraftBukkit + } + } + +@@ -408,6 +422,7 @@ + } else if (this.isOver()) { + ++this.celebrationTicks; + if (this.celebrationTicks >= 600) { ++ org.bukkit.craftbukkit.event.CraftEventFactory.callRaidStopEvent(this, org.bukkit.event.raid.RaidStopEvent.Reason.FINISHED); // CraftBukkit + this.stop(); + return; + } +@@ -429,20 +444,20 @@ + + private void moveRaidCenterToNearbyVillageSection() { + Stream<SectionPos> stream = SectionPos.cube(SectionPos.of(this.center), 2); +- ServerLevel serverlevel = this.level; ++ ServerLevel worldserver = this.level; + + Objects.requireNonNull(this.level); +- stream.filter(serverlevel::isVillage).map(SectionPos::center).min(Comparator.comparingDouble((blockpos) -> { +- return blockpos.distSqr(this.center); ++ stream.filter(worldserver::isVillage).map(SectionPos::center).min(Comparator.comparingDouble((blockposition) -> { ++ return blockposition.distSqr(this.center); + })).ifPresent(this::setCenter); + } + +- private Optional<BlockPos> getValidSpawnPos(int i) { ++ private Optional<BlockPos> getValidSpawnPos(int offsetMultiplier) { + for (int j = 0; j < 3; ++j) { +- BlockPos blockpos = this.findRandomSpawnPos(i, 1); ++ BlockPos blockposition = this.findRandomSpawnPos(offsetMultiplier, 1); + +- if (blockpos != null) { +- return Optional.of(blockpos); ++ if (blockposition != null) { ++ return Optional.of(blockposition); + } + } + +@@ -478,25 +493,25 @@ + Iterator iterator1 = set.iterator(); + + while (iterator1.hasNext()) { +- Raider raider = (Raider) iterator1.next(); +- BlockPos blockpos = raider.blockPosition(); ++ Raider entityraider = (Raider) iterator1.next(); ++ BlockPos blockposition = entityraider.blockPosition(); + +- if (!raider.isRemoved() && raider.level().dimension() == this.level.dimension() && this.center.distSqr(blockpos) < 12544.0D) { +- if (raider.tickCount > 600) { +- if (this.level.getEntity(raider.getUUID()) == null) { +- hashset.add(raider); ++ if (!entityraider.isRemoved() && entityraider.level().dimension() == this.level.dimension() && this.center.distSqr(blockposition) < 12544.0D) { ++ if (entityraider.tickCount > 600) { ++ if (this.level.getEntity(entityraider.getUUID()) == null) { ++ hashset.add(entityraider); + } + +- if (!this.level.isVillage(blockpos) && raider.getNoActionTime() > 2400) { +- raider.setTicksOutsideRaid(raider.getTicksOutsideRaid() + 1); ++ if (!this.level.isVillage(blockposition) && entityraider.getNoActionTime() > 2400) { ++ entityraider.setTicksOutsideRaid(entityraider.getTicksOutsideRaid() + 1); + } + +- if (raider.getTicksOutsideRaid() >= 30) { +- hashset.add(raider); ++ if (entityraider.getTicksOutsideRaid() >= 30) { ++ hashset.add(entityraider); + } + } + } else { +- hashset.add(raider); ++ hashset.add(entityraider); + } + } + } +@@ -504,14 +519,14 @@ + Iterator iterator2 = hashset.iterator(); + + while (iterator2.hasNext()) { +- Raider raider1 = (Raider) iterator2.next(); ++ Raider entityraider1 = (Raider) iterator2.next(); + +- this.removeFromRaid(raider1, true); ++ this.removeFromRaid(entityraider1, true); + } + + } + +- private void playSound(BlockPos blockpos) { ++ private void playSound(BlockPos pos) { + float f = 13.0F; + boolean flag = true; + Collection<ServerPlayer> collection = this.raidEvent.getPlayers(); +@@ -519,67 +534,74 @@ + Iterator iterator = this.level.players().iterator(); + + while (iterator.hasNext()) { +- ServerPlayer serverplayer = (ServerPlayer) iterator.next(); +- Vec3 vec3 = serverplayer.position(); +- Vec3 vec31 = Vec3.atCenterOf(blockpos); +- double d0 = Math.sqrt((vec31.x - vec3.x) * (vec31.x - vec3.x) + (vec31.z - vec3.z) * (vec31.z - vec3.z)); +- double d1 = vec3.x + 13.0D / d0 * (vec31.x - vec3.x); +- double d2 = vec3.z + 13.0D / d0 * (vec31.z - vec3.z); ++ ServerPlayer entityplayer = (ServerPlayer) iterator.next(); ++ Vec3 vec3d = entityplayer.position(); ++ Vec3 vec3d1 = Vec3.atCenterOf(pos); ++ double d0 = Math.sqrt((vec3d1.x - vec3d.x) * (vec3d1.x - vec3d.x) + (vec3d1.z - vec3d.z) * (vec3d1.z - vec3d.z)); ++ double d1 = vec3d.x + 13.0D / d0 * (vec3d1.x - vec3d.x); ++ double d2 = vec3d.z + 13.0D / d0 * (vec3d1.z - vec3d.z); + +- if (d0 <= 64.0D || collection.contains(serverplayer)) { +- serverplayer.connection.send(new ClientboundSoundPacket(SoundEvents.RAID_HORN, SoundSource.NEUTRAL, d1, serverplayer.getY(), d2, 64.0F, 1.0F, i)); ++ if (d0 <= 64.0D || collection.contains(entityplayer)) { ++ entityplayer.connection.send(new ClientboundSoundPacket(SoundEvents.RAID_HORN, SoundSource.NEUTRAL, d1, entityplayer.getY(), d2, 64.0F, 1.0F, i)); + } + } + + } + +- private void spawnGroup(BlockPos blockpos) { ++ private void spawnGroup(BlockPos pos) { + boolean flag = false; + int i = this.groupsSpawned + 1; + + this.totalHealth = 0.0F; +- DifficultyInstance difficultyinstance = this.level.getCurrentDifficultyAt(blockpos); ++ DifficultyInstance difficultydamagescaler = this.level.getCurrentDifficultyAt(pos); + boolean flag1 = this.shouldSpawnBonusGroup(); +- Raid.RaiderType[] araid_raidertype = Raid.RaiderType.VALUES; +- int j = araid_raidertype.length; ++ Raid.RaiderType[] araid_wave = Raid.RaiderType.VALUES; ++ int j = araid_wave.length; + int k = 0; + ++ // CraftBukkit start ++ Raider leader = null; ++ List<Raider> raiders = new java.util.ArrayList<>(); ++ // CraftBukkit end + while (k < j) { +- Raid.RaiderType raid_raidertype = araid_raidertype[k]; +- int l = this.getDefaultNumSpawns(raid_raidertype, i, flag1) + this.getPotentialBonusSpawns(raid_raidertype, this.random, i, difficultyinstance, flag1); ++ Raid.RaiderType raid_wave = araid_wave[k]; ++ int l = this.getDefaultNumSpawns(raid_wave, i, flag1) + this.getPotentialBonusSpawns(raid_wave, this.random, i, difficultydamagescaler, flag1); + int i1 = 0; + int j1 = 0; + + while (true) { + if (j1 < l) { +- Raider raider = (Raider) raid_raidertype.entityType.create(this.level); ++ Raider entityraider = (Raider) raid_wave.entityType.create(this.level); + +- if (raider != null) { +- if (!flag && raider.canBeLeader()) { +- raider.setPatrolLeader(true); +- this.setLeader(i, raider); ++ if (entityraider != null) { ++ if (!flag && entityraider.canBeLeader()) { ++ entityraider.setPatrolLeader(true); ++ this.setLeader(i, entityraider); + flag = true; ++ leader = entityraider; // CraftBukkit + } + +- this.joinRaid(i, raider, blockpos, false); +- if (raid_raidertype.entityType == EntityType.RAVAGER) { +- Raider raider1 = null; ++ this.joinRaid(i, entityraider, pos, false); ++ raiders.add(entityraider); // CraftBukkit ++ if (raid_wave.entityType == EntityType.RAVAGER) { ++ Raider entityraider1 = null; + + if (i == this.getNumGroups(Difficulty.NORMAL)) { +- raider1 = (Raider) EntityType.PILLAGER.create(this.level); ++ entityraider1 = (Raider) EntityType.PILLAGER.create(this.level); + } else if (i >= this.getNumGroups(Difficulty.HARD)) { + if (i1 == 0) { +- raider1 = (Raider) EntityType.EVOKER.create(this.level); ++ entityraider1 = (Raider) EntityType.EVOKER.create(this.level); + } else { +- raider1 = (Raider) EntityType.VINDICATOR.create(this.level); ++ entityraider1 = (Raider) EntityType.VINDICATOR.create(this.level); + } + } + + ++i1; +- if (raider1 != null) { +- this.joinRaid(i, raider1, blockpos, false); +- raider1.moveTo(blockpos, 0.0F, 0.0F); +- raider1.startRiding(raider); ++ if (entityraider1 != null) { ++ this.joinRaid(i, entityraider1, pos, false); ++ entityraider1.moveTo(pos, 0.0F, 0.0F); ++ entityraider1.startRiding(entityraider); ++ raiders.add(entityraider); // CraftBukkit + } + } + +@@ -597,22 +619,23 @@ + ++this.groupsSpawned; + this.updateBossbar(); + this.setDirty(); ++ org.bukkit.craftbukkit.event.CraftEventFactory.callRaidSpawnWaveEvent(this, leader, raiders); // CraftBukkit + } + +- public void joinRaid(int i, Raider raider, @Nullable BlockPos blockpos, boolean flag) { +- boolean flag1 = this.addWaveMob(i, raider); ++ public void joinRaid(int wave, Raider raider, @Nullable BlockPos pos, boolean isRecruited) { ++ boolean flag1 = this.addWaveMob(wave, raider); + + if (flag1) { + raider.setCurrentRaid(this); +- raider.setWave(i); ++ raider.setWave(wave); + raider.setCanJoinRaid(true); + raider.setTicksOutsideRaid(0); +- if (!flag && blockpos != null) { +- raider.setPos((double) blockpos.getX() + 0.5D, (double) blockpos.getY() + 1.0D, (double) blockpos.getZ() + 0.5D); +- raider.finalizeSpawn(this.level, this.level.getCurrentDifficultyAt(blockpos), MobSpawnType.EVENT, (SpawnGroupData) null, (CompoundTag) null); +- raider.applyRaidBuffs(i, false); ++ if (!isRecruited && pos != null) { ++ raider.setPos((double) pos.getX() + 0.5D, (double) pos.getY() + 1.0D, (double) pos.getZ() + 0.5D); ++ raider.finalizeSpawn(this.level, this.level.getCurrentDifficultyAt(pos), EnumMobSpawn.EVENT, (GroupDataEntity) null, (CompoundTag) null); ++ raider.applyRaidBuffs(wave, false); + raider.setOnGround(true); +- this.level.addFreshEntityWithPassengers(raider); ++ this.level.addFreshEntityWithPassengers(raider, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.RAID); // CraftBukkit + } + } + +@@ -629,10 +652,10 @@ + while (iterator.hasNext()) { + Set<Raider> set = (Set) iterator.next(); + +- Raider raider; ++ Raider entityraider; + +- for (Iterator iterator1 = set.iterator(); iterator1.hasNext(); f += raider.getHealth()) { +- raider = (Raider) iterator1.next(); ++ for (Iterator iterator1 = set.iterator(); iterator1.hasNext(); f += entityraider.getHealth()) { ++ entityraider = (Raider) iterator1.next(); + } + } + +@@ -647,14 +670,14 @@ + return this.groupRaiderMap.values().stream().mapToInt(Set::size).sum(); + } + +- public void removeFromRaid(Raider raider, boolean flag) { ++ public void removeFromRaid(Raider raider, boolean wanderedOutOfRaid) { + Set<Raider> set = (Set) this.groupRaiderMap.get(raider.getWave()); + + if (set != null) { + boolean flag1 = set.remove(raider); + + if (flag1) { +- if (flag) { ++ if (wanderedOutOfRaid) { + this.totalHealth -= raider.getHealth(); + } + +@@ -672,38 +695,38 @@ + + public static ItemStack getLeaderBannerInstance() { + ItemStack itemstack = new ItemStack(Items.WHITE_BANNER); +- CompoundTag compoundtag = new CompoundTag(); +- ListTag listtag = (new BannerPattern.Builder()).addPattern(BannerPatterns.RHOMBUS_MIDDLE, DyeColor.CYAN).addPattern(BannerPatterns.STRIPE_BOTTOM, DyeColor.LIGHT_GRAY).addPattern(BannerPatterns.STRIPE_CENTER, DyeColor.GRAY).addPattern(BannerPatterns.BORDER, DyeColor.LIGHT_GRAY).addPattern(BannerPatterns.STRIPE_MIDDLE, DyeColor.BLACK).addPattern(BannerPatterns.HALF_HORIZONTAL, DyeColor.LIGHT_GRAY).addPattern(BannerPatterns.CIRCLE_MIDDLE, DyeColor.LIGHT_GRAY).addPattern(BannerPatterns.BORDER, DyeColor.BLACK).toListTag(); ++ CompoundTag nbttagcompound = new CompoundTag(); ++ ListTag nbttaglist = (new BannerPattern.Builder()).addPattern(BannerPatterns.RHOMBUS_MIDDLE, DyeColor.CYAN).addPattern(BannerPatterns.STRIPE_BOTTOM, DyeColor.LIGHT_GRAY).addPattern(BannerPatterns.STRIPE_CENTER, DyeColor.GRAY).addPattern(BannerPatterns.BORDER, DyeColor.LIGHT_GRAY).addPattern(BannerPatterns.STRIPE_MIDDLE, DyeColor.BLACK).addPattern(BannerPatterns.HALF_HORIZONTAL, DyeColor.LIGHT_GRAY).addPattern(BannerPatterns.CIRCLE_MIDDLE, DyeColor.LIGHT_GRAY).addPattern(BannerPatterns.BORDER, DyeColor.BLACK).toListTag(); + +- compoundtag.put("Patterns", listtag); +- BlockItem.setBlockEntityData(itemstack, BlockEntityType.BANNER, compoundtag); +- itemstack.hideTooltipPart(ItemStack.TooltipPart.ADDITIONAL); ++ nbttagcompound.put("Patterns", nbttaglist); ++ BlockItem.setBlockEntityData(itemstack, BlockEntityType.BANNER, nbttagcompound); ++ itemstack.hideTooltipPart(ItemStack.HideFlags.ADDITIONAL); + itemstack.setHoverName(Component.translatable("block.minecraft.ominous_banner").withStyle(ChatFormatting.GOLD)); + return itemstack; + } + + @Nullable +- public Raider getLeader(int i) { +- return (Raider) this.groupToLeaderMap.get(i); ++ public Raider getLeader(int wave) { ++ return (Raider) this.groupToLeaderMap.get(wave); + } + + @Nullable +- private BlockPos findRandomSpawnPos(int i, int j) { +- int k = i == 0 ? 2 : 2 - i; +- BlockPos.MutableBlockPos blockpos_mutableblockpos = new BlockPos.MutableBlockPos(); ++ private BlockPos findRandomSpawnPos(int offsetMultiplier, int maxTry) { ++ int k = offsetMultiplier == 0 ? 2 : 2 - offsetMultiplier; ++ BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos(); + +- for (int l = 0; l < j; ++l) { ++ for (int l = 0; l < maxTry; ++l) { + float f = this.level.random.nextFloat() * 6.2831855F; + int i1 = this.center.getX() + Mth.floor(Mth.cos(f) * 32.0F * (float) k) + this.level.random.nextInt(5); + int j1 = this.center.getZ() + Mth.floor(Mth.sin(f) * 32.0F * (float) k) + this.level.random.nextInt(5); + int k1 = this.level.getHeight(Heightmap.Types.WORLD_SURFACE, i1, j1); + +- blockpos_mutableblockpos.set(i1, k1, j1); +- if (!this.level.isVillage((BlockPos) blockpos_mutableblockpos) || i >= 2) { ++ blockposition_mutableblockposition.set(i1, k1, j1); ++ if (!this.level.isVillage((BlockPos) blockposition_mutableblockposition) || offsetMultiplier >= 2) { + boolean flag = true; + +- if (this.level.hasChunksAt(blockpos_mutableblockpos.getX() - 10, blockpos_mutableblockpos.getZ() - 10, blockpos_mutableblockpos.getX() + 10, blockpos_mutableblockpos.getZ() + 10) && this.level.isPositionEntityTicking(blockpos_mutableblockpos) && (NaturalSpawner.isSpawnPositionOk(SpawnPlacements.Type.ON_GROUND, this.level, blockpos_mutableblockpos, EntityType.RAVAGER) || this.level.getBlockState(blockpos_mutableblockpos.below()).is(Blocks.SNOW) && this.level.getBlockState(blockpos_mutableblockpos).isAir())) { +- return blockpos_mutableblockpos; ++ if (this.level.hasChunksAt(blockposition_mutableblockposition.getX() - 10, blockposition_mutableblockposition.getZ() - 10, blockposition_mutableblockposition.getX() + 10, blockposition_mutableblockposition.getZ() + 10) && this.level.isPositionEntityTicking(blockposition_mutableblockposition) && (NaturalSpawner.isSpawnPositionOk(SpawnPlacements.Surface.ON_GROUND, this.level, blockposition_mutableblockposition, EntityType.RAVAGER) || this.level.getBlockState(blockposition_mutableblockposition.below()).is(Blocks.SNOW) && this.level.getBlockState(blockposition_mutableblockposition).isAir())) { ++ return blockposition_mutableblockposition; + } + } + } +@@ -711,34 +734,34 @@ + return null; + } + +- private boolean addWaveMob(int i, Raider raider) { +- return this.addWaveMob(i, raider, true); ++ private boolean addWaveMob(int wave, Raider raider) { ++ return this.addWaveMob(wave, raider, true); + } + +- public boolean addWaveMob(int i, Raider raider, boolean flag) { +- this.groupRaiderMap.computeIfAbsent(i, (integer) -> { ++ public boolean addWaveMob(int wave, Raider raider, boolean isRecruited) { ++ this.groupRaiderMap.computeIfAbsent(wave, (integer) -> { + return Sets.newHashSet(); + }); +- Set<Raider> set = (Set) this.groupRaiderMap.get(i); +- Raider raider1 = null; ++ Set<Raider> set = (Set) this.groupRaiderMap.get(wave); ++ Raider entityraider1 = null; + Iterator iterator = set.iterator(); + + while (iterator.hasNext()) { +- Raider raider2 = (Raider) iterator.next(); ++ Raider entityraider2 = (Raider) iterator.next(); + +- if (raider2.getUUID().equals(raider.getUUID())) { +- raider1 = raider2; ++ if (entityraider2.getUUID().equals(raider.getUUID())) { ++ entityraider1 = entityraider2; + break; + } + } + +- if (raider1 != null) { +- set.remove(raider1); ++ if (entityraider1 != null) { ++ set.remove(entityraider1); + set.add(raider); + } + + set.add(raider); +- if (flag) { ++ if (isRecruited) { + this.totalHealth += raider.getHealth(); + } + +@@ -747,41 +770,41 @@ + return true; + } + +- public void setLeader(int i, Raider raider) { +- this.groupToLeaderMap.put(i, raider); ++ public void setLeader(int wave, Raider raider) { ++ this.groupToLeaderMap.put(wave, raider); + raider.setItemSlot(EquipmentSlot.HEAD, getLeaderBannerInstance()); + raider.setDropChance(EquipmentSlot.HEAD, 2.0F); + } + +- public void removeLeader(int i) { +- this.groupToLeaderMap.remove(i); ++ public void removeLeader(int wave) { ++ this.groupToLeaderMap.remove(wave); + } + + public BlockPos getCenter() { + return this.center; + } + +- private void setCenter(BlockPos blockpos) { +- this.center = blockpos; ++ private void setCenter(BlockPos center) { ++ this.center = center; + } + + public int getId() { + return this.id; + } + +- private int getDefaultNumSpawns(Raid.RaiderType raid_raidertype, int i, boolean flag) { +- return flag ? raid_raidertype.spawnsPerWaveBeforeBonus[this.numGroups] : raid_raidertype.spawnsPerWaveBeforeBonus[i]; ++ private int getDefaultNumSpawns(Raid.RaiderType raiderType, int wave, boolean shouldSpawnBonusGroup) { ++ return shouldSpawnBonusGroup ? raiderType.spawnsPerWaveBeforeBonus[this.numGroups] : raiderType.spawnsPerWaveBeforeBonus[wave]; + } + +- private int getPotentialBonusSpawns(Raid.RaiderType raid_raidertype, RandomSource randomsource, int i, DifficultyInstance difficultyinstance, boolean flag) { +- Difficulty difficulty = difficultyinstance.getDifficulty(); +- boolean flag1 = difficulty == Difficulty.EASY; +- boolean flag2 = difficulty == Difficulty.NORMAL; ++ private int getPotentialBonusSpawns(Raid.RaiderType raiderType, RandomSource random, int wave, DifficultyInstance difficulty, boolean shouldSpawnBonusGroup) { ++ Difficulty enumdifficulty = difficulty.getDifficulty(); ++ boolean flag1 = enumdifficulty == Difficulty.EASY; ++ boolean flag2 = enumdifficulty == Difficulty.NORMAL; + int j; + +- switch (raid_raidertype) { ++ switch (raiderType) { + case WITCH: +- if (flag1 || i <= 2 || i == 4) { ++ if (flag1 || wave <= 2 || wave == 4) { + return 0; + } + +@@ -790,7 +813,7 @@ + case PILLAGER: + case VINDICATOR: + if (flag1) { +- j = randomsource.nextInt(2); ++ j = random.nextInt(2); + } else if (flag2) { + j = 1; + } else { +@@ -798,45 +821,45 @@ + } + break; + case RAVAGER: +- j = !flag1 && flag ? 1 : 0; ++ j = !flag1 && shouldSpawnBonusGroup ? 1 : 0; + break; + default: + return 0; + } + +- return j > 0 ? randomsource.nextInt(j + 1) : 0; ++ return j > 0 ? random.nextInt(j + 1) : 0; + } + + public boolean isActive() { + return this.active; + } + +- public CompoundTag save(CompoundTag compoundtag) { +- compoundtag.putInt("Id", this.id); +- compoundtag.putBoolean("Started", this.started); +- compoundtag.putBoolean("Active", this.active); +- compoundtag.putLong("TicksActive", this.ticksActive); +- compoundtag.putInt("BadOmenLevel", this.badOmenLevel); +- compoundtag.putInt("GroupsSpawned", this.groupsSpawned); +- compoundtag.putInt("PreRaidTicks", this.raidCooldownTicks); +- compoundtag.putInt("PostRaidTicks", this.postRaidTicks); +- compoundtag.putFloat("TotalHealth", this.totalHealth); +- compoundtag.putInt("NumGroups", this.numGroups); +- compoundtag.putString("Status", this.status.getName()); +- compoundtag.putInt("CX", this.center.getX()); +- compoundtag.putInt("CY", this.center.getY()); +- compoundtag.putInt("CZ", this.center.getZ()); +- ListTag listtag = new ListTag(); ++ public CompoundTag save(CompoundTag compound) { ++ compound.putInt("Id", this.id); ++ compound.putBoolean("Started", this.started); ++ compound.putBoolean("Active", this.active); ++ compound.putLong("TicksActive", this.ticksActive); ++ compound.putInt("BadOmenLevel", this.badOmenLevel); ++ compound.putInt("GroupsSpawned", this.groupsSpawned); ++ compound.putInt("PreRaidTicks", this.raidCooldownTicks); ++ compound.putInt("PostRaidTicks", this.postRaidTicks); ++ compound.putFloat("TotalHealth", this.totalHealth); ++ compound.putInt("NumGroups", this.numGroups); ++ compound.putString("Status", this.status.getName()); ++ compound.putInt("CX", this.center.getX()); ++ compound.putInt("CY", this.center.getY()); ++ compound.putInt("CZ", this.center.getZ()); ++ ListTag nbttaglist = new ListTag(); + Iterator iterator = this.heroesOfTheVillage.iterator(); + + while (iterator.hasNext()) { + UUID uuid = (UUID) iterator.next(); + +- listtag.add(NbtUtils.createUUID(uuid)); ++ nbttaglist.add(NbtUtils.createUUID(uuid)); + } + +- compoundtag.put("HeroesOfTheVillage", listtag); +- return compoundtag; ++ compound.put("HeroesOfTheVillage", nbttaglist); ++ return compound; + } + + public int getNumGroups(Difficulty difficulty) { +@@ -858,10 +881,16 @@ + return i == 2 ? 0.1F : (i == 3 ? 0.25F : (i == 4 ? 0.5F : (i == 5 ? 0.75F : 0.0F))); + } + +- public void addHeroOfTheVillage(Entity entity) { +- this.heroesOfTheVillage.add(entity.getUUID()); ++ public void addHeroOfTheVillage(Entity player) { ++ this.heroesOfTheVillage.add(player.getUUID()); + } + ++ // CraftBukkit start - a method to get all raiders ++ public java.util.Collection<Raider> getRaiders() { ++ return this.groupRaiderMap.values().stream().flatMap(Set::stream).collect(java.util.stream.Collectors.toSet()); ++ } ++ // CraftBukkit end ++ + private static enum RaidStatus { + + ONGOING, VICTORY, LOSS, STOPPED; +@@ -870,15 +899,15 @@ + + private RaidStatus() {} + +- static Raid.RaidStatus getByName(String s) { +- Raid.RaidStatus[] araid_raidstatus = Raid.RaidStatus.VALUES; +- int i = araid_raidstatus.length; ++ static Raid.RaidStatus getByName(String name) { ++ Raid.RaidStatus[] araid_status = Raid.RaidStatus.VALUES; ++ int i = araid_status.length; + + for (int j = 0; j < i; ++j) { +- Raid.RaidStatus raid_raidstatus = araid_raidstatus[j]; ++ Raid.RaidStatus raid_status = araid_status[j]; + +- if (s.equalsIgnoreCase(raid_raidstatus.name())) { +- return raid_raidstatus; ++ if (name.equalsIgnoreCase(raid_status.name())) { ++ return raid_status; + } + } + +@@ -898,8 +927,8 @@ + final EntityType<? extends Raider> entityType; + final int[] spawnsPerWaveBeforeBonus; + +- private RaiderType(EntityType<? extends Raider> entitytype, int[] aint) { +- this.entityType = entitytype; ++ private RaiderType(EntityType entitytypes, int[] aint) { ++ this.entityType = entitytypes; + this.spawnsPerWaveBeforeBonus = aint; + } + } |