mirror of
https://github.com/LeavesMC/Leaves.git
synced 2025-12-19 14:59:32 +00:00
* init 1.21.4, and boom! * build change, but weight not work * just work * Build changes, and delete timings * Fix API patches (#406) * Fix API patches * merge --------- Co-authored-by: violetc <58360096+s-yh-china@users.noreply.github.com> * 0006/0129 * 0009/0129 * 0011/0129 * 0018/0129 * 0030/0129 * 0035/0129 * 0043/0129 * 0048/0129 * 0049/0129 * 0057/0129 * 0065/0129 * 0086/0129 (#408) * 0072/0129 * 0080/0129 * Readd patch infos * 0086/0129 * Delete applied patches * 0087/0129 * 0091/0129 * 0097/0129 * 0101/0129 * 102/129 * 0107/0129 * 0112/0129 * 0118/0129 * 0129/0129, 100% patched * fix some * server work * Protocol... (#409) * Jade v7 * Fix changed part for Jade * Formatting imports, add Lms Paster protocol * REI payloads 5/8 * Add REI support, remove unnecessary content in Jade * Rename * Make jade better * Make action work * fix action jar * Fix some protocol * Fix bot action, and entity tickCount * Fix Warden GameEventListener register on load * Fix extra Raider drop * Fix grindstone overstacking * Update Paper, and some doc * Merge * [ci skip] Update Action --------- Co-authored-by: Lumine1909 <133463833+Lumine1909@users.noreply.github.com>
92 lines
4.7 KiB
Diff
92 lines
4.7 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: violetc <58360096+s-yh-china@users.noreply.github.com>
|
|
Date: Thu, 20 Jul 2023 15:18:50 +0800
|
|
Subject: [PATCH] Optimize sun burn tick
|
|
|
|
This patch is Powered by Gale(https://github.com/GaleMC/Gale)
|
|
|
|
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
|
index 92f363180ed4d2a91da996de9e8adfa4f3b17e69..cbb3062d1bfd9d9695e0d72df3f91ad084e043c2 100644
|
|
--- a/net/minecraft/world/entity/Entity.java
|
|
+++ b/net/minecraft/world/entity/Entity.java
|
|
@@ -2039,10 +2039,22 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
|
|
@Deprecated
|
|
public float getLightLevelDependentMagicValue() {
|
|
- return this.level().hasChunkAt(this.getBlockX(), this.getBlockZ())
|
|
- ? this.level().getLightLevelDependentMagicValue(BlockPos.containing(this.getX(), this.getEyeY(), this.getZ()))
|
|
- : 0.0F;
|
|
+ // Leaves start - optimize sun burn tick
|
|
+ if (!org.leavesmc.leaves.LeavesConfig.performance.optimizeSunBurnTick) {
|
|
+ return this.level().hasChunkAt(this.getBlockX(), this.getBlockZ()) ? this.level().getLightLevelDependentMagicValue(BlockPos.containing(this.getX(), this.getEyeY(), this.getZ())) : 0.0F;
|
|
+ } else {
|
|
+ return this.getLightLevelDependentMagicValue(BlockPos.containing(this.getX(), this.getEyeY(), this.getZ()));
|
|
+ }
|
|
+ // Leaves end - optimize sun burn tick
|
|
+ }
|
|
+
|
|
+ // Leaves start - optimize sun burn tick
|
|
+ /** @deprecated */
|
|
+ @Deprecated
|
|
+ public float getLightLevelDependentMagicValue(BlockPos pos) {
|
|
+ return this.level().hasChunkAt(this.getBlockX(), this.getBlockZ()) ? this.level.getLightLevelDependentMagicValue(pos) : 0.0F;
|
|
}
|
|
+ // Leaves end - optimize sun burn tick
|
|
|
|
public void absMoveTo(double x, double y, double z, float yRot, float xRot) {
|
|
this.absMoveTo(x, y, z);
|
|
diff --git a/net/minecraft/world/entity/Mob.java b/net/minecraft/world/entity/Mob.java
|
|
index b694ea0a5fee852c31ff503a42e50a999c5a287b..6810037ab23e79986ef0f5d959bc317142df67cd 100644
|
|
--- a/net/minecraft/world/entity/Mob.java
|
|
+++ b/net/minecraft/world/entity/Mob.java
|
|
@@ -1627,20 +1627,40 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab
|
|
protected void playAttackSound() {
|
|
}
|
|
|
|
+ // Leaves start - optimize sun burn tick
|
|
+ private BlockPos cached_eye_blockpos;
|
|
+ private int cached_position_hashcode;
|
|
+ // Leaves end - optimize sun burn tick
|
|
+
|
|
public boolean isSunBurnTick() {
|
|
if (this.level().isDay() && !this.level().isClientSide) {
|
|
- float lightLevelDependentMagicValue = this.getLightLevelDependentMagicValue();
|
|
- BlockPos blockPos = BlockPos.containing(this.getX(), this.getEyeY(), this.getZ());
|
|
- boolean flag = this.isInWaterRainOrBubble() || 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;
|
|
+ // Leaves start - optimize sun burn tick
|
|
+ if (!org.leavesmc.leaves.LeavesConfig.performance.optimizeSunBurnTick) {
|
|
+ float f = this.getLightLevelDependentMagicValue();
|
|
+ BlockPos blockposition = BlockPos.containing(this.getX(), this.getEyeY(), this.getZ());
|
|
+ boolean flag = this.isInWaterRainOrBubble() || this.isInPowderSnow || this.wasInPowderSnow;
|
|
+
|
|
+ if (f > 0.5F && this.random.nextFloat() * 30.0F < (f - 0.4F) * 2.0F && !flag && this.level().canSeeSky(blockposition)) {
|
|
+ return true;
|
|
+ }
|
|
+ } else {
|
|
+ int positionHashCode = this.position().hashCode();
|
|
+ if (this.cached_position_hashcode != positionHashCode) {
|
|
+ this.cached_eye_blockpos = BlockPos.containing(this.getX(), this.getEyeY(), this.getZ());
|
|
+ this.cached_position_hashcode = positionHashCode;
|
|
+ }
|
|
+
|
|
+ float f = this.getLightLevelDependentMagicValue(cached_eye_blockpos); // Pass BlockPos to getBrightness
|
|
+
|
|
+ // Check brightness first
|
|
+ if (f <= 0.5F) return false;
|
|
+ if (this.random.nextFloat() * 30.0F >= (f - 0.4F) * 2.0F) return false;
|
|
+ boolean flag = this.isInWaterRainOrBubble() || this.isInPowderSnow || this.wasInPowderSnow;
|
|
+ return !flag && this.level().canSeeSky(this.cached_eye_blockpos);
|
|
}
|
|
}
|
|
-
|
|
return false;
|
|
+ // Leaves end - optimize sun burn tick
|
|
}
|
|
|
|
@Override
|