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
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 e81774a2fbcafb5909b966f71d31379c8b5a7426..229daac5767e8d65b2d0c37303d3490ef97e21ff 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
|