@@ -28050,7 +28050,7 @@ index 8cc5c0716392ba06501542ff5cbe71ee43979e5d..09fd99c9cbd23b5f3c899bfb00c9b896
28050
28050
+ // Paper end - block counting
28051
28051
}
28052
28052
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
28053
- index 5ee3dc10cb4755fca83d8f7cad55d26b07afd6ff..346d9dfafab6dfe6f8253552d0e89ecd7e190312 100644
28053
+ index 5ee3dc10cb4755fca83d8f7cad55d26b07afd6ff..454f588b166e412a6da9d7991607418d7e100b59 100644
28054
28054
--- a/net/minecraft/world/entity/Entity.java
28055
28055
+++ b/net/minecraft/world/entity/Entity.java
28056
28056
@@ -149,7 +149,7 @@ import net.minecraft.world.waypoints.WaypointTransmitter;
@@ -28551,7 +28551,7 @@ index 5ee3dc10cb4755fca83d8f7cad55d26b07afd6ff..346d9dfafab6dfe6f8253552d0e89ecd
28551
28551
}
28552
28552
28553
28553
public int countPlayerPassengers() {
28554
- @@ -4478,77 +4717,136 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
28554
+ @@ -4478,77 +4717,126 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
28555
28555
return Mth.lerp(partialTick, this.yRotO, this.yRot);
28556
28556
}
28557
28557
@@ -28591,7 +28591,17 @@ index 5ee3dc10cb4755fca83d8f7cad55d26b07afd6ff..346d9dfafab6dfe6f8253552d0e89ecd
28591
28591
- flow = flow.scale(d);
28592
28592
- }
28593
28593
+ }
28594
- +
28594
+
28595
+ - vec3 = vec3.add(flow);
28596
+ - i++;
28597
+ - }
28598
+ - // CraftBukkit start - store last lava contact location
28599
+ - if (fluidTag == FluidTags.LAVA) {
28600
+ - this.lastLavaContact = mutableBlockPos.immutable();
28601
+ - }
28602
+ - // CraftBukkit end
28603
+ - }
28604
+ - }
28595
28605
+ final AABB boundingBox = this.getBoundingBox().deflate(1.0E-3);
28596
28606
+
28597
28607
+ final Level world = this.level;
@@ -28617,81 +28627,65 @@ index 5ee3dc10cb4755fca83d8f7cad55d26b07afd6ff..346d9dfafab6dfe6f8253552d0e89ecd
28617
28627
+ final int minChunkX = minBlockX >> 4;
28618
28628
+ final int maxChunkX = maxBlockX >> 4;
28619
28629
+
28620
- + final int minChunkY = minBlockY >> 4;
28621
- + final int maxChunkY = maxBlockY >> 4;
28622
- +
28623
28630
+ final int minChunkZ = minBlockZ >> 4;
28624
28631
+ final int maxChunkZ = maxBlockZ >> 4;
28625
28632
+
28626
28633
+ final net.minecraft.world.level.chunk.ChunkSource chunkSource = world.getChunkSource();
28627
28634
+
28635
+ + final int chunkLenX = maxChunkX - minChunkX + 1;
28636
+ + // chunk index = (x - minX) + (maxX-minX+1)*(z - minZ)
28637
+ + // = x + (maxX-minX+1)*z - (minX + (maxX-minX+1)*minZ)
28638
+ + final int chunkOffset = -(minChunkX + chunkLenX*minChunkZ);
28639
+ + // = x + (maxX-minX+1)*z + chunkOffset
28640
+ + final net.minecraft.world.level.chunk.LevelChunkSection[][] sections = new net.minecraft.world.level.chunk.LevelChunkSection[chunkLenX * (maxChunkZ - minChunkZ + 1)][];
28641
+ +
28642
+ + // init chunks
28628
28643
+ for (int currChunkZ = minChunkZ; currChunkZ <= maxChunkZ; ++currChunkZ) {
28629
28644
+ for (int currChunkX = minChunkX; currChunkX <= maxChunkX; ++currChunkX) {
28630
- + final net.minecraft.world.level.chunk.LevelChunkSection[] sections = chunkSource.getChunk(currChunkX, currChunkZ, net.minecraft.world.level.chunk.status.ChunkStatus.FULL, false).getSections();
28645
+ + sections[currChunkX + chunkLenX*currChunkZ + chunkOffset] = chunkSource.getChunk(currChunkX, currChunkZ, net.minecraft.world.level.chunk.status.ChunkStatus.FULL, false).getSections();
28646
+ + }
28647
+ + }
28631
28648
+
28632
- + // bound y
28633
- + for (int currChunkY = minChunkY; currChunkY <= maxChunkY; ++currChunkY) {
28634
- + final int sectionIdx = currChunkY - minSection;
28635
- + if (sectionIdx < 0 || sectionIdx >= sections.length) {
28636
- + continue;
28637
- + }
28638
- + final net.minecraft.world.level.chunk.LevelChunkSection section = sections[sectionIdx];
28639
- + if (section.hasOnlyAir()) {
28640
- + // empty
28649
+ + for (int currX = minBlockX; currX <= maxBlockX; ++currX) {
28650
+ + for (int currY = minBlockY; currY <= maxBlockY; ++currY) {
28651
+ + for (int currZ = minBlockZ; currZ <= maxBlockZ; ++currZ) {
28652
+ + final FluidState fluidState = sections[(currX >> 4) + chunkLenX*(currZ >> 4) + chunkOffset][(currY >> 4) - minSection]
28653
+ + .states.get((currX & 15) | ((currZ & 15) << 4) | ((currY & 15) << 8)).getFluidState();
28654
+ +
28655
+ + if (fluidState.isEmpty() || !fluidState.is(fluid)) {
28641
28656
+ continue;
28642
28657
+ }
28643
28658
+
28644
- + final net.minecraft.world.level.chunk.PalettedContainer<net.minecraft.world.level.block.state.BlockState> blocks = section.states ;
28659
+ + mutablePos.set(currX, currY, currZ) ;
28645
28660
+
28646
- + final int minXIterate = currChunkX == minChunkX ? (minBlockX & 15) : 0;
28647
- + final int maxXIterate = currChunkX == maxChunkX ? (maxBlockX & 15) : 15;
28648
- + final int minZIterate = currChunkZ == minChunkZ ? (minBlockZ & 15) : 0;
28649
- + final int maxZIterate = currChunkZ == maxChunkZ ? (maxBlockZ & 15) : 15;
28650
- + final int minYIterate = currChunkY == minChunkY ? (minBlockY & 15) : 0;
28651
- + final int maxYIterate = currChunkY == maxChunkY ? (maxBlockY & 15) : 15;
28652
-
28653
- - vec3 = vec3.add(flow);
28654
- - i++;
28655
- + for (int currY = minYIterate; currY <= maxYIterate; ++currY) {
28656
- + for (int currZ = minZIterate; currZ <= maxZIterate; ++currZ) {
28657
- + for (int currX = minXIterate; currX <= maxXIterate; ++currX) {
28658
- + final FluidState fluidState = blocks.get((currX) | (currZ << 4) | ((currY) << 8)).getFluidState();
28659
- +
28660
- + if (fluidState.isEmpty() || !fluidState.is(fluid)) {
28661
- + continue;
28662
- }
28663
- - // CraftBukkit start - store last lava contact location
28664
- - if (fluidTag == FluidTags.LAVA) {
28665
- - this.lastLavaContact = mutableBlockPos.immutable();
28666
- +
28667
- + mutablePos.set(currX | (currChunkX << 4), currY | (currChunkY << 4), currZ | (currChunkZ << 4));
28661
+ + // CraftBukkit start - store last lava contact location
28662
+ + if (fluid == FluidTags.LAVA) {
28663
+ + this.lastLavaContact = mutablePos.immutable();
28664
+ + }
28665
+ + // CraftBukkit end
28668
28666
+
28669
- + final double height = (double)((float)mutablePos.getY() + fluidState.getHeight(world, mutablePos));
28670
- + final double diff = height - boundingBox.minY;
28667
+ + final double height = (double)((float)currY + fluidState.getHeight(world, mutablePos));
28668
+ + final double diff = height - boundingBox.minY;
28671
28669
+
28672
- + if (diff < 0.0) {
28673
- + continue;
28674
- + }
28670
+ + if (diff < 0.0) {
28671
+ + continue;
28672
+ + }
28675
28673
+
28676
- + inFluid = true;
28677
- + maxHeightDiff = Math.max(maxHeightDiff, diff);
28674
+ + inFluid = true;
28675
+ + maxHeightDiff = Math.max(maxHeightDiff, diff);
28678
28676
+
28679
- + if (!isPushable) {
28680
- + continue;
28681
- + }
28677
+ + if (!isPushable) {
28678
+ + continue;
28679
+ + }
28682
28680
+
28683
- + ++totalPushes;
28681
+ + ++totalPushes;
28684
28682
+
28685
- + final Vec3 flow = fluidState.getFlow(world, mutablePos);
28683
+ + final Vec3 flow = fluidState.getFlow(world, mutablePos);
28686
28684
+
28687
- + if (diff < 0.4) {
28688
- + pushVector = pushVector.add(flow.scale(diff));
28689
- + } else {
28690
- + pushVector = pushVector.add(flow);
28691
- }
28692
- - // CraftBukkit end
28693
- }
28694
- }
28685
+ + if (maxHeightDiff < 0.4) {
28686
+ + pushVector = pushVector.add(flow.scale(maxHeightDiff));
28687
+ + } else {
28688
+ + pushVector = pushVector.add(flow);
28695
28689
}
28696
28690
}
28697
28691
}
@@ -28706,7 +28700,7 @@ index 5ee3dc10cb4755fca83d8f7cad55d26b07afd6ff..346d9dfafab6dfe6f8253552d0e89ecd
28706
28700
- if (!(this instanceof Player)) {
28707
28701
- vec3 = vec3.normalize();
28708
28702
- }
28709
- + if (pushVector.lengthSqr() == 0.0 ) {
28703
+ + if (pushVector == Vec3.ZERO ) {
28710
28704
+ return inFluid;
28711
28705
+ }
28712
28706
@@ -28716,7 +28710,7 @@ index 5ee3dc10cb4755fca83d8f7cad55d26b07afd6ff..346d9dfafab6dfe6f8253552d0e89ecd
28716
28710
- if (Math.abs(deltaMovement.x) < 0.003 && Math.abs(deltaMovement.z) < 0.003 && vec3.length() < 0.0045000000000000005) {
28717
28711
- vec3 = vec3.normalize().scale(0.0045000000000000005);
28718
28712
- }
28719
- + // note: totalPushes != 0 as pushVector != 0
28713
+ + // note: totalPushes != 0 as pushVector was changed
28720
28714
+ pushVector = pushVector.scale(1.0 / totalPushes);
28721
28715
+ final Vec3 currMovement = this.getDeltaMovement();
28722
28716
@@ -28742,7 +28736,7 @@ index 5ee3dc10cb4755fca83d8f7cad55d26b07afd6ff..346d9dfafab6dfe6f8253552d0e89ecd
28742
28736
28743
28737
public boolean touchingUnloadedChunk() {
28744
28738
AABB aabb = this.getBoundingBox().inflate(1.0);
28745
- @@ -4704,6 +5002 ,15 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
28739
+ @@ -4704,6 +4992 ,15 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
28746
28740
}
28747
28741
28748
28742
public final void setPosRaw(double x, double y, double z, boolean forceBoundingBoxUpdate) {
@@ -28758,7 +28752,7 @@ index 5ee3dc10cb4755fca83d8f7cad55d26b07afd6ff..346d9dfafab6dfe6f8253552d0e89ecd
28758
28752
if (!checkPosition(this, x, y, z)) {
28759
28753
return;
28760
28754
}
28761
- @@ -4855,6 +5162 ,12 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
28755
+ @@ -4855,6 +5152 ,12 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
28762
28756
28763
28757
@Override
28764
28758
public final void setRemoved(Entity.RemovalReason removalReason, @Nullable org.bukkit.event.entity.EntityRemoveEvent.Cause cause) { // CraftBukkit - add Bukkit remove cause
@@ -28771,7 +28765,7 @@ index 5ee3dc10cb4755fca83d8f7cad55d26b07afd6ff..346d9dfafab6dfe6f8253552d0e89ecd
28771
28765
org.bukkit.craftbukkit.event.CraftEventFactory.callEntityRemoveEvent(this, cause); // CraftBukkit
28772
28766
final boolean alreadyRemoved = this.removalReason != null; // Paper - Folia schedulers
28773
28767
if (this.removalReason == null) {
28774
- @@ -4865,7 +5178 ,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
28768
+ @@ -4865,7 +5168 ,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
28775
28769
this.stopRiding();
28776
28770
}
28777
28771
@@ -28780,7 +28774,7 @@ index 5ee3dc10cb4755fca83d8f7cad55d26b07afd6ff..346d9dfafab6dfe6f8253552d0e89ecd
28780
28774
this.levelCallback.onRemove(removalReason);
28781
28775
this.onRemoval(removalReason);
28782
28776
// Paper start - Folia schedulers
28783
- @@ -4899,7 +5212 ,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
28777
+ @@ -4899,7 +5202 ,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
28784
28778
public boolean shouldBeSaved() {
28785
28779
return (this.removalReason == null || this.removalReason.shouldSave())
28786
28780
&& !this.isPassenger()
0 commit comments