mirror of
https://github.com/LeavesMC/Leaves.git
synced 2025-12-19 14:59:32 +00:00
158 lines
8.7 KiB
Diff
158 lines
8.7 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: huanli233 <392352840@qq.com>
|
|
Date: Wed, 23 Oct 2024 23:10:48 +0800
|
|
Subject: [PATCH] Revert raid changes
|
|
|
|
|
|
diff --git a/net/minecraft/world/effect/BadOmenMobEffect.java b/net/minecraft/world/effect/BadOmenMobEffect.java
|
|
index 80f17f33f670018240c854df589cf90cdeab6e70..4c6ce6a4a730033802651b0c0052fc46edeed4d6 100644
|
|
--- a/net/minecraft/world/effect/BadOmenMobEffect.java
|
|
+++ b/net/minecraft/world/effect/BadOmenMobEffect.java
|
|
@@ -22,6 +22,11 @@ class BadOmenMobEffect extends MobEffect {
|
|
&& !serverPlayer.isSpectator()
|
|
&& level.getDifficulty() != Difficulty.PEACEFUL
|
|
&& level.isVillage(serverPlayer.blockPosition())) {
|
|
+ // Leaves start - Revert raid changes
|
|
+ if (org.leavesmc.leaves.LeavesConfig.modify.oldMC.raid.allowBadOmenTriggerRaid) {
|
|
+ return level.getRaids().createOrExtendRaid(serverPlayer, serverPlayer.blockPosition()) == null;
|
|
+ }
|
|
+ // Leaves end - Revert raid changes
|
|
Raid raidAt = level.getRaidAt(serverPlayer.blockPosition());
|
|
if (raidAt == null || raidAt.getRaidOmenLevel() < raidAt.getMaxRaidOmenLevel()) {
|
|
serverPlayer.addEffect(new MobEffectInstance(MobEffects.RAID_OMEN, 600, amplifier));
|
|
diff --git a/net/minecraft/world/entity/raid/Raid.java b/net/minecraft/world/entity/raid/Raid.java
|
|
index 41b0db439b425b052bd1469daa6620a435ca852b..4e2b73ad91b4fc12da123b22910a7e3a78b23d1d 100644
|
|
--- a/net/minecraft/world/entity/raid/Raid.java
|
|
+++ b/net/minecraft/world/entity/raid/Raid.java
|
|
@@ -318,7 +318,20 @@ public class Raid {
|
|
}
|
|
|
|
if (flag1) {
|
|
- this.waveSpawnPos = this.getValidSpawnPos();
|
|
+ // Leaves Start - old FindSpawnPosition
|
|
+ if (!org.leavesmc.leaves.LeavesConfig.modify.oldMC.raid.useOldFindSpawnPosition) {
|
|
+ this.waveSpawnPos = this.getValidSpawnPos();
|
|
+ } else {
|
|
+ int n4 = 0;
|
|
+ if (this.raidCooldownTicks < 100) {
|
|
+ n4 = 1;
|
|
+ }
|
|
+ if (this.raidCooldownTicks < 40) {
|
|
+ n4 = 2;
|
|
+ }
|
|
+ this.waveSpawnPos = this.getValidSpawnPos(n4);
|
|
+ }
|
|
+ // Leaves End - old FindSpawnPosition
|
|
}
|
|
|
|
if (this.raidCooldownTicks == 300 || this.raidCooldownTicks % 20 == 0) {
|
|
@@ -353,7 +366,14 @@ public class Raid {
|
|
int i = 0;
|
|
|
|
while (this.shouldSpawnGroup()) {
|
|
- BlockPos blockPos = this.waveSpawnPos.orElseGet(() -> this.findRandomSpawnPos(20));
|
|
+ // Leaves Start - old FindSpawnPosition
|
|
+ BlockPos blockPos;
|
|
+ if (!org.leavesmc.leaves.LeavesConfig.modify.oldMC.raid.useOldFindSpawnPosition) {
|
|
+ blockPos = this.waveSpawnPos.orElseGet(() -> this.findRandomSpawnPos(20));
|
|
+ } else {
|
|
+ blockPos = this.waveSpawnPos.isPresent() ? this.waveSpawnPos.get() : this.findRandomSpawnPos(i, 20);
|
|
+ }
|
|
+ // Leaves End - old FindSpawnPosition
|
|
if (blockPos != null) {
|
|
this.started = true;
|
|
this.spawnGroup(blockPos);
|
|
@@ -365,7 +385,7 @@ public class Raid {
|
|
i++;
|
|
}
|
|
|
|
- if (i > 5) {
|
|
+ if (i > (org.leavesmc.leaves.LeavesConfig.modify.oldMC.raid.useOldFindSpawnPosition ? 3 : 5)) { // Leaves - old FindSpawnPosition
|
|
org.bukkit.craftbukkit.event.CraftEventFactory.callRaidStopEvent(this, org.bukkit.event.raid.RaidStopEvent.Reason.UNSPAWNABLE); // CraftBukkit
|
|
this.stop();
|
|
break;
|
|
@@ -680,6 +700,35 @@ public class Raid {
|
|
return null;
|
|
}
|
|
|
|
+ // Leaves Start - old FindSpawnPosition
|
|
+ @Nullable
|
|
+ private BlockPos findRandomSpawnPos(int n, int n2) {
|
|
+ int n3 = 2 - n;
|
|
+ BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos();
|
|
+ SpawnPlacementType spawnPlacementType = SpawnPlacements.getPlacementType(EntityType.RAVAGER);
|
|
+ for (int i = 0; i < n2; ++i) {
|
|
+ float f = this.level.random.nextFloat() * ((float)Math.PI * 2);
|
|
+ int n4 = this.center.getX() + Mth.floor(Mth.cos(f) * 32.0f * (float)n3) + this.level.random.nextInt(5);
|
|
+ int n5 = this.center.getZ() + Mth.floor(Mth.sin(f) * 32.0f * (float)n3) + this.level.random.nextInt(5);
|
|
+ int n6 = this.level.getHeight(Heightmap.Types.WORLD_SURFACE, n4, n5);
|
|
+ mutableBlockPos.set(n4, n6, n5);
|
|
+ if (this.level.isVillage(mutableBlockPos) && n < 2) continue;
|
|
+ if (!this.level.hasChunksAt(mutableBlockPos.getX() - 10, mutableBlockPos.getZ() - 10, mutableBlockPos.getX() + 10, mutableBlockPos.getZ() + 10) || !this.level.isPositionEntityTicking(mutableBlockPos) || !spawnPlacementType.isSpawnPositionOk(this.level, mutableBlockPos, EntityType.RAVAGER) && (!this.level.getBlockState((BlockPos)mutableBlockPos.below()).is(Blocks.SNOW) || !this.level.getBlockState(mutableBlockPos).isAir())) continue;
|
|
+ return mutableBlockPos;
|
|
+ }
|
|
+ return null;
|
|
+ }
|
|
+
|
|
+ private Optional<BlockPos> getValidSpawnPos(int n) {
|
|
+ for (int i = 0; i < 3; ++i) {
|
|
+ BlockPos blockPos = this.findRandomSpawnPos(n, 1);
|
|
+ if (blockPos == null) continue;
|
|
+ return Optional.of(blockPos);
|
|
+ }
|
|
+ return Optional.empty();
|
|
+ }
|
|
+ // Leaves End - old FindSpawnPosition
|
|
+
|
|
private boolean addWaveMob(int wave, Raider raider) {
|
|
return this.addWaveMob(wave, raider, true);
|
|
}
|
|
diff --git a/net/minecraft/world/entity/raid/Raider.java b/net/minecraft/world/entity/raid/Raider.java
|
|
index f58a20e7dd6b8dc3fc431d4aba9f91a7c25f2c33..ce692698260d4751b13d5b26f7d9403c72b413c6 100644
|
|
--- a/net/minecraft/world/entity/raid/Raider.java
|
|
+++ b/net/minecraft/world/entity/raid/Raider.java
|
|
@@ -125,6 +125,43 @@ public abstract class Raider extends PatrollingMonster {
|
|
|
|
currentRaid.removeFromRaid(this, false);
|
|
}
|
|
+
|
|
+ // Leaves start - Revert raid changes
|
|
+ if (this.level() instanceof ServerLevel serverLevel) {
|
|
+ if (org.leavesmc.leaves.LeavesConfig.modify.oldMC.raid.giveBadOmenWhenKillPatrolLeader && !this.hasRaid()) {
|
|
+ ItemStack itemstack = this.getItemBySlot(EquipmentSlot.HEAD);
|
|
+ net.minecraft.world.entity.player.Player entityhuman = null;
|
|
+ if (entity instanceof net.minecraft.world.entity.player.Player player) {
|
|
+ entityhuman = player;
|
|
+ } else if (entity instanceof net.minecraft.world.entity.animal.Wolf wolf) {
|
|
+ LivingEntity entityliving = wolf.getOwner();
|
|
+ if (wolf.isTame() && entityliving instanceof net.minecraft.world.entity.player.Player player) {
|
|
+ entityhuman = player;
|
|
+ }
|
|
+ }
|
|
+
|
|
+ if (entityhuman != null && !itemstack.isEmpty() && this.isCaptain()) {
|
|
+ net.minecraft.world.effect.MobEffectInstance mobeffect = entityhuman.getEffect(net.minecraft.world.effect.MobEffects.BAD_OMEN);
|
|
+ int i = 1;
|
|
+
|
|
+ if (mobeffect != null) {
|
|
+ i += mobeffect.getAmplifier();
|
|
+ entityhuman.removeEffectNoUpdate(net.minecraft.world.effect.MobEffects.BAD_OMEN);
|
|
+ } else {
|
|
+ --i;
|
|
+ }
|
|
+
|
|
+ i = net.minecraft.util.Mth.clamp(i, 0, 4);
|
|
+ net.minecraft.world.effect.MobEffectInstance mobeffect1 = new net.minecraft.world.effect.MobEffectInstance(net.minecraft.world.effect.MobEffects.BAD_OMEN, 120000, i, false, false, true);
|
|
+
|
|
+ if (!serverLevel.getGameRules().getBoolean(net.minecraft.world.level.GameRules.RULE_DISABLE_RAIDS)) {
|
|
+ entityhuman.addEffect(mobeffect1, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.PATROL_CAPTAIN); // CraftBukkit
|
|
+ }
|
|
+ this.setPatrolLeader(false);
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ // Leaves end - Revert raid changes
|
|
}
|
|
|
|
super.die(cause);
|