-
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
121 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: huanli233 <[email protected]> | ||
Date: Wed, 23 Oct 2024 23:10:48 +0800 | ||
Subject: [PATCH] Revert raid changes | ||
|
||
|
||
diff --git a/src/main/java/net/minecraft/world/effect/BadOmenMobEffect.java b/src/main/java/net/minecraft/world/effect/BadOmenMobEffect.java | ||
index 038ee9e1ef4c7fc6a92efbba0f2ec9063c236df5..391be234ad2635cabb0eb39eecb1e07d2d872518 100644 | ||
--- a/src/main/java/net/minecraft/world/effect/BadOmenMobEffect.java | ||
+++ b/src/main/java/net/minecraft/world/effect/BadOmenMobEffect.java | ||
@@ -1,5 +1,6 @@ | ||
package net.minecraft.world.effect; | ||
|
||
+import net.minecraft.core.BlockPos; | ||
import net.minecraft.server.level.ServerLevel; | ||
import net.minecraft.server.level.ServerPlayer; | ||
import net.minecraft.world.Difficulty; | ||
@@ -20,6 +21,11 @@ class BadOmenMobEffect extends MobEffect { | ||
public boolean applyEffectTick(LivingEntity entity, int amplifier) { | ||
if (entity instanceof ServerPlayer serverPlayer && !serverPlayer.isSpectator()) { | ||
ServerLevel serverLevel = serverPlayer.serverLevel(); | ||
+ // Leaves start - Revert raid changes | ||
+ if (org.leavesmc.leaves.LeavesConfig.allowBadOmenTriggerRaid) { | ||
+ return this.legacyApplyEffectTick(serverPlayer, serverLevel); | ||
+ } | ||
+ // Leaves end - Revert raid changes | ||
if (serverLevel.getDifficulty() != Difficulty.PEACEFUL && serverLevel.isVillage(serverPlayer.blockPosition())) { | ||
Raid raid = serverLevel.getRaidAt(serverPlayer.blockPosition()); | ||
if (raid == null || raid.getRaidOmenLevel() < raid.getMaxRaidOmenLevel()) { | ||
@@ -32,4 +38,9 @@ class BadOmenMobEffect extends MobEffect { | ||
|
||
return true; | ||
} | ||
+ | ||
+ private boolean legacyApplyEffectTick(ServerPlayer player, ServerLevel world) { | ||
+ BlockPos blockPos = player.blockPosition(); | ||
+ return world.getDifficulty() == Difficulty.PEACEFUL || !world.isVillage(blockPos) || world.getRaids().createOrExtendRaid(player, blockPos) == null; | ||
+ } | ||
} | ||
diff --git a/src/main/java/net/minecraft/world/entity/raid/Raider.java b/src/main/java/net/minecraft/world/entity/raid/Raider.java | ||
index 6e68f8fa8280a106b1a262d86aa130e89d4f5cce..2401ebf4f2cbc841c7938eba2e0bd7dd54124c9e 100644 | ||
--- a/src/main/java/net/minecraft/world/entity/raid/Raider.java | ||
+++ b/src/main/java/net/minecraft/world/entity/raid/Raider.java | ||
@@ -16,8 +16,11 @@ import net.minecraft.network.syncher.EntityDataSerializers; | ||
import net.minecraft.network.syncher.SynchedEntityData; | ||
import net.minecraft.server.level.ServerLevel; | ||
import net.minecraft.sounds.SoundEvent; | ||
+import net.minecraft.util.Mth; | ||
import net.minecraft.world.DifficultyInstance; | ||
import net.minecraft.world.damagesource.DamageSource; | ||
+import net.minecraft.world.effect.MobEffectInstance; | ||
+import net.minecraft.world.effect.MobEffects; | ||
import net.minecraft.world.entity.Entity; | ||
import net.minecraft.world.entity.EntityType; | ||
import net.minecraft.world.entity.EquipmentSlot; | ||
@@ -30,10 +33,13 @@ import net.minecraft.world.entity.ai.targeting.TargetingConditions; | ||
import net.minecraft.world.entity.ai.util.DefaultRandomPos; | ||
import net.minecraft.world.entity.ai.village.poi.PoiManager; | ||
import net.minecraft.world.entity.ai.village.poi.PoiTypes; | ||
+import net.minecraft.world.entity.animal.Wolf; | ||
import net.minecraft.world.entity.item.ItemEntity; | ||
import net.minecraft.world.entity.monster.AbstractIllager; | ||
import net.minecraft.world.entity.monster.PatrollingMonster; | ||
+import net.minecraft.world.entity.player.Player; | ||
import net.minecraft.world.item.ItemStack; | ||
+import net.minecraft.world.level.GameRules; | ||
import net.minecraft.world.level.Level; | ||
import net.minecraft.world.level.ServerLevelAccessor; | ||
import net.minecraft.world.phys.Vec3; | ||
@@ -131,6 +137,43 @@ public abstract class Raider extends PatrollingMonster { | ||
|
||
raid.removeFromRaid(this, false); | ||
} | ||
+ | ||
+ // Leaves start - Revert raid changes | ||
+ if (org.leavesmc.leaves.LeavesConfig.giveBadOmenWhenKillPatrolLeader && this.isPatrolLeader() && raid == null && ((ServerLevel) this.level()).getRaidAt(this.blockPosition()) == null) { | ||
+ ItemStack itemstack = this.getItemBySlot(EquipmentSlot.HEAD); | ||
+ Player entityhuman = null; | ||
+ | ||
+ if (entity instanceof Player) { | ||
+ entityhuman = (Player) entity; | ||
+ } else if (entity instanceof Wolf) { | ||
+ Wolf entitywolf = (Wolf) entity; | ||
+ LivingEntity entityliving = entitywolf.getOwner(); | ||
+ | ||
+ if (entitywolf.isTame() && entityliving instanceof Player) { | ||
+ entityhuman = (Player) entityliving; | ||
+ } | ||
+ } | ||
+ | ||
+ if (!itemstack.isEmpty() && ItemStack.matches(itemstack, Raid.getLeaderBannerInstance(this.registryAccess().lookupOrThrow(Registries.BANNER_PATTERN))) && entityhuman != null) { | ||
+ MobEffectInstance mobeffect = entityhuman.getEffect(MobEffects.BAD_OMEN); | ||
+ int i = 1; | ||
+ | ||
+ if (mobeffect != null) { | ||
+ i += mobeffect.getAmplifier(); | ||
+ entityhuman.removeEffectNoUpdate(MobEffects.BAD_OMEN); | ||
+ } else { | ||
+ --i; | ||
+ } | ||
+ | ||
+ i = Mth.clamp(i, 0, 4); | ||
+ MobEffectInstance mobeffect1 = new MobEffectInstance(MobEffects.BAD_OMEN, 120000, i, false, false, true); | ||
+ | ||
+ if (!this.level().getGameRules().getBoolean(GameRules.RULE_DISABLE_RAIDS)) { | ||
+ entityhuman.addEffect(mobeffect1, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.PATROL_CAPTAIN); // CraftBukkit | ||
+ } | ||
+ } | ||
+ } | ||
+ // Leaves end - Revert raid changes | ||
} | ||
|
||
super.die(damageSource); |