mirror of
https://github.com/Samsuik/Sakura.git
synced 2025-12-21 15:59:26 +00:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: PaperMC/Paper@9e51f94 Fix ping event always receiving protocol version 0 (#10671) PaperMC/Paper@89ad61f Fix hopper pull event being skipped after the first call (#10667) PaperMC/Paper@eee55d0 Correctly compare holders in BeaconMenu (#10673) PaperMC/Paper@5729b29 Update Adventure to 4.17.0 Release PaperMC/Paper@ab2a85a [ci skip] Clarify var entry in contributing file PaperMC/Paper@f2512b1 Print data component type on encoding error PaperMC/Paper@1b67e02 Fix entity tracker desync when new players are added to the tracker PaperMC/Paper@cc29d2b Invalidate PathTypeCache when pathfinding updates are disabled PaperMC/Paper@b56e92f Fix chunk data version check not running in chunk system PaperMC/Paper@2df1dac Fix DataConverter ConverterParticleToNBT.parseProperties PaperMC/Paper@8748ae1 Use MCDataConverter instead of raw convert call for cmd converter PaperMC/Paper@7f1a154 Add validation to player profile and properties (#10680) PaperMC/Paper@4fd58a1 Add conversion for summon command PaperMC/Paper@39532a1 Fix stacks losing empty attr modifiers PaperMC/Paper@cdb6ba8 Fix keepalive time interval (#10690) PaperMC/Paper@a61d58d adjust ItemMeta to distinguish null and empty modifiers PaperMC/Paper@6c02dbc handle recent ItemMeta changes in serialization logic PaperMC/Paper@447f9a1 [ci skip] Fix paperclip PR label PaperMC/Paper@b98d20a Brigadier Command Support (#8235) PaperMC/Paper@ac554ad Updated Upstream (Bukkit/CraftBukkit) (#10691) PaperMC/Paper@711f82e Fix signed book page serialization (#10696) PaperMC/Paper@7e48f66 Properly pass requirement on namespaced redirects (#10701) PaperMC/Paper@f041f48 Prevent infinite recursion on cyclic brig redirect (#10705) PaperMC/Paper@11c3963 Improve Recipe validation (#10707) PaperMC/Paper@0688f21 Better way to keep paper datapack enabled PaperMC/Paper@218d33c fix creating complex recipes that have air results PaperMC/Paper@fa8a407 Remove Adventure snapshot repo from dev bundle (#10716) PaperMC/Paper@bebcc9c Make exception during command conversion non-fatal PaperMC/Paper@2faa3b2 Correctly copy alias requirements in command upgrader PaperMC/Paper@3fc9358 Show stacktrace when modifyItemStack fails PaperMC/Paper@f175193 Expose server build information (#10729) PaperMC/Paper@d8d59e0 Fix NPE sending resource pack without prompt PaperMC/Paper@5a9afbe Fixes issues in the suppress dismount cancellation patch (#10735) PaperMC/Paper@0ad09de Make PaperSimplePluginClassLoader show class which is not found PaperMC/Paper@b3b3406 fix CompassMeta not being correct (#10737) PaperMC/Paper@591521e Check for more correct profile validation (#10730) PaperMC/Paper@7d2e5c3 Add an 'empty' RecipeChoice for certain ingredient slots (#10710) PaperMC/Paper@9bf4855 Add a better warning message than "Server performance will be affected" for CommandRegisteredEvent use (#10754) PaperMC/Paper@66cb880 Remove ThreadedWorldUpgrader patch PaperMC/Paper@980cff9 Fix compile PaperMC/Paper@d3ffa62 fix default item attributes PaperMC/Paper@b149584 Always show command exception stack traces in logs (#10766) PaperMC/Paper@a9201d4 [ci skip] Move logic in our patches to ItemType/BlockType (#10772) PaperMC/Paper@3de408e Fix equipment slot and group API (#10767) PaperMC/Paper@d408381 Print CommandRegisteredEvent deprecation warnings again (#10756) PaperMC/Paper@6de7a1f Improve default item attributes API (#10765) PaperMC/Paper@2a90732 Remove incorrect logic for Fireball#setVelocity (#10764) PaperMC/Paper@5e7b65a Allow using PluginLoader classpath API from Bukkit plugins (#10758) PaperMC/Paper@3004717 Do not re-wrap vanilla goals (#10751) PaperMC/Paper@377733d Use getter/setter on Mob for equipment drop chances (#10780) PaperMC/Paper@dff591d Allow to define new map cursor types (#10782) PaperMC/Paper@4fd3ac0 [ci skip] Update Player#getListeningPluginChannels Jdoc (#10778) PaperMC/Paper@535dca5 Fix a few issues with ItemMeta (#10740) PaperMC/Paper@26e90b9 Fix CraftMetaBlockState for data components (#10731) PaperMC/Paper@f0bd0cc Expose anvil cost in the API (#10682) PaperMC/Paper@41bee55 Fix NPE for color-related metas PaperMC/Paper@4e10fad reset meta block state on BlockStateMeta#setBlockState PaperMC/Paper@a7ae966 readd itemstack data sanitization (#10454) PaperMC/Paper@ca50b87 Clear firework item properly (#10793) PaperMC/Paper@9774a52 fix and cleanup loot table patches (#10100) PaperMC/Paper@ac4ee06 Fix integer overflow for lag compensating eating check (#10797) PaperMC/Paper@6649a17 Fix BlockStateMeta equals (#10795) PaperMC/Paper@1b8cdc6 Extend Player Interact cancellation to cover Jigsaw blocks (#10719) PaperMC/Paper@841ab41 Fix more item desync when an event is cancelled (#10654) PaperMC/Paper@b0e3ca4 Prevent NPE if hooked entity was cleared (#10712) PaperMC/Paper@347bbe3 Fix Cancelling BlockPlaceEvent calling onRemove (#10773) PaperMC/Paper@23fe116 Fix missing debug trace PaperMC/Paper@b0c9b9c Only remove worldgen block entity on changed block (#10794) PaperMC/Paper@9c917fe [ci skip] Clean up paperclip build-pr workflow (#10802) PaperMC/Paper@9d6f2cc [ci skip] Rebuild patches (#10803)
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 88964adf81cd03b26556b50b764caaddd49b59be..e689173f44a06ad320740dab2eceda5ff0e68fe2 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
@@ -1276,6 +1276,95 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
}
|
|
// Paper end - detailed watchdog information
|
|
|
|
+ // 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 && !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.setOnGroundWithKnownMovement(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
|
|
// Paper start - detailed watchdog information
|
|
@@ -1654,6 +1743,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
|
|
final boolean xZero = movement.x == 0.0;
|
|
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 a148befad883e5d524dcf643690f80a0bfd079e5..eec86ec7088079f31a5348089f47f29e7a1adaa8 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
|
|
@@ -200,7 +200,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 6cfa54da058939003576025cb0512e0bcc3e715b..d3073a058e4d200b0146d7b72ef3cd56a6a1d8d8 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
|
|
@@ -96,7 +96,7 @@ public class PrimedTnt extends Entity implements TraceableEntity {
|
|
public void tick() {
|
|
if (this.level().spigotConfig.maxTntTicksPerTick > 0 && ++this.level().spigotConfig.currentPrimedTnt > this.level().spigotConfig.maxTntTicksPerTick) { return; } // Spigot
|
|
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);
|