mirror of
https://github.com/LeavesMC/Leaves.git
synced 2025-12-19 14:59:32 +00:00
--------- Co-authored-by: Lumine1909 <133463833+Lumine1909@users.noreply.github.com> Co-authored-by: violetc <58360096+s-yh-china@users.noreply.github.com> Co-authored-by: Helvetica Volubi <88063803+Suisuroru@users.noreply.github.com>
34 lines
2.0 KiB
Diff
34 lines
2.0 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: violetc <58360096+s-yh-china@users.noreply.github.com>
|
|
Date: Sun, 14 Aug 2022 08:25:24 +0800
|
|
Subject: [PATCH] Optimize suffocation
|
|
|
|
This patch is Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish)
|
|
|
|
diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java
|
|
index f4a45a39afae0befa5c6048bb5f2001395d5cbfc..ccc6900644f666729dc47cc0cfcdef66dd65b90a 100644
|
|
--- a/net/minecraft/world/entity/LivingEntity.java
|
|
+++ b/net/minecraft/world/entity/LivingEntity.java
|
|
@@ -440,7 +440,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin
|
|
profilerFiller.push("livingEntityBaseTick");
|
|
if (this.isAlive() && this.level() instanceof ServerLevel serverLevel1) {
|
|
boolean flag = this instanceof Player;
|
|
- if (this.isInWall()) {
|
|
+ if ((!org.leavesmc.leaves.LeavesConfig.performance.enableSuffocationOptimization || this instanceof WitherBoss || (tickCount % 10 == 0 && couldPossiblyBeHurt(1.0F))) && this.isInWall()) { // Leaves - optimize suffocation
|
|
this.hurtServer(serverLevel1, this.damageSources().inWall(), 1.0F);
|
|
} else if (flag && !serverLevel1.getWorldBorder().isWithinBounds(this.getBoundingBox())) {
|
|
double d = serverLevel1.getWorldBorder().getDistanceToBorder(this) + serverLevel1.getWorldBorder().getSafeZone();
|
|
@@ -1411,6 +1411,12 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin
|
|
return this.getHealth() <= 0.0F;
|
|
}
|
|
|
|
+ // Leaves start - optimize suffocation
|
|
+ public boolean couldPossiblyBeHurt(float amount) {
|
|
+ return !((float) this.invulnerableTime > (float) this.invulnerableDuration / 2.0F) || !(amount <= this.lastHurt);
|
|
+ }
|
|
+ // Leaves end - optimize suffocation
|
|
+
|
|
@Override
|
|
public boolean hurtServer(ServerLevel level, DamageSource damageSource, float amount) {
|
|
if (this.isInvulnerableTo(level, damageSource)) {
|