mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-19 15:09:25 +00:00
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 e84081f571190fc00db07bdc9da349b9cfae142a..90f80877f25fd10a62d6ed273aa2ebb4b390f292 100644
|
|
--- a/net/minecraft/world/entity/Entity.java
|
|
+++ b/net/minecraft/world/entity/Entity.java
|
|
@@ -2017,10 +2017,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 7f5981f71e6380c09e40a0c80db6a77e74d5113d..6cc000611dc58a5487034ad87af4156059dd37d7 100644
|
|
--- a/net/minecraft/world/entity/Mob.java
|
|
+++ b/net/minecraft/world/entity/Mob.java
|
|
@@ -1474,20 +1474,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
|