mirror of
https://github.com/LeavesMC/Leaves.git
synced 2025-12-30 12:29:18 +00:00
37 lines
2.0 KiB
Diff
37 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/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
index 7610b2961d59af006440476f7c91038b9b1c5432..8c34c7f74779774e8627c2eb9d5230ed1980df36 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
@@ -467,7 +467,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
|
|
|
if (world1 instanceof ServerLevel) {
|
|
worldserver1 = (ServerLevel) world1;
|
|
- 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(worldserver1, this.damageSources().inWall(), 1.0F);
|
|
} else if (flag && !this.level().getWorldBorder().isWithinBounds(this.getBoundingBox())) {
|
|
double d1 = this.level().getWorldBorder().getDistanceToBorder(this) + this.level().getWorldBorder().getDamageSafeZone();
|
|
@@ -1437,6 +1437,15 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
|
return this.getHealth() <= 0.0F;
|
|
}
|
|
|
|
+ // Leaves start - optimize suffocation
|
|
+ public boolean couldPossiblyBeHurt(float amount) {
|
|
+ if ((float) this.invulnerableTime > (float) this.invulnerableDuration / 2.0F && amount <= this.lastHurt) {
|
|
+ return false;
|
|
+ }
|
|
+ return true;
|
|
+ }
|
|
+ // Leaves end - optimize suffocation
|
|
+
|
|
@Override
|
|
public boolean hurtServer(ServerLevel world, DamageSource source, float amount) {
|
|
if (this.isInvulnerableTo(world, source)) {
|