mirror of
https://github.com/Dreeam-qwq/Gale.git
synced 2026-01-04 15:31:45 +00:00
Add first bootstrap patches
This commit is contained in:
86
patches/server/0036-Reduce-in-wall-checks.patch
Normal file
86
patches/server/0036-Reduce-in-wall-checks.patch
Normal file
@@ -0,0 +1,86 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MartijnMuijsers <martijnmuijsers@live.nl>
|
||||
Date: Thu, 24 Nov 2022 10:31:38 +0100
|
||||
Subject: [PATCH] Reduce in wall checks
|
||||
|
||||
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
This patch is based on the following patch:
|
||||
"Optimize suffocation"
|
||||
By: Kevin Raneri <kevin.raneri@gmail.com>
|
||||
As part of: Pufferfish (https://github.com/pufferfish-gg/Pufferfish)
|
||||
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
* Pufferfish description *
|
||||
|
||||
The isInWall check to determine suffocation is quite expensive, and
|
||||
often is completely unnecessary to check. We do two things here to
|
||||
improve this:
|
||||
|
||||
1. We only check for suffocation once per 20 ticks. The maximum
|
||||
no-damage ticks value means that this change should be extremely
|
||||
difficult, if not impossible, for players to notice.
|
||||
|
||||
2. We additionally execute a check to see if the player can even take
|
||||
damage in the first place. This check doesn't improve performance much
|
||||
but is so much cheaper than the suffocation check that it's worth
|
||||
keeping it.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
index 842f12ad6106eaa9a5bde69d3702abcac4d347b1..69b04b9e92985eef2a23a497387249c31918a7d8 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -399,7 +399,10 @@ public abstract class LivingEntity extends Entity {
|
||||
if (this.isAlive()) {
|
||||
boolean flag = this instanceof net.minecraft.world.entity.player.Player;
|
||||
|
||||
- if (this.isInWall()) {
|
||||
+ // Gale start - Pufferfish - reduce in wall checks
|
||||
+ long checkStuckInWallInterval = this.level.galeConfig().smallOptimizations.reducedIntervals.checkStuckInWall;
|
||||
+ if ((checkStuckInWallInterval <= 1 || (tickCount % checkStuckInWallInterval == 0 && couldPossiblyBeHurt(1.0F))) && this.isInWall()) {
|
||||
+ // Gale end - Pufferfish - reduce in wall checks
|
||||
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 +1316,15 @@ public abstract class LivingEntity extends Entity {
|
||||
return this.getHealth() <= 0.0F;
|
||||
}
|
||||
|
||||
+ // Gale start - Pufferfish - reduce in wall checks
|
||||
+ public boolean couldPossiblyBeHurt(float amount) {
|
||||
+ if ((float) this.invulnerableTime > (float) this.invulnerableDuration / 2.0F && amount <= this.lastHurt) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ return true;
|
||||
+ }
|
||||
+ // Gale end - Pufferfish - reduce in wall checks
|
||||
+
|
||||
@Override
|
||||
public boolean hurt(DamageSource source, float amount) {
|
||||
if (this.isInvulnerableTo(source)) {
|
||||
diff --git a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
|
||||
index a277e64b3bcfe3add3d3652b65255c8c91cdbdd8..870ca1a1d96b0554294a9fe27fc2abb9747f29f8 100644
|
||||
--- a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
|
||||
+++ b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
|
||||
@@ -101,6 +101,21 @@ public class GaleWorldConfiguration extends ConfigurationPart {
|
||||
public int acquirePoiForStuckEntity = 200;
|
||||
// Gale end - Airplane - reduce acquire POI for stuck entities
|
||||
|
||||
+ // Gale start - Pufferfish - reduce in wall checks
|
||||
+ /**
|
||||
+ * Interval at which to check whether an entity is stuck in a wall, to deal suffocation damage.
|
||||
+ * Since after dealing damage, there is an interval (this may change in the future, but approximately
|
||||
+ * 1 second) at which entities cannot take repeated damage, delaying the suffocation check by less is
|
||||
+ * almost unnoticeable.
|
||||
+ * Any value <= 0 behaves like 1.
|
||||
+ * <ul>
|
||||
+ * <li><i>Default</i>: 10 (twice per second)</li>
|
||||
+ * <li><i>Vanilla</i>: 1</li>
|
||||
+ * </ul>
|
||||
+ */
|
||||
+ public int checkStuckInWall = 10;
|
||||
+ // Gale end - Pufferfish - reduce in wall checks
|
||||
+
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user