9
0
mirror of https://github.com/BX-Team/DivineMC.git synced 2025-12-19 14:59:25 +00:00
Files
DivineMC/divinemc-server/minecraft-patches/features/0050-Optimize-suffocation.patch
Artem Ostrasev 109c57a637 1.21.6 (#25)
* start 1.21.6 update

* change workflow

* apply some patches

* set experimental to true

* some compile fixes

* Updated Upstream (Purpur)

Upstream has released updates that appear to apply and compile correctly

Purpur Changes:
PurpurMC/Purpur@5d3463aa Updated Upstream (Paper)

* Updated Upstream (Purpur)

Upstream has released updates that appear to apply and compile correctly

Purpur Changes:
PurpurMC/Purpur@5d3463aa Updated Upstream (Paper)

* remove data converter for 1.21.6; move clumps to unapplied

* Updated Upstream (Purpur)

Upstream has released updates that appear to apply and compile correctly

* Updated Upstream (Purpur)

Upstream has released updates that appear to apply and compile correctly

* Update upstream

* Update upstream

* update to 1.21.6-pre4

* update patches

* fix compile

* set readme version to 1.21.6

* Updated Upstream (Purpur)

Upstream has released updates that appear to apply and compile correctly

Purpur Changes:
PurpurMC/Purpur@439f15db Updated Upstream (Paper)
PurpurMC/Purpur@46a28b93 [ci/skip] update version in README
2025-06-18 17:36:28 +03:00

35 lines
2.0 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
Date: Wed, 11 Jun 2025 16:40:43 +0300
Subject: [PATCH] Optimize suffocation
Original license: GPL v3
Original project: https://github.com/pufferfish-gg/Pufferfish
diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java
index 16a3cd813997456ca67a382a8277eca02dc6662f..3cf377f87e8b7f672ea247728365eb61f47bc3ac 100644
--- a/net/minecraft/world/entity/LivingEntity.java
+++ b/net/minecraft/world/entity/LivingEntity.java
@@ -420,6 +420,12 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin
return this.getDeltaMovement().y() < 1.0E-5F && this.isInLiquid();
}
+ // DivineMC start - Optimize suffocation
+ public boolean couldPossiblyBeHurt(float amount) {
+ return !((float) this.invulnerableTime > (float) this.invulnerableDuration / 2.0F) || !(amount <= this.lastHurt);
+ }
+ // DivineMC end - Optimize suffocation
+
@Override
public void baseTick() {
this.oAttackAnim = this.attackAnim;
@@ -438,7 +444,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin
if (this.isAlive() && this.level() instanceof ServerLevel serverLevel1) {
boolean flag = this instanceof Player;
- if (this.isInWall()) {
+ if ((!org.bxteam.divinemc.config.DivineConfig.PerformanceCategory.enableSuffocationOptimization || this instanceof WitherBoss || (tickCount % 10 == 0 && couldPossiblyBeHurt(1.0F))) && this.isInWall()) { // DivineMC - 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().getDamageSafeZone();