mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-29 03:49:21 +00:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: PaperMC/Paper@6bb9dc6b Normalize and trim spaces in Player#performCommand (#12892) PaperMC/Paper@840dd9e1 Fix dialog preconditions (#12895) PaperMC/Paper@9ccc51df Fix legacy pearls forgetting owner on disconnect (#12884) PaperMC/Paper@57c13137 Allow to change despawnInPeaceful (#12880) PaperMC/Paper@a5763618 Add WorldDifficultyChangeEvent (#12471) PaperMC/Paper@dbc367ba Keep non-container slots synced when in container view (#12881)
86 lines
4.5 KiB
Diff
86 lines
4.5 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Martijn Muijsers <martijnmuijsers@live.nl>
|
|
Date: Wed, 30 Nov 2022 23:04:59 +0100
|
|
Subject: [PATCH] Optimize sun burn tick
|
|
|
|
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:
|
|
"some entity micro opts"
|
|
By: Simon Gardling <titaniumtown@gmail.com>
|
|
As part of: JettPack (https://gitlab.com/Titaniumtown/JettPack)
|
|
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
|
|
|
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
|
index 977198e485053847b051b9e9ae60c6d8be6600cc..bb7be7cf6040aa7b5b28fb66f600c487d50019a6 100644
|
|
--- a/net/minecraft/world/entity/Entity.java
|
|
+++ b/net/minecraft/world/entity/Entity.java
|
|
@@ -2087,10 +2087,20 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
|
|
@Deprecated
|
|
public float getLightLevelDependentMagicValue() {
|
|
+ return this.getLightLevelDependentMagicValue(BlockPos.containing(this.getX(), this.getEyeY(), this.getZ())); // Gale - JettPack - optimize sun burn tick - allow passing BlockPos to getLightLevelDependentMagicValue
|
|
+ }
|
|
+
|
|
+ // Gale start - JettPack - optimize sun burn tick - allow passing BlockPos to getLightLevelDependentMagicValue
|
|
+ /**
|
|
+ * @deprecated
|
|
+ */
|
|
+ @Deprecated
|
|
+ public float getLightLevelDependentMagicValue(BlockPos pos) {
|
|
return this.level().hasChunkAt(this.getBlockX(), this.getBlockZ())
|
|
- ? this.level().getLightLevelDependentMagicValue(BlockPos.containing(this.getX(), this.getEyeY(), this.getZ()))
|
|
+ ? this.level.getLightLevelDependentMagicValue(pos)
|
|
: 0.0F;
|
|
}
|
|
+ // Gale end - JettPack - optimize sun burn tick - allow passing BlockPos to getLightLevelDependentMagicValue
|
|
|
|
public void absSnapTo(double x, double y, double z, float yRot, float xRot) {
|
|
this.absSnapTo(x, y, z);
|
|
diff --git a/net/minecraft/world/entity/Mob.java b/net/minecraft/world/entity/Mob.java
|
|
index 4aec1fd4efbb3dd139542c55d06503716723f326..37c6567701fe10011a364b8def9ebf3391376592 100644
|
|
--- a/net/minecraft/world/entity/Mob.java
|
|
+++ b/net/minecraft/world/entity/Mob.java
|
|
@@ -1513,20 +1513,31 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab
|
|
protected void playAttackSound() {
|
|
}
|
|
|
|
+ // Gale start - JettPack - optimize sun burn tick - cache eye blockpos
|
|
+ private BlockPos cached_eye_blockpos;
|
|
+ private net.minecraft.world.phys.Vec3 cached_position;
|
|
+ // Gale end - JettPack - optimize sun burn tick - cache eye blockpos
|
|
public boolean isSunBurnTick() {
|
|
if (this.level().isBrightOutside() && !this.level().isClientSide) {
|
|
- float lightLevelDependentMagicValue = this.getLightLevelDependentMagicValue();
|
|
- BlockPos blockPos = BlockPos.containing(this.getX(), this.getEyeY(), this.getZ());
|
|
- boolean flag = this.isInWaterOrRain() || this.isInPowderSnow || this.wasInPowderSnow;
|
|
- if (lightLevelDependentMagicValue > 0.5F
|
|
- && this.random.nextFloat() * 30.0F < (lightLevelDependentMagicValue - 0.4F) * 2.0F
|
|
- && !flag
|
|
- && this.level().canSeeSky(blockPos)) {
|
|
- return true;
|
|
+ // Gale start - JettPack - optimize sun burn tick - optimizations and cache eye blockpos
|
|
+ if (this.cached_position != this.position) {
|
|
+ this.cached_eye_blockpos = BlockPos.containing(this.getX(), this.getEyeY(), this.getZ());
|
|
+ this.cached_position = this.position;
|
|
}
|
|
+
|
|
+ float lightLevelDependentMagicValue = this.getLightLevelDependentMagicValue(cached_eye_blockpos); // Pass BlockPos to getBrightness
|
|
+
|
|
+ // Check brightness first
|
|
+ if (lightLevelDependentMagicValue <= 0.5F) return false;
|
|
+ if (this.random.nextFloat() * 30.0F >= (lightLevelDependentMagicValue - 0.4F) * 2.0F) return false;
|
|
+ // Gale end - JettPack - optimize sun burn tick - optimizations and cache eye blockpos
|
|
+
|
|
+ boolean flag = this.isInWaterOrRain() || this.isInPowderSnow || this.wasInPowderSnow;
|
|
+
|
|
+ return !flag && this.level().canSeeSky(this.cached_eye_blockpos); // Gale - JettPack - optimize sun burn tick - optimizations and cache eye blockpos
|
|
}
|
|
|
|
- return false;
|
|
+ return false; // Gale - JettPack - optimize sun burn tick - optimizations and cache eye blockpos - diff on change
|
|
}
|
|
|
|
@Override
|