Skip to content

Commit

Permalink
Revert raid changes (#361)
Browse files Browse the repository at this point in the history
  • Loading branch information
huanli233 authored Oct 24, 2024
1 parent f830919 commit 9d90760
Show file tree
Hide file tree
Showing 2 changed files with 121 additions and 2 deletions.
10 changes: 8 additions & 2 deletions patches/server/0006-Leaves-Server-Config-And-Command.patch
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ index d97771ecaf06b92d92b5ca0224ae0866e36703a6..439305bb4f5ce232aa6237276c121d53
.withRequiredArg()
diff --git a/src/main/java/org/leavesmc/leaves/LeavesConfig.java b/src/main/java/org/leavesmc/leaves/LeavesConfig.java
new file mode 100644
index 0000000000000000000000000000000000000000..57bd1c9b79f7be0a63ca9a3f9d1360fa6df16463
index 0000000000000000000000000000000000000000..eced5c887f83602e1050f42de2789266478c70d0
--- /dev/null
+++ b/src/main/java/org/leavesmc/leaves/LeavesConfig.java
@@ -0,0 +1,889 @@
@@ -0,0 +1,895 @@
+package org.leavesmc.leaves;
+
+import com.destroystokyo.paper.util.SneakyThrow;
Expand Down Expand Up @@ -323,6 +323,12 @@ index 0000000000000000000000000000000000000000..57bd1c9b79f7be0a63ca9a3f9d1360fa
+ @GlobalConfig(name = "old-block-entity-behaviour", category = {"modify", "minecraft-old"})
+ public static boolean oldBlockEntityBehaviour = false;
+
+ @GlobalConfig(name = "allow-bad-omen-trigger-raid", category = {"modify", "minecraft-old", "revert-raid-changes"})
+ public static boolean allowBadOmenTriggerRaid = false;
+
+ @GlobalConfig(name = "give-bad-omen-when-kill-patrol-leader", category = {"modify", "minecraft-old", "revert-raid-changes"})
+ public static boolean giveBadOmenWhenKillPatrolLeader = false;
+
+ // Leaves end - modify - minecraft-old
+
+ // Leaves start - modify - elytra-aeronautics
Expand Down
113 changes: 113 additions & 0 deletions patches/server/0133-Revert-raid-changes.patch
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);

0 comments on commit 9d90760

Please sign in to comment.