149 lines
7.7 KiB
Diff
149 lines
7.7 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Helvetica Volubi <suisuroru@blue-millennium.fun>
|
|
Date: Tue, 29 Apr 2025 23:03:56 +0800
|
|
Subject: [PATCH] Add config to enable Cross Region Damage trace
|
|
|
|
|
|
diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java
|
|
index d9ea3db817878ff56a2772ce983ff95431e1326c..fd4e37719baced819100f7ad2d1cf0350950cb60 100644
|
|
--- a/net/minecraft/server/level/ServerPlayer.java
|
|
+++ b/net/minecraft/server/level/ServerPlayer.java
|
|
@@ -1378,6 +1378,13 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
|
this.awardStat(Stats.ENTITY_KILLED_BY.get(killCredit.getType()));
|
|
killCredit.awardKillScore(this, cause);
|
|
this.createWitherRose(killCredit);
|
|
+ // Luminol Start - Cross Region Damage trace
|
|
+ } else if (me.earthme.luminol.config.modules.experiment.EntityDamageSourceTraceConfig.enabled) {
|
|
+ final LivingEntity entitylivingnew = this.getKillCreditOrigin();
|
|
+ if (entitylivingnew != null) {
|
|
+ this.damageTransferToAsync(entitylivingnew, cause);
|
|
+ }
|
|
+ // Luminol End - Cross Region Damage trace
|
|
}
|
|
|
|
this.level().broadcastEntityEvent(this, (byte)3);
|
|
@@ -1392,6 +1399,24 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
|
this.setClientLoaded(false);
|
|
}
|
|
|
|
+ // Luminol Start - Cross Region Damage trace
|
|
+ private void damageTransferToAsync(LivingEntity entity, DamageSource cause) {
|
|
+ // Operations running on current entity
|
|
+ this.awardStat(Stats.ENTITY_KILLED_BY.get(entity.getType()));
|
|
+ this.createWitherRose(entity);
|
|
+
|
|
+ // the entity might be in another tickregion sometimes, so we need to schedule the task onto the entity
|
|
+ // to ensure thread safe
|
|
+ entity.getBukkitEntity().taskScheduler.schedule((LivingEntity nmsEntity) -> {
|
|
+ try {
|
|
+ nmsEntity.awardKillScore(this, cause);
|
|
+ } catch (Throwable ex) {
|
|
+ LOGGER.error(ex.getMessage(), ex);
|
|
+ }
|
|
+ }, null, 1L );
|
|
+ }
|
|
+ // Luminol End - Cross Region Damage trace
|
|
+
|
|
// Leaves start - exp fix
|
|
private boolean shouldDropExperience(boolean eventResult, boolean forceUseEvent) {
|
|
if (forceUseEvent) {
|
|
diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java
|
|
index 658aa09aecf8d64145feedb82dc9be2a55201450..ccb1541e5ea0acf7ec34084a041652e2139ee724 100644
|
|
--- a/net/minecraft/world/entity/LivingEntity.java
|
|
+++ b/net/minecraft/world/entity/LivingEntity.java
|
|
@@ -1181,6 +1181,29 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
|
}
|
|
}
|
|
|
|
+ // Luminol Start - raid revert adapt Cross Region Damage trace
|
|
+ public boolean addEffect(MobEffectInstance effectInstance, @Nullable Entity entity, EntityPotionEffectEvent.Cause cause, boolean fireEvent, boolean async) {
|
|
+ if (ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(entity)) {
|
|
+ return addEffect(effectInstance, entity, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.PATROL_CAPTAIN, true);
|
|
+ } else if (me.earthme.luminol.config.modules.experiment.EntityDamageSourceTraceConfig.enabled) {
|
|
+ postToEntityThreadAddEffect(effectInstance, entity, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.PATROL_CAPTAIN, true);
|
|
+ return true;
|
|
+ }
|
|
+ return false;
|
|
+ }
|
|
+
|
|
+ private void postToEntityThreadAddEffect(MobEffectInstance effectInstance, @Nullable Entity entity, EntityPotionEffectEvent.Cause cause, boolean fireEvent) {
|
|
+ if (entity != null)
|
|
+ entity.getBukkitEntity().taskScheduler.schedule((Entity nmsEntity) -> {
|
|
+ try {
|
|
+ addEffect(effectInstance, nmsEntity, cause, fireEvent);
|
|
+ } catch (Throwable ex) {
|
|
+ LOGGER.error(ex.getMessage(), ex);
|
|
+ }
|
|
+ }, null, 1L );
|
|
+ }
|
|
+ // Luminol End - raid revert adapt Cross Region Damage trace
|
|
+
|
|
public boolean canBeAffected(MobEffectInstance effectInstance) {
|
|
if (this.getType().is(EntityTypeTags.IMMUNE_TO_INFESTED)) {
|
|
return !effectInstance.is(MobEffects.INFESTED);
|
|
@@ -1831,6 +1854,13 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
|
final LivingEntity entityliving = this.getKillCredit();
|
|
if (entityliving != null) {
|
|
entityliving.awardKillScore(this, damageSource);
|
|
+ // Luminol Start - Cross Region Damage trace
|
|
+ } else if (me.earthme.luminol.config.modules.experiment.EntityDamageSourceTraceConfig.enabled) {
|
|
+ final LivingEntity entitylivingnew = this.getKillCreditOrigin();
|
|
+ if (entitylivingnew != null) {
|
|
+ this.damageTransferToAsync(entitylivingnew, damageSource);
|
|
+ }
|
|
+ // Luminol End - Cross Region Damage trace
|
|
}
|
|
}); // Paper end
|
|
this.postDeathDropItems(deathEvent); // Paper
|
|
@@ -1841,6 +1871,18 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
|
return deathEvent; // Paper
|
|
}
|
|
|
|
+ // Luminol Start - Cross Region Damage trace
|
|
+ private void damageTransferToAsync(LivingEntity entity, DamageSource damageSource) {
|
|
+ entity.getBukkitEntity().taskScheduler.schedule((LivingEntity nmsEntity) -> {
|
|
+ try {
|
|
+ nmsEntity.awardKillScore(this, damageSource);
|
|
+ } catch (Throwable ex) {
|
|
+ LOGGER.error(ex.getMessage(), ex);
|
|
+ }
|
|
+ }, null, 1L );
|
|
+ }
|
|
+ // Luminol End - Cross Region Damage trace
|
|
+
|
|
protected void dropEquipment(ServerLevel level) {
|
|
}
|
|
protected void postDeathDropItems(org.bukkit.event.entity.EntityDeathEvent event) {} // Paper - method for post death logic that cannot be ran before the event is potentially cancelled
|
|
@@ -2474,6 +2516,18 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
|
}
|
|
}
|
|
|
|
+ // Luminol Start - Cross Region Damage trace
|
|
+ @Nullable
|
|
+ public LivingEntity getKillCreditOrigin() {
|
|
+ if (this.lastHurtByPlayer != null) {
|
|
+ return this.lastHurtByPlayer;
|
|
+ } else if (this.lastHurtByMob != null) {
|
|
+ return this.lastHurtByMob;
|
|
+ }
|
|
+ return null;
|
|
+ }
|
|
+ // Luminol End - Cross Region Damage trace
|
|
+
|
|
public final float getMaxHealth() {
|
|
return (float)this.getAttributeValue(Attributes.MAX_HEALTH);
|
|
}
|
|
diff --git a/net/minecraft/world/item/component/OminousBottleAmplifier.java b/net/minecraft/world/item/component/OminousBottleAmplifier.java
|
|
index 5607d2f21131510563f8fdc9079d1145483b11df..f709880a8c1064298aa133617055e7aa5cc2be5e 100644
|
|
--- a/net/minecraft/world/item/component/OminousBottleAmplifier.java
|
|
+++ b/net/minecraft/world/item/component/OminousBottleAmplifier.java
|
|
@@ -28,7 +28,7 @@ public record OminousBottleAmplifier(int value) implements ConsumableListener, T
|
|
|
|
@Override
|
|
public void onConsume(Level level, LivingEntity entity, ItemStack stack, Consumable consumable) {
|
|
- entity.addEffect(new MobEffectInstance(MobEffects.BAD_OMEN, 120000, this.value, false, false, true)); // Paper - properly resend entities - diff on change for below
|
|
+ entity.addEffect(new MobEffectInstance(MobEffects.BAD_OMEN, me.earthme.luminol.config.modules.misc.RaidChangesConfig.infinite ? net.minecraft.world.effect.MobEffectInstance.INFINITE_DURATION : 120000, this.value, false, false, true)); // Paper - properly resend entities - diff on change for below // Luminol - Raid effect infinite
|
|
}
|
|
|
|
// Paper start - properly resend entities - collect packets for bundle
|