mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-25 18:09:17 +00:00
fix: air supply increase underwater from incorrect eye Y position
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: hayanesuru <hayanesuru@outlook.jp>
|
||||
Date: Sat, 9 Aug 2025 15:43:24 +0900
|
||||
Subject: [PATCH] optimize get eye block position
|
||||
Subject: [PATCH] cache eye block position
|
||||
|
||||
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index bb16f3ebffcafcb11d3112e03f5767ac71b359f6..22b7b1bd62f730a760ce0cf0a2ddb701324e3c3e 100644
|
||||
index bb16f3ebffcafcb11d3112e03f5767ac71b359f6..29fa9cfa1aa2d507da852f5fe33ea6e4143da194 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -553,20 +553,14 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
@@ -15,7 +15,7 @@ index bb16f3ebffcafcb11d3112e03f5767ac71b359f6..22b7b1bd62f730a760ce0cf0a2ddb701
|
||||
- private BlockPos cached_eye_blockpos;
|
||||
- private net.minecraft.world.phys.Vec3 cached_position;
|
||||
+ private BlockPos leaf$cached_eye_blockpos = BlockPos.ZERO;
|
||||
+ @Nullable private BlockPos leaf$cached_position = null;
|
||||
+ @Nullable private Vec3 leaf$cached_position = null;
|
||||
// Gale end - JettPack - optimize sun burn tick - cache eye blockpos
|
||||
// Purpur start - copied from Mob - API for any mob to burn daylight
|
||||
public boolean isSunBurnTick() {
|
||||
@@ -32,7 +32,7 @@ index bb16f3ebffcafcb11d3112e03f5767ac71b359f6..22b7b1bd62f730a760ce0cf0a2ddb701
|
||||
// Check brightness first
|
||||
if (lightLevelDependentMagicValue <= 0.5F) return false;
|
||||
if (this.random.nextFloat() * 30.0F >= (lightLevelDependentMagicValue - 0.4F) * 2.0F) return false;
|
||||
@@ -574,11 +568,22 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
@@ -574,11 +568,29 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
|
||||
boolean flag = this.isInWaterOrRain() || this.isInPowderSnow || this.wasInPowderSnow;
|
||||
|
||||
@@ -43,20 +43,27 @@ index bb16f3ebffcafcb11d3112e03f5767ac71b359f6..22b7b1bd62f730a760ce0cf0a2ddb701
|
||||
return false; // Gale - JettPack - optimize sun burn tick - optimizations and cache eye blockpos - diff on change
|
||||
}
|
||||
+
|
||||
+ // Leaf start
|
||||
+ // Leaf start - cache eye block pos
|
||||
+ public BlockPos leaf$getEyeBlockPos() {
|
||||
+ if (this.leaf$cached_position != this.blockPosition) {
|
||||
+ this.leaf$cached_eye_blockpos = this.blockPosition.atY(Mth.floor(this.getEyeY()));
|
||||
+ this.leaf$cached_position = this.blockPosition;
|
||||
+ if (this.leaf$cached_position != this.position) {
|
||||
+ double eyeY = this.getEyeY();
|
||||
+ int x = Mth.floor(this.getX());
|
||||
+ int y = Mth.floor(eyeY);
|
||||
+ int z = Mth.floor(this.getZ());
|
||||
+ BlockPos o = leaf$cached_eye_blockpos;
|
||||
+ if (o.getX() != x || o.getY() != y || o.getZ() != z) {
|
||||
+ this.leaf$cached_eye_blockpos = new BlockPos(x, y, z);
|
||||
+ }
|
||||
+ this.leaf$cached_position = this.position;
|
||||
+ }
|
||||
+ return this.leaf$cached_eye_blockpos;
|
||||
+ }
|
||||
+ // Leaf end
|
||||
+ // Leaf end - cache eye block pos
|
||||
+
|
||||
// Purpur end - copied from Mob - API for any mob to burn daylight
|
||||
// Leaf end - Fix Pufferfish and Purpur patches
|
||||
|
||||
@@ -2151,8 +2156,9 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
@@ -2151,8 +2163,9 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
&& abstractBoat.getBoundingBox().maxY >= eyeY
|
||||
&& abstractBoat.getBoundingBox().minY <= eyeY
|
||||
)) {
|
||||
@@ -68,7 +75,7 @@ index bb16f3ebffcafcb11d3112e03f5767ac71b359f6..22b7b1bd62f730a760ce0cf0a2ddb701
|
||||
double d = blockPos.getY() + fluidState.getHeight(this.level(), blockPos);
|
||||
if (d > eyeY) {
|
||||
// Leaf start - Optimize isEyeInFluid
|
||||
@@ -2280,20 +2286,10 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
@@ -2280,20 +2293,10 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
|
||||
@Deprecated
|
||||
public float getLightLevelDependentMagicValue() {
|
||||
@@ -91,7 +98,7 @@ index bb16f3ebffcafcb11d3112e03f5767ac71b359f6..22b7b1bd62f730a760ce0cf0a2ddb701
|
||||
|
||||
public void absSnapTo(double x, double y, double z, float yRot, float xRot) {
|
||||
this.absSnapTo(x, y, z);
|
||||
@@ -4531,6 +4527,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
@@ -4531,6 +4534,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
EntityDimensions dimensions = this.getDimensions(pose);
|
||||
this.dimensions = dimensions;
|
||||
this.eyeHeight = dimensions.eyeHeight();
|
||||
@@ -99,7 +106,7 @@ index bb16f3ebffcafcb11d3112e03f5767ac71b359f6..22b7b1bd62f730a760ce0cf0a2ddb701
|
||||
}
|
||||
|
||||
public void refreshDimensions() {
|
||||
@@ -4539,6 +4536,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
@@ -4539,6 +4543,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
EntityDimensions dimensions = this.getDimensions(pose);
|
||||
this.dimensions = dimensions;
|
||||
this.eyeHeight = dimensions.eyeHeight();
|
||||
@@ -5,10 +5,10 @@ Subject: [PATCH] optimize updateFluidHeightAndDoFluidPushing
|
||||
|
||||
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index 22b7b1bd62f730a760ce0cf0a2ddb701324e3c3e..2d3998b547a5593703788f7a532f960f6054b7c9 100644
|
||||
index 29fa9cfa1aa2d507da852f5fe33ea6e4143da194..0366217ac729a967ba69fb256481479255d347be 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -4932,12 +4932,12 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
@@ -4939,12 +4939,12 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
final int minChunkZ = minBlockZ >> 4;
|
||||
final int maxChunkZ = maxBlockZ >> 4;
|
||||
|
||||
@@ -23,7 +23,7 @@ index 22b7b1bd62f730a760ce0cf0a2ddb701324e3c3e..2d3998b547a5593703788f7a532f960f
|
||||
if (chunk == null) continue;
|
||||
final net.minecraft.world.level.chunk.LevelChunkSection[] sections = chunk.getSections();
|
||||
// Leaf end - Prevent double chunk retrieving in entity fluid pushing check and fluid height updating
|
||||
@@ -4949,7 +4949,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
@@ -4956,7 +4956,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
continue;
|
||||
}
|
||||
final net.minecraft.world.level.chunk.LevelChunkSection section = sections[sectionIdx];
|
||||
@@ -32,7 +32,7 @@ index 22b7b1bd62f730a760ce0cf0a2ddb701324e3c3e..2d3998b547a5593703788f7a532f960f
|
||||
// empty
|
||||
continue;
|
||||
}
|
||||
@@ -5006,7 +5006,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
@@ -5013,7 +5013,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
|
||||
this.fluidHeight.put(fluid, maxHeightDiff);
|
||||
|
||||
|
||||
@@ -5,10 +5,10 @@ Subject: [PATCH] optimize checkInsideBlocks
|
||||
|
||||
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index 2d3998b547a5593703788f7a532f960f6054b7c9..0804d3dc5262350a194c5e6d86c313364b6fba76 100644
|
||||
index 0366217ac729a967ba69fb256481479255d347be..afc9788b69a9398c295a6fe3801b82fb6d6c3384 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -1811,72 +1811,57 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
@@ -1818,72 +1818,57 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
private void checkInsideBlocks(Vec3 vec3, Vec3 vec31, InsideBlockEffectApplier.StepBasedCollector stepBasedCollector, LongSet set) {
|
||||
final Level level = this.level();
|
||||
AABB aabb = this.getBoundingBox().move(vec31.subtract(this.position())).deflate(1.0E-5F);
|
||||
|
||||
@@ -18,10 +18,10 @@ index b94f2122da885fe94bd60c7914421968e6a2f3fa..5178290d060dd8a72f0e6cb77f77d196
|
||||
final net.minecraft.world.level.levelgen.BitRandomSource simpleRandom = this.simpleRandom; // Paper - optimise random ticking // Leaf - Faster random generator - upcasting
|
||||
ChunkPos pos = chunk.getPos();
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index fc1175ae9bf5b59be2575a4e560bb558cbf007f4..46724762116945d9eb8d1692657fe5ef4d7f912b 100644
|
||||
index dcae12c34690346cb32780f7143fe05549c84c11..7140c99edfc2d6fbbd4aff6df5012a4e617b727f 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -1640,8 +1640,8 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
@@ -1647,8 +1647,8 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
|
||||
final AABB currentBox = this.getBoundingBox();
|
||||
|
||||
@@ -32,7 +32,7 @@ index fc1175ae9bf5b59be2575a4e560bb558cbf007f4..46724762116945d9eb8d1692657fe5ef
|
||||
|
||||
final AABB initialCollisionBox;
|
||||
if (xZero & zZero) {
|
||||
@@ -1653,17 +1653,17 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
@@ -1660,17 +1660,17 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
initialCollisionBox = currentBox.expandTowards(movement);
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ index fc1175ae9bf5b59be2575a4e560bb558cbf007f4..46724762116945d9eb8d1692657fe5ef
|
||||
|
||||
final boolean collidedX = collided.x != movement.x;
|
||||
final boolean collidedY = collided.y != movement.y;
|
||||
@@ -1674,6 +1674,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
@@ -1681,6 +1681,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
final double stepHeight;
|
||||
|
||||
if ((!collidedDownwards && !this.onGround) || (!collidedX && !collidedZ) || (stepHeight = (double)this.maxUpStep()) <= 0.0) {
|
||||
@@ -63,7 +63,7 @@ index fc1175ae9bf5b59be2575a4e560bb558cbf007f4..46724762116945d9eb8d1692657fe5ef
|
||||
return collided;
|
||||
}
|
||||
|
||||
@@ -1684,7 +1685,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
@@ -1691,7 +1692,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
}
|
||||
|
||||
final List<VoxelShape> stepVoxels = new ArrayList<>();
|
||||
@@ -72,7 +72,7 @@ index fc1175ae9bf5b59be2575a4e560bb558cbf007f4..46724762116945d9eb8d1692657fe5ef
|
||||
|
||||
ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.getCollisionsForBlocksOrWorldBorder(
|
||||
this.level, (Entity)(Object)this, stepRetrievalBox, stepVoxels, stepAABBs,
|
||||
@@ -1698,6 +1699,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
@@ -1705,6 +1706,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user