mirror of
https://github.com/LeavesMC/Leaves.git
synced 2025-12-19 14:59:32 +00:00
52 lines
2.7 KiB
Diff
52 lines
2.7 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 476afe131aa60d91a2d43fd04c55ab591b03337b..c23e0c6b740878e035a1b84a31bfaa3a5f469007 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
@@ -399,7 +399,7 @@ public abstract class LivingEntity extends Entity {
|
|
if (this.isAlive()) {
|
|
boolean flag = this instanceof net.minecraft.world.entity.player.Player;
|
|
|
|
- if (this.isInWall()) {
|
|
+ if ((!top.leavesmc.leaves.LeavesConfig.enableSuffocationOptimization || (tickCount % 10 == 0 && couldPossiblyBeHurt(1.0F))) && this.isInWall()) { // Leaves - optimize suffocation
|
|
this.hurt(DamageSource.IN_WALL, 1.0F);
|
|
} else if (flag && !this.level.getWorldBorder().isWithinBounds(this.getBoundingBox())) {
|
|
double d0 = this.level.getWorldBorder().getDistanceToBorder(this) + this.level.getWorldBorder().getDamageSafeZone();
|
|
@@ -1313,6 +1313,15 @@ public abstract class LivingEntity extends Entity {
|
|
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 hurt(DamageSource source, float amount) {
|
|
if (this.isInvulnerableTo(source)) {
|
|
diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
|
|
index 578bbec4431366e55a615ccbb5e7c8d0a50d668b..64fc662bcf102df1fd971e9bc72b96ebfe3cda32 100644
|
|
--- a/src/main/java/top/leavesmc/leaves/LeavesConfig.java
|
|
+++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
|
|
@@ -261,6 +261,10 @@ public final class LeavesConfig {
|
|
optimizeEntityCoordinateKey = getBoolean("settings.performance.optimize-entity-coordinate-key", optimizeEntityCoordinateKey);
|
|
}
|
|
|
|
+ public static boolean enableSuffocationOptimization = true;
|
|
+ private static void enableSuffocationOptimization() {
|
|
+ enableSuffocationOptimization = getBoolean("settings.performance.enable-suffocation-optimization", enableSuffocationOptimization);
|
|
+ }
|
|
|
|
public static final class WorldConfig {
|
|
|