mirror of
https://github.com/Samsuik/Sakura.git
synced 2025-12-28 03:09:07 +00:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: PaperMC/Paper@a24f9b2 1.21.6 dev PaperMC/Paper@457a0a6 Bump version string and protocol version to 1.21.6 release PaperMC/Paper@245b547 Update base to 1.21.6 PaperMC/Paper@b28d77b Update Moonrise to 1.21.6 PaperMC/Paper@8318dcb Update DataConverter to 1.21.6-rc1 PaperMC/Paper@d2b1158 Set correct world access on BSL snapshots PaperMC/Paper@023e6c2 Ensure waypoints are per world PaperMC/Paper@40d5d31 Fix recursively converting JSON Text Components PaperMC/Paper@1fcc416 Implement FeatureHooks#isChunkSent for Moonrise chunk system PaperMC/Paper@e4d7178 Implement WaypointTransmitter#isChunkVisible PaperMC/Paper@8980ead Directly walk text component after converting from JSON PaperMC/Paper@5613ed6 Provide env environment variable and copy spigots sys prop for overriding default repository PaperMC/Paper@62b7f86 Avoid and discourage use of Maven Central as a CDN (#12689) PaperMC/Paper@f5534cb [ci skip] Run generators (#12691) PaperMC/Paper@4781d28 Re-add Log4j Javadocs (#12693) PaperMC/Paper@74fbcce Check type of Material in get/set stats (#12607) PaperMC/Paper@4b3f967 Improve Fix MC-44654 (#12703) PaperMC/Paper@a7dd263 Enable spigot obfuscation support (#12695) PaperMC/Paper@6a51c44 Cleanup Primed TNT Fix (#12704) PaperMC/Paper@839c6a1 Fix #11169 (#12706) PaperMC/Paper@c77d5f9 Fix MC-297591 PaperMC/Paper@219f86e Implement chunk unload delay config option PaperMC/Paper@e4eb69b Do not allow ticket level decreases to be processed asynchronously PaperMC/Paper@71b0c76 Adds support for vanilla negative explosions (#12705) PaperMC/Paper@3750927 [ci skip] Fix PermissionManager#clearPermissions() docs bad wording (#12657) PaperMC/Paper@d61a51e Add ItemType#getBurnDuration() (#12604) PaperMC/Paper@29fc853 Allow empty paths in namespaced keys (#12687) PaperMC/Paper@4419afb fix: Safely handle nanosecond overflow in ClickCallback (#12686) PaperMC/Paper@5652882 Add `isProxyEnabled` method to ServerConfiguration (#12664) PaperMC/Paper@c0dda0e Add `isForceDefaultGameMode` method (#12673) PaperMC/Paper@e714de6 Fix excess slot updates PaperMC/Paper@6d0821d [ci skip] Fix docs for Spawner class and cleanup (#12710) PaperMC/Paper@cceffe3 Release ItemType and BlockType (#12708) PaperMC/Paper@186e9e3 Relocate CommandMap#registerServerAliases() call to after lifecycle events have been run (#12601) PaperMC/Paper@5edcf6d Cleanup/command dispatching (#12713) PaperMC/Paper@803baf0 Support hidden entities in Waypoints (#12715) PaperMC/Paper@1814d8b build: publish to fill (#12717) PaperMC/Paper@e454fef Add support for private constructors in plugin main classes (#12652) PaperMC/Paper@d0e808f Move player to correct position in vehicle move packet handler PaperMC/Paper@46b4b0b Improve keepalive ping system PaperMC/Paper@38c1ddb Add and use FeatureHooks.getAllEntities PaperMC/Paper@2f083ac Ensure player entity schedulers are ticked when they are dead PaperMC/Paper@7c90c7c Optimise EntityScheduler ticking PaperMC/Paper@aa6ee44 Re-add global region scheduler tick erroneously removed in last commit PaperMC/Paper@d7510ef Fix #12722 (#12726) PaperMC/Paper@0caf75f Fix #12721 (#12725) PaperMC/Paper@bee2879 Adventure 4.23.0 (#12690) PaperMC/Paper@692e93a Fix MC-299110 PaperMC/Paper@ea10fa4 Don't mutate the position of Items for MC-4 Fix (#12702) PaperMC/Paper@aa6cd74 Remove unnecesary item check for ServerboundPlayerActionPacket RELEASE_USE_ITEM (#12668) PaperMC/Paper@c9e89f4 Expose arrow velocity in EntityShootBowEvent for mobs (#12688) PaperMC/Paper@7ec3174 Jump out of experimental phase PaperMC/Paper@4e1a255 Update try catch for command handling
111 lines
6.5 KiB
Diff
111 lines
6.5 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Samsuik <kfian294ma4@gmail.com>
|
|
Date: Fri, 8 Nov 2024 19:35:49 +0000
|
|
Subject: [PATCH] Optimise check inside blocks and traverse blocks
|
|
|
|
|
|
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
|
index ee7da44161fee45ce3de26d7e990eab3a3f5ff6e..b804964e620c49130c89d67e0371f06881b95eca 100644
|
|
--- a/net/minecraft/world/entity/Entity.java
|
|
+++ b/net/minecraft/world/entity/Entity.java
|
|
@@ -1936,6 +1936,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
private void checkInsideBlocks(List<Entity.Movement> movements, InsideBlockEffectApplier.StepBasedCollector stepBasedCollector) {
|
|
if (this.isAffectedByBlocks()) {
|
|
LongSet set = this.visitedBlocks;
|
|
+ final net.minecraft.world.level.chunk.ChunkAccess[] chunkCache = new net.minecraft.world.level.chunk.ChunkAccess[4]; // Sakura - optimise check inside blocks
|
|
|
|
for (Entity.Movement movement : movements) {
|
|
Vec3 vec3 = movement.from;
|
|
@@ -1945,12 +1946,12 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
double d = vec31.get(axis);
|
|
if (d != 0.0) {
|
|
Vec3 vec32 = vec3.relative(axis.getPositive(), d);
|
|
- this.checkInsideBlocks(vec3, vec32, stepBasedCollector, set);
|
|
+ this.checkInsideBlocks(vec3, vec32, stepBasedCollector, set, chunkCache); // Sakura - optimise check inside blocks
|
|
vec3 = vec32;
|
|
}
|
|
}
|
|
} else {
|
|
- this.checkInsideBlocks(movement.from(), movement.to(), stepBasedCollector, set);
|
|
+ this.checkInsideBlocks(movement.from(), movement.to(), stepBasedCollector, set, chunkCache); // Sakura - optimise check inside blocks
|
|
}
|
|
}
|
|
|
|
@@ -1958,7 +1959,10 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
}
|
|
}
|
|
|
|
- private void checkInsideBlocks(Vec3 vec3, Vec3 vec31, InsideBlockEffectApplier.StepBasedCollector stepBasedCollector, LongSet set) {
|
|
+ // Sakura start - optimise check inside blocks
|
|
+ private void checkInsideBlocks(Vec3 vec3, Vec3 vec31, InsideBlockEffectApplier.StepBasedCollector stepBasedCollector,
|
|
+ LongSet set, net.minecraft.world.level.chunk.ChunkAccess[] chunkCache) {
|
|
+ // Sakura end - optimise check inside blocks
|
|
// Sakura start - configure cannon physics
|
|
double margin = this.physics.afterOrEqual(1_21_2) ? 1.0E-5f : this.physics.afterOrEqual(1_19_3) ? 1.0E-7 : 0.001;
|
|
AABB aabb = this.makeBoundingBox(vec31).deflate(margin);
|
|
@@ -1972,7 +1976,20 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
if (!this.isAlive()) {
|
|
return false;
|
|
} else {
|
|
- BlockState blockState = this.level().getBlockState(pos);
|
|
+ // Sakura start - optimise check inside blocks
|
|
+ final int chunkX = pos.getX() >> 4;
|
|
+ final int chunkZ = pos.getZ() >> 4;
|
|
+ final int chunkKey = ((chunkX << 2) | chunkZ) & 3;
|
|
+ net.minecraft.world.level.chunk.ChunkAccess chunk = chunkCache[chunkKey];
|
|
+ if (chunk == null || chunk.locX != chunkX || chunk.locZ != chunkZ) {
|
|
+ chunk = this.level().getChunkIfLoadedImmediately(chunkX, chunkZ);
|
|
+ if (chunk == null) {
|
|
+ return true;
|
|
+ }
|
|
+ chunkCache[chunkKey] = chunk;
|
|
+ }
|
|
+ final BlockState blockState = chunk.getBlockState(pos);
|
|
+ // Sakura end - optimise check inside blocks
|
|
if (blockState.isAir()) {
|
|
this.debugBlockIntersection(pos, false, false);
|
|
return true;
|
|
diff --git a/net/minecraft/world/level/BlockGetter.java b/net/minecraft/world/level/BlockGetter.java
|
|
index 67c9393133f4509abf1bd352fbbc8e21dbb116e2..9e235b8bec7ed8da7c0cb099c47c3b23fbccb9b4 100644
|
|
--- a/net/minecraft/world/level/BlockGetter.java
|
|
+++ b/net/minecraft/world/level/BlockGetter.java
|
|
@@ -221,7 +221,7 @@ public interface BlockGetter extends LevelHeightAccessor {
|
|
Vec3 vec3 = to.subtract(from);
|
|
if (physics != null && physics.before(1_21_2) || vec3.lengthSqr() < Mth.square(0.99999F)) {
|
|
// Sakura end - configure cannon physics
|
|
- for (BlockPos blockPos : BlockPos.betweenClosed(boundingBox)) {
|
|
+ for (BlockPos blockPos : me.samsuik.sakura.utils.BlockPosIterator.iterable(boundingBox)) { // Sakura - optimise check inside blocks
|
|
if (!visitor.visit(blockPos, 0)) {
|
|
return false;
|
|
}
|
|
@@ -229,6 +229,20 @@ public interface BlockGetter extends LevelHeightAccessor {
|
|
|
|
return true;
|
|
} else {
|
|
+ // Sakura start - optimise check inside blocks
|
|
+ final boolean xZero = vec3.x() == 0.0;
|
|
+ final boolean yZero = vec3.y() == 0.0;
|
|
+ final boolean zZero = vec3.z() == 0.0;
|
|
+ if (xZero && yZero || yZero && zZero || xZero && zZero) {
|
|
+ int blockIndex = 0;
|
|
+ for (final BlockPos blockPos : me.samsuik.sakura.utils.BlockPosIterator.traverseArea(vec3, boundingBox)) {
|
|
+ if (!visitor.visit(blockPos, blockIndex++)) {
|
|
+ return false;
|
|
+ }
|
|
+ }
|
|
+ return true;
|
|
+ }
|
|
+ // Sakura end - optimise check inside blocks
|
|
LongSet set = new LongOpenHashSet();
|
|
Vec3 minPosition = boundingBox.getMinPosition();
|
|
Vec3 vec31 = minPosition.subtract(vec3);
|
|
@@ -236,7 +250,7 @@ public interface BlockGetter extends LevelHeightAccessor {
|
|
if (i < 0) {
|
|
return false;
|
|
} else {
|
|
- for (BlockPos blockPos1 : BlockPos.betweenClosed(boundingBox)) {
|
|
+ for (BlockPos blockPos1 : me.samsuik.sakura.utils.BlockPosIterator.iterable(boundingBox)) { // Sakura - optimise check inside blocks
|
|
if (!set.contains(blockPos1.asLong()) && !visitor.visit(blockPos1, i + 1)) {
|
|
return false;
|
|
}
|