9
0
mirror of https://github.com/LeavesMC/Leaves.git synced 2025-12-19 14:59:32 +00:00

Fix spawnInvulnerableTime (#583)

This commit is contained in:
Helvetica Volubi
2025-06-28 07:21:01 +08:00
committed by GitHub
parent 6c07912dd2
commit 2dcf9f8509

View File

@@ -5,14 +5,36 @@ Subject: [PATCH] Spawn invulnerable time
diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java
index d4984c919a88fa930dfec823cd9b471fa47f3565..8a622da26cff56f404b7d8b6131c27c65a31cdfe 100644
index d4984c919a88fa930dfec823cd9b471fa47f3565..9920af965a661f9dc56e5bcd9911de7976134748 100644
--- a/net/minecraft/server/level/ServerPlayer.java
+++ b/net/minecraft/server/level/ServerPlayer.java
@@ -474,6 +474,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
this.adventure$displayName = org.leavesmc.leaves.LeavesConfig.fix.vanillaDisplayName ? io.papermc.paper.adventure.PaperAdventure.asAdventure(this.getDisplayName()) : net.kyori.adventure.text.Component.text(this.getScoreboardName()); // Paper // Leaves - Vanilla display name
this.bukkitPickUpLoot = true;
this.maxHealthCache = this.getMaxHealth();
+ if (org.leavesmc.leaves.LeavesConfig.modify.oldMC.spawnInvulnerableTime) this.invulnerableTime = 60; // Leaves - spawn invulnerable time
@@ -221,6 +221,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
private int lastSentFood = -99999999;
private boolean lastFoodSaturationZero = true;
public int lastSentExp = -99999999;
+ private int spawnInvulnerableTime = 60; // Leaves - spawn invulnerable time
private ChatVisiblity chatVisibility = ChatVisiblity.FULL;
public ParticleStatus particleStatus = ParticleStatus.ALL;
private boolean canChatColor = true;
@@ -751,6 +752,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
this.resetOperationCountPerTick(); // Leaves - player operation limiter
this.gameMode.tick();
this.wardenSpawnTracker.tick();
+ if (this.spawnInvulnerableTime > 0) --this.spawnInvulnerableTime; // Leaves - spawn invulnerable time
if (this.invulnerableTime > 0) {
this.invulnerableTime--;
}
@Override
@@ -1185,6 +1187,13 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
if (this.isInvulnerableTo(level, damageSource)) {
return false;
} else {
+ // Leaves start - spawn invulnerable time
+ if (org.leavesmc.leaves.LeavesConfig.modify.oldMC.spawnInvulnerableTime) {
+ if (this.spawnInvulnerableTime > 0 && !damageSource.is(net.minecraft.tags.DamageTypeTags.BYPASSES_INVULNERABILITY)) {
+ return false;
+ }
+ }
+ // Leaves end - spawn invulnerable time
Entity entity = damageSource.getEntity();
if (!( // Paper - split the if statement. If below statement is false, hurtServer would not have been evaluated. Return false.
!(entity instanceof Player player && !this.canHarmPlayer(player))