mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2026-01-04 15:41:40 +00:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: PaperMC/Paper@b0da38c2 Repository details in RuntimeException for MavenLibraryResolver#addRepository (#12939) PaperMC/Paper@1922be90 Update custom tags (#12183) PaperMC/Paper@79cf1353 Ignore HopperInventorySearchEvent when it has no listeners (#13009) PaperMC/Paper@ea014f7a feat: add stuckEntityPoiRetryDelay config (#12949) PaperMC/Paper@a9e76749 Support for showNotification in PlayerRecipeDiscoverEvent (#12992) PaperMC/Paper@5622c9dd Expose attribute sentiment (#12974) PaperMC/Paper@42b653b1 Expose more argument types (#12665) PaperMC/Paper@52d9a221 [ci/skip] Fix typo in Display javadoc (#13010) PaperMC/Paper@614e9acf Improve APIs around riptide tridents (#12996) PaperMC/Paper@51706e5a Fixed DyeItem sheep dye hunk
59 lines
3.0 KiB
Diff
59 lines
3.0 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Martijn Muijsers <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)
|
|
Gale - https://galemc.org
|
|
|
|
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/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java
|
|
index bd22f0bca65be702a92641a95e944e43f882e440..1b7d8a8838e9b75bc12ce4b9f30429110e9af913 100644
|
|
--- a/net/minecraft/world/entity/LivingEntity.java
|
|
+++ b/net/minecraft/world/entity/LivingEntity.java
|
|
@@ -433,7 +433,10 @@ 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()) {
|
|
+ // 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.hurtServer(serverLevel1, this.damageSources().inWall(), 1.0F);
|
|
} else if (flag && !serverLevel1.getWorldBorder().isWithinBounds(this.getBoundingBox())) {
|
|
double d = serverLevel1.getWorldBorder().getDistanceToBorder(this) + serverLevel1.getWorldBorder().getDamageSafeZone();
|
|
@@ -1399,6 +1402,12 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin
|
|
return this.getHealth() <= 0.0F;
|
|
}
|
|
|
|
+ // Gale start - Pufferfish - reduce in wall checks
|
|
+ private boolean couldPossiblyBeHurt(float amount) {
|
|
+ return !((float) this.invulnerableTime > (float) this.invulnerableDuration / 2.0F) || !(amount <= this.lastHurt);
|
|
+ }
|
|
+ // Gale end - Pufferfish - reduce in wall checks
|
|
+
|
|
@Override
|
|
public boolean hurtServer(ServerLevel level, DamageSource damageSource, float amount) {
|
|
if (this.isInvulnerableTo(level, damageSource)) {
|