mirror of
https://github.com/PaperMC/Folia.git
synced 2024-11-22 12:05:12 +01:00
44 lines
2.8 KiB
Diff
44 lines
2.8 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: WillQi <williamqipizza@gmail.com>
|
|
Date: Mon, 15 May 2023 23:45:09 -0600
|
|
Subject: [PATCH] Fix off region raid heroes
|
|
|
|
This patch aims to solve a potential incorrect thread call when completing a raid.
|
|
If a player is a hero of the village but proceeds to leave the region of the
|
|
raid before it's completion, it would throw an exception due to not being on the
|
|
same region thread anymore.
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/raid/Raid.java b/src/main/java/net/minecraft/world/entity/raid/Raid.java
|
|
index 113583d0d9de744e314bc7ee15cb8e21ec4a92f9..ddec5251b335a25cb9d8726396d90d94572dbd6b 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/raid/Raid.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/raid/Raid.java
|
|
@@ -407,12 +407,25 @@ public class Raid {
|
|
if (entity instanceof LivingEntity && !entity.isSpectator()) {
|
|
LivingEntity entityliving = (LivingEntity) entity;
|
|
|
|
- entityliving.addEffect(new MobEffectInstance(MobEffects.HERO_OF_THE_VILLAGE, 48000, this.badOmenLevel - 1, false, false, true));
|
|
+ // Folia start - Fix off region raid heroes
|
|
+ entityliving.getBukkitLivingEntity().taskScheduler.schedule(task -> {
|
|
+ entityliving.addEffect(new MobEffectInstance(MobEffects.HERO_OF_THE_VILLAGE, 48000, this.badOmenLevel - 1, false, false, true));
|
|
+
|
|
+ if (entityliving instanceof ServerPlayer) {
|
|
+ ServerPlayer entityplayer = (ServerPlayer) entityliving;
|
|
+
|
|
+ entityplayer.awardStat(Stats.RAID_WIN);
|
|
+ CriteriaTriggers.RAID_WIN.trigger(entityplayer);
|
|
+ }
|
|
+ }, null, 0);
|
|
+ // Folia end
|
|
if (entityliving instanceof ServerPlayer) {
|
|
ServerPlayer entityplayer = (ServerPlayer) entityliving;
|
|
|
|
- entityplayer.awardStat(Stats.RAID_WIN);
|
|
- CriteriaTriggers.RAID_WIN.trigger(entityplayer);
|
|
+ // Folia start - Fix off region raid heroes
|
|
+ // entityplayer.awardStat(Stats.RAID_WIN);
|
|
+ // CriteriaTriggers.RAID_WIN.trigger(entityplayer);
|
|
+ // Folia end
|
|
winners.add(entityplayer.getBukkitEntity()); // CraftBukkit
|
|
}
|
|
}
|