mirror of
https://github.com/Samsuik/Sakura.git
synced 2025-12-23 08:49:25 +00:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: PaperMC/Paper@7fbb827 Finish API patches PaperMC/Paper@8a37f93 62 PaperMC/Paper@2055809 117 PaperMC/Paper@0b75522 194 PaperMC/Paper@ec05cb8 279 PaperMC/Paper@0bc9aee 385 PaperMC/Paper@27e29cc 487/1053 PaperMC/Paper@083bd9e 531/1053 PaperMC/Paper@ed2ea45 538 PaperMC/Paper@ba163e1 585/1053 PaperMC/Paper@8731266 650/1053 PaperMC/Paper@52b49fb 788/1053 PaperMC/Paper@33b36cd update some patches PaperMC/Paper@14c0336 922 PaperMC/Paper@a399f23 956 PaperMC/Paper@4140de2 960 PaperMC/Paper@6d4e235 988 PaperMC/Paper@6a34750 Move unapplied patches to the back PaperMC/Paper@3c04f9f Fix a few compile errors PaperMC/Paper@0d3ce2d Fix more compile issues PaperMC/Paper@a308c7c Fix more compile issues PaperMC/Paper@69d1d0a Pretend to fix compile errors PaperMC/Paper@547f09d Some work on the ItemMend events PaperMC/Paper@184a943 Adopt previous commit changes in API PaperMC/Paper@5442bff Make it compile PaperMC/Paper@038f8d9 Fixup and deprecate player profiles in ping event PaperMC/Paper@66f7b67 Fix body equipmentslot and effect enum PaperMC/Paper@38b3182 Updated Upstream (Bukkit/CraftBukkit) PaperMC/Paper@df633e5 DataConverter 1.21 PaperMC/Paper@f569389 Update ConcurrentUtil PaperMC/Paper@5fca3ae update generated API PaperMC/Paper@188cff2 remove old vanilla goals PaperMC/Paper@ffe310a remove api that was scheduled for removal PaperMC/Paper@730882f Chunk System and Starlight WIP PaperMC/Paper@512fd08 Update Gradle Wrapper to v8.8 PaperMC/Paper@097284d Bump tiny-remapper to 0.10.3 PaperMC/Paper@ee9b820 Update more optimization patches PaperMC/Paper@5d834b1 rebuild patches PaperMC/Paper@4bc15f1 Updated Upstream (Bukkit/CraftBukkit) PaperMC/Paper@0b6701d Revert DamageSource#getCausingEntity to vanilla PaperMC/Paper@5bd7f4e Update AbstractArrow item method implementations for 1.20.6 (#10885) PaperMC/Paper@fb511c6 Fix Player#sendBlockState (#10855) PaperMC/Paper@b420038 Fix ItemMeta#removeEnchantments (#10886) PaperMC/Paper@a835ad1 Merge remote-tracking branch 'origin/dev/1.21' into dev/1.21 PaperMC/Paper@04dad71 Improve enchantWithLevels logic PaperMC/Paper@0008fa1 Add back more optimization patches PaperMC/Paper@56b5b7d Fix max chunk status checks PaperMC/Paper@c1aefee correctly change enchantment registry to a 'delayed' version PaperMC/Paper@d41636f Add back RecipeIterator fixes patch (#10887) PaperMC/Paper@7df4725 Configurable damage tick when blocking with shield (#10877) PaperMC/Paper@3555a77 Properly forward DispenseEvent #getItem to saddle PaperMC/Paper@e339ec2 Deprecate BlockData#getDestroySpeed for removal PaperMC/Paper@b090c65 Remove unnecessary changes from chunk status fix PaperMC/Paper@5e7cd07 add some generated typed/tag keys PaperMC/Paper@5a5412c Owen fixing stuff!!! PaperMC/Paper@7240d9d Restore functionality to sand dupe setting PaperMC/Paper@f873bce Fix NPE in V3808 PaperMC/Paper@1f8e7a7 address compile and test issue (#10890) PaperMC/Paper@60f3bd8 De-deprecate BlockData#getDestroySpeed PaperMC/Paper@752f957 Add back more patches PaperMC/Paper@dc684c6 Remove bad server.scheduleOnMain disconnect calls from old patches PaperMC/Paper@c84a3b5 Remove fully dropped patches PaperMC/Paper@d8c2980 Add Adventure API to ServerLinks (#10891) PaperMC/Paper@ec4c712 update 'improve mass craft perf' patch PaperMC/Paper@e1c0033 Updated Upstream (Bukkit/CraftBukkit) PaperMC/Paper@fbc2a55 Update Wither#canTravelThroughPortals PaperMC/Paper@167961e call EntityDamageItemEvent for thorns PaperMC/Paper@106dbae Fix getAddress connection check PaperMC/Paper@d9111cc Registry Modification API (#10893) PaperMC/Paper@f8ee0a0 Fix implementations of ChunkHolder#getChunkIfPresent PaperMC/Paper@61b85e4 Fix legacy cb version in remapper PaperMC/Paper@de8220c Update ChunkMap#distanceManager mapping patch PaperMC/Paper@8dfb85c Enchantment and GameEvent Registry builders (#10889) PaperMC/Paper@fb762cf remove remaining reference to 'pgive' PaperMC/Paper@a7f6633 make EntityPortalReadyEvent#setTargetWorld work again PaperMC/Paper@152f4fe Add back improved watchdog support patch PaperMC/Paper@13992b1 Make chunk system loggers calm down a bit PaperMC/Paper@bf8552f Delegate ItemStack (#10852) PaperMC/Paper@b3e072a Fix `hasFiredAsync` parameter when `AsyncPlayerSendCommandsEvent` is called (#10896) PaperMC/Paper@21c9a7c Rebuild patches PaperMC/Paper@b9f7098 [ci skip] Fix javadoc mistake in EnchantmentRegistryEntry.Builder (#10898) PaperMC/Paper@b4b8208 Fix NPE for Jukebox#setRecord PaperMC/Paper@4514f41 Correct duplicate attribute check (#10901) PaperMC/Paper@090775e Use ItemStack.empty() when air is passed into constructor PaperMC/Paper@7bbe682 Fix CraftWorld#isChunkGenerated PaperMC/Paper@126f6d7 Remove getUnloadingChunkHolder check PaperMC/Paper@d23825a Add missing null check to getFullChunkIfLoaded PaperMC/Paper@3b1c85b Execute chunk tasks while waiting for chunk load in isChunkGenerated PaperMC/Paper@4ea696f Add ticket for chunk load in isChunkGenerated PaperMC/Paper@250e78c Re-add fixlight command PaperMC/Paper@c0268ca Copy missing diff from old chunk system patch PaperMC/Paper@38428c0 Cleanup MCUtils patch for chunk system PaperMC/Paper@f4ddd4a Fix ChunkHolder#getFullChunkNow returning non-null when it should not PaperMC/Paper@e0d9d60 Add debug for chunk system unload crash PaperMC/Paper@2df432f Re-add chunk system debug commands PaperMC/Paper@cf60574 Fix jukebox playable component not being applied on item meta (#10922) PaperMC/Paper@666bc4d Experimental annotation changes (#10914) PaperMC/Paper@bab07e0 Validate speed for tool component rule (#10923) PaperMC/Paper@2118196 Fixes exception log messages getting dropped during bootstrap (#10935) PaperMC/Paper@8b1d26d Fix diff in sprint interruption option (Closes #10939) PaperMC/Paper@0a1b133 Revert "Fixes exception log messages getting dropped during bootstrap (#10935)" (Closes #10945) PaperMC/Paper@a0fad76 Fix base damage for trident (#10948) PaperMC/Paper@d64be7e Fix NPE of AbstractArrow#getWeapon (#10933) PaperMC/Paper@081146c Validate using_converts_to for food component (#10931) PaperMC/Paper@0409a68 deprecate and update some entity tags (#10932) PaperMC/Paper@9cd0201 Preserve velocity for fireball (#10934) PaperMC/Paper@19105a9 Fix unload queue storing chunks in wrong sections PaperMC/Paper@77c763b Fix PlayerShearBlockEvent drops ignored for Pumpkin (#10956) PaperMC/Paper@76c2f16 Fix wrong diff applying delta twice (#10959) PaperMC/Paper@812701d Do not crash when an exp orb attempts to mend an unrepairable item PaperMC/Paper@19eefe9 Fix SoundEffects only to players diff (#10966) PaperMC/Paper@95aa440 Add missing effect cause and deprecate PATROL_CAPTAIN cause (#10958) PaperMC/Paper@b2e5587 Expose LivingEntity#canUseSlot (#10930) PaperMC/Paper@97afc9a Fix StackOverflowError for new dispenser interaction (#10949) PaperMC/Paper@5ae4758 Fix speed for launched trident using api (#10936) PaperMC/Paper@897ece4 Call EntityPortalEnterEvent on endgateways and make cancellable (#10892) PaperMC/Paper@1d3fc0e Bump reflection-rewriter to 0.0.2 (#10927) PaperMC/Paper@b99d071 Swap some nullable annotations (#10960) PaperMC/Paper@dd31654 bump reflection-rewriter to 0.0.3 (#10969) PaperMC/Paper@dd49fba Fix NPE when retrieving an entity with a null UUID
229 lines
11 KiB
Diff
229 lines
11 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Samsuik <40902469+Samsuik@users.noreply.github.com>
|
|
Date: Fri, 13 Oct 2023 14:36:19 +0100
|
|
Subject: [PATCH] Optimise Fast Movement
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
index 190e0022cb45545d8a76f0f7819b6f2be0b64307..348714eb8d74cf917daa5586f0b4962351a96102 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
@@ -1245,6 +1245,95 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
return this.onGround;
|
|
}
|
|
|
|
+ // Sakura start - stripped back movement method for basic entities
|
|
+ public void moveBasic(MoverType movementType, Vec3 movement) {
|
|
+ io.papermc.paper.util.TickThread.ensureTickThread("Cannot move an entity off-main");
|
|
+
|
|
+ if (this.noPhysics) {
|
|
+ this.setPos(this.getX() + movement.x, this.getY() + movement.y, this.getZ() + movement.z);
|
|
+ } else {
|
|
+ if (movementType == MoverType.PISTON) { // Paper
|
|
+ movement = this.limitPistonMovement(movement);
|
|
+ if (movement.equals(Vec3.ZERO)) {
|
|
+ return;
|
|
+ }
|
|
+ }
|
|
+
|
|
+ this.level().getProfiler().push("move");
|
|
+ if (this.stuckSpeedMultiplier.lengthSqr() > 1.0E-7D) {
|
|
+ movement = movement.multiply(this.stuckSpeedMultiplier);
|
|
+ this.stuckSpeedMultiplier = Vec3.ZERO;
|
|
+ this.setDeltaMovement(Vec3.ZERO);
|
|
+ }
|
|
+
|
|
+ // collideScan for optimised large movements
|
|
+ Vec3 vec3d1 = this.collideScan(movement);
|
|
+ double d0 = vec3d1.lengthSqr();
|
|
+
|
|
+ if (d0 > 1.0E-7D) {
|
|
+ // NOTE: if there are any blocks in the future that rely on fall distance make sure this is correct.
|
|
+ // The only block I am aware of is powdered snow that has a special case for falling blocks.
|
|
+ if (this.fallDistance != 0.0F && d0 >= 1.0D && !this.isFallingBlock) {
|
|
+ BlockHitResult movingobjectpositionblock = this.level().clip(new ClipContext(this.position(), this.position().add(vec3d1), ClipContext.Block.FALLDAMAGE_RESETTING, ClipContext.Fluid.WATER, this));
|
|
+
|
|
+ if (movingobjectpositionblock.getType() != HitResult.Type.MISS) {
|
|
+ this.resetFallDistance();
|
|
+ }
|
|
+ }
|
|
+
|
|
+ this.setPos(this.getX() + vec3d1.x, this.getY() + vec3d1.y, this.getZ() + vec3d1.z);
|
|
+ }
|
|
+
|
|
+ this.level().getProfiler().pop();
|
|
+ this.level().getProfiler().push("rest");
|
|
+ boolean flag = !Mth.equal(movement.x, vec3d1.x);
|
|
+ boolean flag1 = !Mth.equal(movement.z, vec3d1.z);
|
|
+
|
|
+ this.horizontalCollision = flag || flag1;
|
|
+ this.verticalCollision = movement.y != vec3d1.y;
|
|
+ this.verticalCollisionBelow = this.verticalCollision && movement.y < 0.0D;
|
|
+ if (this.horizontalCollision) {
|
|
+ this.minorHorizontalCollision = this.isHorizontalCollisionMinor(vec3d1);
|
|
+ } else {
|
|
+ this.minorHorizontalCollision = false;
|
|
+ }
|
|
+
|
|
+ this.setOnGroundWithMovement(this.verticalCollisionBelow, vec3d1);
|
|
+ BlockPos blockposition = this.getOnPosLegacy();
|
|
+ BlockState iblockdata = this.level().getBlockState(blockposition);
|
|
+
|
|
+ this.checkFallDamage(vec3d1.y, this.onGround(), iblockdata, blockposition);
|
|
+ if (this.isRemoved()) {
|
|
+ this.level().getProfiler().pop();
|
|
+ } else {
|
|
+ if (this.horizontalCollision) {
|
|
+ Vec3 vec3d2 = this.getDeltaMovement();
|
|
+
|
|
+ this.setDeltaMovement(flag ? 0.0D : vec3d2.x, vec3d2.y, flag1 ? 0.0D : vec3d2.z);
|
|
+ }
|
|
+
|
|
+ Block block = iblockdata.getBlock();
|
|
+
|
|
+ if (movement.y != vec3d1.y) {
|
|
+ block.updateEntityAfterFallOn(this.level(), this);
|
|
+ }
|
|
+
|
|
+ if (this.onGround()) {
|
|
+ // used for slowing down entities on top of slime
|
|
+ block.stepOn(this.level(), blockposition, iblockdata, this);
|
|
+ }
|
|
+
|
|
+ this.tryCheckInsideBlocks();
|
|
+
|
|
+ float f = this.getBlockSpeedFactor();
|
|
+
|
|
+ this.multiplyDeltaMovement((double) f, 1.0D, (double) f); // Sakura - reduce movement allocations
|
|
+ this.level().getProfiler().pop();
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ // Sakura end
|
|
+
|
|
public void move(MoverType movementType, Vec3 movement) {
|
|
final Vec3 originalMovement = movement; // Paper - Expose pre-collision velocity
|
|
if (this.noPhysics) {
|
|
@@ -1606,6 +1695,95 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
return offsetFactor;
|
|
}
|
|
|
|
+ // Sakura start
|
|
+ private Vec3 collideScan(Vec3 movement) {
|
|
+ if (movement.x == 0.0 && movement.y == 0.0 && movement.z == 0.0) {
|
|
+ return movement;
|
|
+ }
|
|
+
|
|
+ final boolean scan = movement.lengthSqr() >= 12.0;
|
|
+ final List<AABB> potentialCollisionsBB = new it.unimi.dsi.fastutil.objects.ObjectArrayList<>(4);
|
|
+ final List<VoxelShape> potentialCollisionsVoxel = new it.unimi.dsi.fastutil.objects.ObjectArrayList<>(1);
|
|
+ final AABB currBoundingBox = getBoundingBox();
|
|
+
|
|
+ if (scan) {
|
|
+ return scanAndCollide(movement, currBoundingBox, potentialCollisionsVoxel, potentialCollisionsBB);
|
|
+ } else {
|
|
+ final AABB bb = currBoundingBox.expandTowards(movement.x, movement.y, movement.z);
|
|
+ collectCollisions(bb, potentialCollisionsVoxel, potentialCollisionsBB);
|
|
+ return io.papermc.paper.util.CollisionUtil.performCollisions(movement, currBoundingBox, potentialCollisionsVoxel, potentialCollisionsBB);
|
|
+ }
|
|
+ }
|
|
+
|
|
+ private Vec3 scanAndCollide(Vec3 movement, AABB currBoundingBox, List<VoxelShape> voxelList, List<AABB> bbList) {
|
|
+ double x = movement.x;
|
|
+ double y = movement.y;
|
|
+ double z = movement.z;
|
|
+
|
|
+ final boolean xSmaller = Math.abs(x) < Math.abs(z);
|
|
+
|
|
+ if (y != 0.0) {
|
|
+ y = scanY(currBoundingBox, y, voxelList, bbList);
|
|
+
|
|
+ if (y != 0.0) {
|
|
+ currBoundingBox = io.papermc.paper.util.CollisionUtil.offsetY(currBoundingBox, y);
|
|
+ }
|
|
+ }
|
|
+
|
|
+ if (xSmaller && z != 0.0) {
|
|
+ z = scanZ(currBoundingBox, z, voxelList, bbList);
|
|
+
|
|
+ if (z != 0.0) {
|
|
+ currBoundingBox = io.papermc.paper.util.CollisionUtil.offsetZ(currBoundingBox, z);
|
|
+ }
|
|
+ }
|
|
+
|
|
+ if (x != 0.0) {
|
|
+ x = scanX(currBoundingBox, x, voxelList, bbList);
|
|
+
|
|
+ if (x != 0.0) {
|
|
+ currBoundingBox = io.papermc.paper.util.CollisionUtil.offsetX(currBoundingBox, x);
|
|
+ }
|
|
+ }
|
|
+
|
|
+ if (!xSmaller && z != 0.0) {
|
|
+ z = scanZ(currBoundingBox, z, voxelList, bbList);
|
|
+ }
|
|
+
|
|
+ return new Vec3(x, y, z);
|
|
+ }
|
|
+
|
|
+ private void collectCollisions(AABB collisionBox, List<VoxelShape> voxelList, List<AABB> bbList) {
|
|
+ // Copied from the collide method below
|
|
+ io.papermc.paper.util.CollisionUtil.getCollisions(
|
|
+ level, this, collisionBox, voxelList, bbList,
|
|
+ io.papermc.paper.util.CollisionUtil.COLLISION_FLAG_CHECK_BORDER | this.getExtraCollisionFlags(), // Sakura
|
|
+ null, null
|
|
+ );
|
|
+ }
|
|
+
|
|
+ private double scanX(AABB currBoundingBox, double x, List<VoxelShape> voxelList, List<AABB> bbList) {
|
|
+ AABB scanBox = currBoundingBox.expandTowards(x, 0.0, 0.0);
|
|
+ collectCollisions(scanBox, voxelList, bbList);
|
|
+ x = io.papermc.paper.util.CollisionUtil.performAABBCollisionsX(currBoundingBox, x, bbList);
|
|
+ return io.papermc.paper.util.CollisionUtil.performVoxelCollisionsX(currBoundingBox, x, voxelList);
|
|
+ }
|
|
+
|
|
+ private double scanY(AABB currBoundingBox, double y, List<VoxelShape> voxelList, List<AABB> bbList) {
|
|
+ AABB scanBox = currBoundingBox.expandTowards(0.0, y, 0.0);
|
|
+ collectCollisions(scanBox, voxelList, bbList);
|
|
+ y = io.papermc.paper.util.CollisionUtil.performAABBCollisionsY(currBoundingBox, y, bbList);
|
|
+ return io.papermc.paper.util.CollisionUtil.performVoxelCollisionsY(currBoundingBox, y, voxelList);
|
|
+ }
|
|
+
|
|
+ private double scanZ(AABB currBoundingBox, double z, List<VoxelShape> voxelList, List<AABB> bbList) {
|
|
+ AABB scanBox = currBoundingBox.expandTowards(0.0, 0.0, z);
|
|
+ collectCollisions(scanBox, voxelList, bbList);
|
|
+ z = io.papermc.paper.util.CollisionUtil.performAABBCollisionsZ(currBoundingBox, z, bbList);
|
|
+ return io.papermc.paper.util.CollisionUtil.performVoxelCollisionsZ(currBoundingBox, z, voxelList);
|
|
+ }
|
|
+ // Sakura end
|
|
+
|
|
private Vec3 collide(Vec3 movement) {
|
|
// Paper start - optimise collisions
|
|
// Sakura - This is temporary workaround until this patch is updated by Paper.
|
|
diff --git a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
|
|
index fa95135e3af7fdd610cad2230cc39b547cda0a8a..533b7db0adc9aa9677106f807a992bc09ba60b28 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
|
|
@@ -204,7 +204,7 @@ public class FallingBlockEntity extends Entity {
|
|
|
|
++this.time;
|
|
this.applyGravity();
|
|
- this.move(MoverType.SELF, this.getDeltaMovement());
|
|
+ this.moveBasic(MoverType.SELF, this.getDeltaMovement()); // Sakura - optimise simple entity movement
|
|
// Paper start - Configurable falling blocks height nerf
|
|
if (this.level().paperConfig().fixes.fallingBlockHeightNerf.test(v -> this.getY() > v)) {
|
|
if (this.dropItem && this.level().getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) {
|
|
diff --git a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
|
|
index a86ca8e7c66605260d8932b489d5d4fe8c74ab64..96878f577174b0ccef7c063153a0787ec3e97177 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
|
|
@@ -117,7 +117,7 @@ public class PrimedTnt extends Entity implements TraceableEntity {
|
|
if (this.level().spigotConfig.maxTntTicksPerTick > 0 && ++this.level().spigotConfig.currentPrimedTnt > this.level().spigotConfig.maxTntTicksPerTick) { return; } // Spigot
|
|
this.handlePortal();
|
|
this.applyGravity();
|
|
- this.move(MoverType.SELF, this.getDeltaMovement());
|
|
+ this.moveBasic(MoverType.SELF, this.getDeltaMovement()); // Sakura - optimise simple entity movement
|
|
// Paper start - Configurable TNT height nerf
|
|
if (this.level().paperConfig().fixes.tntEntityHeightNerf.test(v -> this.getY() > v)) {
|
|
this.discard(EntityRemoveEvent.Cause.OUT_OF_WORLD);
|