9
0
mirror of https://github.com/Dreeam-qwq/Gale.git synced 2025-12-21 07:49:22 +00:00

Check reference instead of the hashcode in sunburn tick optimizations

Co-Authored-By: M2ke4U <79621885+mrhua269@users.noreply.github.com>
This commit is contained in:
Dreeam
2024-12-17 01:08:25 -05:00
parent dcccfce143
commit 883fef72cd

View File

@@ -47,16 +47,16 @@ index 1d81b2eccaf796922e7645be4e388a44efb807dd..8cc3394f951e1560c6944343724fb0d3
this.absMoveTo(x, y, z); this.absMoveTo(x, y, z);
this.absRotateTo(yaw, pitch); this.absRotateTo(yaw, pitch);
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
index 9dbcebe04ad9dd2f5558e92e85749c7026f6d428..06c57db4e6c76945cba514fc27828ff96fcd2c10 100644 index 9dbcebe04ad9dd2f5558e92e85749c7026f6d428..361000909cedb7ae8bfe326e87be750b6916aa62 100644
--- a/src/main/java/net/minecraft/world/entity/Mob.java --- a/src/main/java/net/minecraft/world/entity/Mob.java
+++ b/src/main/java/net/minecraft/world/entity/Mob.java +++ b/src/main/java/net/minecraft/world/entity/Mob.java
@@ -1726,13 +1726,29 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab @@ -1726,13 +1726,28 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab
protected void playAttackSound() {} protected void playAttackSound() {}
+ // Gale start - JettPack - optimize sun burn tick - cache eye blockpos + // Gale start - JettPack - optimize sun burn tick - cache eye blockpos
+ private BlockPos cached_eye_blockpos; + private BlockPos cached_eye_blockpos;
+ private int cached_position_hashcode; + private net.minecraft.world.phys.Vec3 cached_position;
+ // Gale end - JettPack - optimize sun burn tick - cache eye blockpos + // Gale end - JettPack - optimize sun burn tick - cache eye blockpos
+ +
public boolean isSunBurnTick() { public boolean isSunBurnTick() {
@@ -64,10 +64,9 @@ index 9dbcebe04ad9dd2f5558e92e85749c7026f6d428..06c57db4e6c76945cba514fc27828ff9
- float f = this.getLightLevelDependentMagicValue(); - float f = this.getLightLevelDependentMagicValue();
- BlockPos blockposition = BlockPos.containing(this.getX(), this.getEyeY(), this.getZ()); - BlockPos blockposition = BlockPos.containing(this.getX(), this.getEyeY(), this.getZ());
+ // Gale start - JettPack - optimize sun burn tick - optimizations and cache eye blockpos + // Gale start - JettPack - optimize sun burn tick - optimizations and cache eye blockpos
+ int positionHashCode = this.position.hashCode(); + if (this.cached_position != this.position) {
+ if (this.cached_position_hashcode != positionHashCode) {
+ this.cached_eye_blockpos = BlockPos.containing(this.getX(), this.getEyeY(), this.getZ()); + this.cached_eye_blockpos = BlockPos.containing(this.getX(), this.getEyeY(), this.getZ());
+ this.cached_position_hashcode = positionHashCode; + this.cached_position = this.position;
+ } + }
+ +
+ float f = this.getLightLevelDependentMagicValue(cached_eye_blockpos); // Pass BlockPos to getBrightness + float f = this.getLightLevelDependentMagicValue(cached_eye_blockpos); // Pass BlockPos to getBrightness