mirror of
https://github.com/Samsuik/Sakura.git
synced 2025-12-26 18:29:07 +00:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: PaperMC/Paper@a80d31b Log command execution exceptions if debug=true (#10130) PaperMC/Paper@ec19620 Use a ConcurrentHashMap for enum mappings for BlockData (#10161) PaperMC/Paper@f28caff Limit ResourceLocation length to nbt string tag length PaperMC/Paper@a0ffb57 [ci skip] Small cleanup to mc utils patch PaperMC/Paper@8c8862f Also check for the actual character length in ResourceLocation validation PaperMC/Paper@e84621a [ci skip] Add more patch identifying comments PaperMC/Paper@c0e4697 [ci skip] Add more patch identifying comments PaperMC/Paper@17275ff [ci skip] add more comments & move 1 hunk to correct patch PaperMC/Paper@78fcb8e [ci skip] Update contributing guidelines to include identifying commit titles in comments (#10162) PaperMC/Paper@8657cd9 Updated Upstream (Bukkit/CraftBukkit/Spigot) (#10164) PaperMC/Paper@c151c95 Fixup AsyncPreLoginEvent patches PaperMC/Paper@93a848c Readd missed line PaperMC/Paper@f9fdedf [ci skip] Add more patch identifying comments, merge related patches PaperMC/Paper@0ef5984 [ci skip] Add more patch identifying comments, merge related patches PaperMC/Paper@848a396 Add mob goal generator (#9980) PaperMC/Paper@ebf97bd [ci skip] Add more patch identifying comments PaperMC/Paper@94807a1 [ci skip] Minor cleanup and patch merges PaperMC/Paper@5e73c55 [ci skip] Add more identifying patch comments PaperMC/Paper@3e20d3a [ci skip] Add more identifying patch comments PaperMC/Paper@f61ebdc Fix issue with kick event causes being passed improperly PaperMC/Paper@106c67a [ci skip] Add more identifying patch comments PaperMC/Paper@cc693ce [ci skip] Add more identifying patch comments, merge related patches PaperMC/Paper@eeb6afc [ci skip] Add more identifying patch comments, merge related patches PaperMC/Paper@1c956ab [ci skip] Add more identifying patch comments, merge related patches PaperMC/Paper@42e88a8 [ci skip] Add more identifying patch comments PaperMC/Paper@8e41ef4 Add visual blockdata api for primed tnt (#10146) PaperMC/Paper@68c3297 [ci skip] Add more identifying patch comments PaperMC/Paper@4a98986 Add back Reduce allocation of Vec3D by entity tracker patch (#10179) PaperMC/Paper@b48d737 Async world data IO saving (#10171) PaperMC/Paper@8d94596 [ci skip] Add more identifying patch comments PaperMC/Paper@f7dd304 [ci skip] Add more identifying patch comments PaperMC/Paper@98e6d20 [ci skip] Add more identifying patch comments PaperMC/Paper@e9e0bc1 [ci skip] Add more identifying patch comments PaperMC/Paper@d9df6bc [ci skip] Add more patch identifying comments, cleanup PaperMC/Paper@27cabc1 [ci skip] Add more patch identifying comments PaperMC/Paper@684319f [ci skip] Add more patch identifying comments PaperMC/Paper@9eb0b38 [ci skip] Add more patch identifying comments PaperMC/Paper@25013d9 [ci skip] Move some disruptive patches back PaperMC/Paper@484d6bf [ci skip] Move some disruptive patches back PaperMC/Paper@52619e7 [ci skip] Add more patch identifying comments PaperMC/Paper@e660379 [ci skip] Move some disruptive patches back PaperMC/Paper@c57d1aa Move diffs around to compile without later ones applied PaperMC/Paper@581b101 Add world to Entity AddTo/RemoveFrom Events (#10183) PaperMC/Paper@24dc2bf Add BlockStateMeta#clearBlockState (#10160) PaperMC/Paper@76da4bc Expose LootTable of DecoratedPot (#10023) PaperMC/Paper@11645e3 [ci skip] (Mostly) finish adding identifying patch comments PaperMC/Paper@51bef80 [ci skip] Remove removed patches PaperMC/Paper@ad2cf68 [ci skip] Move chunk system patch back a bit PaperMC/Paper@d405ff1 [ci skip] Fixup last commit PaperMC/Paper@a4a08b7 [ci skip] Move chunk system patch a bit back PaperMC/Paper@b700460 Convert average tick value in the GUI to the correct granularity PaperMC/Paper@1831240 [ci skip] Move chunk system patch back PaperMC/Paper@b03f255 Finish moving patches back and improving compilable state PaperMC/Paper@bd2fd61 [ci skip] Fixup a few bad comments PaperMC/Paper@fe53b0e Updated Upstream (Bukkit/CraftBukkit/Spigot) PaperMC/Paper@1ed50da Fix javadoc errors, remove unused classes PaperMC/Paper@7f7d05a [ci skip] Remove IRC link from the README (#10194) PaperMC/Paper@ed130f1 [ci skip] clarify javadocs for Block#getDrops (#10153) PaperMC/Paper@4643b0d Shulker duplicate event (#10135) PaperMC/Paper@b333831 Make spawn egg colours visible (#10158) PaperMC/Paper@0cc3a7e Disable memory reserve allocating (#10180) PaperMC/Paper@3841722 Properly check if a loot table exists (#10190) PaperMC/Paper@b3c8108 [ci skip] Fix incorrect documentation for BlockDropItemEvent (#10175) PaperMC/Paper@294347b [ci skip] Cleanup events (#10202) PaperMC/Paper@87ce7c7 Small refactor of Paper plugin context preparation PaperMC/Paper@7f856a1 Fix sleeping pos desync PaperMC/Paper@8bc5be8 Add missing catch PaperMC/Paper@c5d168c More provider source fixup PaperMC/Paper@9e171ef Improve tag parser handling, move hunks out of chunk system patch PaperMC/Paper@934cd77 Lifecycle Event System (#9629) PaperMC/Paper@534659e Fix NotNull locales (#10216) PaperMC/Paper@9c04729 Add Arrow/Stinger Removal Time API (#10193) PaperMC/Paper@69b52b4 Check for server JARs in plugin directory (#10228) PaperMC/Paper@cbe62d9 Add Conduit API (#10195) PaperMC/Paper@97c0120 Fix fox drops on death (#8862) PaperMC/Paper@581fb30 itemstack expose tooltip lines (#10185) PaperMC/Paper@99bae59 Propagate failed to bind to port error (#10235) PaperMC/Paper@bf6e803 Fix WaterBottleSplashEvent not forwarding hit result (#10203) PaperMC/Paper@2fa2d32 Fix possible StackOverflowError for some dispenser iteractions (#8524) PaperMC/Paper@e6a5215 Properly track the changed item from dispense events (#8658) PaperMC/Paper@4b58a85 Fire BlockPreDispenseEvent for droppers (#10226) PaperMC/Paper@cde5587 Add getChunkSnapshot includeLightData parameter (#10234) PaperMC/Paper@31699ae Updated Upstream (Bukkit/CraftBukkit) (#10242) PaperMC/Paper@37df121 Fix BlockState being set to null for damage events (#10252) PaperMC/Paper@7f85940 Updated Upstream (Bukkit) (#10255) PaperMC/Paper@7ccefdc Fire entity knockback event for ownerless tnt (#7171) PaperMC/Paper@a07d526 [ci skip] Fix JavaDoc mistake in BlockPistonRetractEvent (#10250) PaperMC/Paper@9a66f2b [ci skip] Fix javadoc mistake in PluginMeta (#10258) PaperMC/Paper@1964b22 Scoreboard objective number format api (#10036) PaperMC/Paper@d95341e FluidState API (#9951) PaperMC/Paper@351923d Run round-trip adventure codec tests with JSON, NBT, and Java ops. Use JavaOps for conversions. (#10031) PaperMC/Paper@4939f87 Add more ResourceLocation checks, some cleanup
261 lines
12 KiB
Diff
261 lines
12 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Samsuik <kfian294ma4@gmail.com>
|
|
Date: Fri, 24 Mar 2023 16:29:21 +0000
|
|
Subject: [PATCH] Reduce deltaMovement Allocations
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
index f426abb7e6db911dfb3609383fce6476fd4233ed..d92e4db0051f128fac5653c7920c2466bff80143 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
@@ -1240,7 +1240,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
|
this.tryCheckInsideBlocks();
|
|
float f = this.getBlockSpeedFactor();
|
|
|
|
- this.setDeltaMovement(this.getDeltaMovement().multiply((double) f, 1.0D, (double) f));
|
|
+ this.multiplyDeltaMovement((double) f, 1.0D, (double) f); // Sakura - reduce movement allocations
|
|
// Paper start - remove expensive streams from here
|
|
boolean noneMatch = true;
|
|
AABB fireSearchBox = this.getBoundingBox().deflate(1.0E-6D);
|
|
@@ -2056,6 +2056,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
|
public void moveTo(double x, double y, double z, float yaw, float pitch) {
|
|
// Paper start - Fix Entity Teleportation and cancel velocity if teleported
|
|
if (!preserveMotion) {
|
|
+ this.movementDirty = false; // Sakura
|
|
this.deltaMovement = Vec3.ZERO;
|
|
} else {
|
|
this.preserveMotion = false;
|
|
@@ -3457,29 +3458,33 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
|
}
|
|
|
|
public void onAboveBubbleCol(boolean drag) {
|
|
- Vec3 vec3d = this.getDeltaMovement();
|
|
+ // Sakura start - reduce movement allocations
|
|
+ // Vec3 vec3d = this.getDeltaMovement();
|
|
+ this.syncDeltaMovement();
|
|
double d0;
|
|
|
|
if (drag) {
|
|
- d0 = Math.max(-0.9D, vec3d.y - 0.03D);
|
|
+ d0 = Math.max(-0.9D, movementY - 0.03D);
|
|
} else {
|
|
- d0 = Math.min(1.8D, vec3d.y + 0.1D);
|
|
+ d0 = Math.min(1.8D, movementY + 0.1D);
|
|
}
|
|
|
|
- this.setDeltaMovement(vec3d.x, d0, vec3d.z);
|
|
+ this.setDeltaMovement(movementX, d0, movementZ);
|
|
}
|
|
|
|
public void onInsideBubbleColumn(boolean drag) {
|
|
- Vec3 vec3d = this.getDeltaMovement();
|
|
+ // Vec3 vec3d = this.getDeltaMovement();
|
|
+ this.syncDeltaMovement();
|
|
double d0;
|
|
|
|
if (drag) {
|
|
- d0 = Math.max(-0.3D, vec3d.y - 0.03D);
|
|
+ d0 = Math.max(-0.3D, movementY - 0.03D);
|
|
} else {
|
|
- d0 = Math.min(0.7D, vec3d.y + 0.06D);
|
|
+ d0 = Math.min(0.7D, movementY + 0.06D);
|
|
}
|
|
|
|
- this.setDeltaMovement(vec3d.x, d0, vec3d.z);
|
|
+ this.setDeltaMovement(movementX, d0, movementZ);
|
|
+ // Sakura end
|
|
this.resetFallDistance();
|
|
}
|
|
|
|
@@ -4468,16 +4473,19 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
|
vec3d = vec3d.normalize();
|
|
}
|
|
|
|
- Vec3 vec3d2 = this.getDeltaMovement();
|
|
+ // Sakura start - reduce movement allocations
|
|
+ // Vec3 vec3d2 = this.getDeltaMovement();
|
|
+ this.syncDeltaMovement();
|
|
|
|
vec3d = vec3d.scale(speed * 1.0D);
|
|
double d3 = 0.003D;
|
|
|
|
- if (Math.abs(vec3d2.x) < 0.003D && Math.abs(vec3d2.z) < 0.003D && vec3d.length() < 0.0045000000000000005D) {
|
|
+ if (Math.abs(movementX) < 0.003D && Math.abs(movementZ) < 0.003D && vec3d.length() < 0.0045000000000000005D) {
|
|
vec3d = vec3d.normalize().scale(0.0045000000000000005D);
|
|
}
|
|
|
|
- this.setDeltaMovement(this.getDeltaMovement().add(vec3d));
|
|
+ this.addDeltaMovement(vec3d.x, vec3d.y, vec3d.z);
|
|
+ // Sakura end
|
|
}
|
|
|
|
this.fluidHeight.put(tag, d1);
|
|
@@ -4548,11 +4556,53 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
|
return this.chunkPosition;
|
|
}
|
|
|
|
+ // Sakura start - reduce movement allocations
|
|
+ private double movementX;
|
|
+ private double movementY;
|
|
+ private double movementZ;
|
|
+ private boolean movementDirty;
|
|
+
|
|
+ public void addDeltaMovement(double x, double y, double z) {
|
|
+ syncDeltaMovement();
|
|
+ movementX += x;
|
|
+ movementY += y;
|
|
+ movementZ += z;
|
|
+ }
|
|
+
|
|
+ public void scaleDeltaMovement(double n) {
|
|
+ syncDeltaMovement();
|
|
+ movementX *= n;
|
|
+ movementY *= n;
|
|
+ movementZ *= n;
|
|
+ }
|
|
+
|
|
+ public void multiplyDeltaMovement(double x, double y, double z) {
|
|
+ syncDeltaMovement();
|
|
+ movementX *= x;
|
|
+ movementY *= y;
|
|
+ movementZ *= z;
|
|
+ }
|
|
+
|
|
+ private void updateDeltaMovement() {
|
|
+ if (movementDirty) {
|
|
+ deltaMovement = new Vec3(movementX, movementY, movementZ);
|
|
+ movementDirty = false;
|
|
+ }
|
|
+ }
|
|
+
|
|
+ private void syncDeltaMovement() {
|
|
+ if (!movementDirty) {
|
|
+ setDeltaMovement(deltaMovement.x, deltaMovement.y, deltaMovement.z);
|
|
+ }
|
|
+ }
|
|
+
|
|
public Vec3 getDeltaMovement() {
|
|
+ updateDeltaMovement();
|
|
return this.deltaMovement;
|
|
}
|
|
|
|
public void setDeltaMovement(Vec3 velocity) {
|
|
+ movementDirty = false;
|
|
synchronized (this.posLock) { // Paper
|
|
this.deltaMovement = velocity;
|
|
} // Paper
|
|
@@ -4563,7 +4613,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
|
}
|
|
|
|
public void setDeltaMovement(double x, double y, double z) {
|
|
- this.setDeltaMovement(new Vec3(x, y, z));
|
|
+ movementX = x;
|
|
+ movementY = y;
|
|
+ movementZ = z;
|
|
+ movementDirty = true;
|
|
+ // Sakura end
|
|
}
|
|
|
|
public final int getBlockX() {
|
|
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 af4875fd0ed635dde59ec579dc198558efab0533..f345ab3886899e5823e5146b032c41f4e5ef5953 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
|
|
@@ -145,7 +145,7 @@ public class FallingBlockEntity extends Entity {
|
|
|
|
++this.time;
|
|
if (!this.isNoGravity()) {
|
|
- this.setDeltaMovement(this.getDeltaMovement().add(0.0D, -0.04D, 0.0D));
|
|
+ this.addDeltaMovement(0.0D, -0.04D, 0.0D); // Sakura - reduce movement allocations
|
|
}
|
|
|
|
this.move(MoverType.SELF, this.getDeltaMovement());
|
|
@@ -190,7 +190,7 @@ public class FallingBlockEntity extends Entity {
|
|
} else {
|
|
BlockState iblockdata = this.level().getBlockState(blockposition);
|
|
|
|
- this.setDeltaMovement(this.getDeltaMovement().multiply(0.7D, -0.5D, 0.7D));
|
|
+ this.multiplyDeltaMovement(0.7D, -0.5D, 0.7D); // Sakura - reduce movement allocations
|
|
if (!iblockdata.is(Blocks.MOVING_PISTON)) {
|
|
if (!this.cancelDrop) {
|
|
boolean flag2 = iblockdata.canBeReplaced((BlockPlaceContext) (new DirectionalPlaceContext(this.level(), blockposition, Direction.DOWN, ItemStack.EMPTY, Direction.UP)));
|
|
@@ -257,7 +257,7 @@ public class FallingBlockEntity extends Entity {
|
|
}
|
|
}
|
|
|
|
- this.setDeltaMovement(this.getDeltaMovement().scale(0.98D));
|
|
+ this.scaleDeltaMovement(0.98D); // Sakura - reduce movement allocations
|
|
}
|
|
}
|
|
|
|
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 3c5e8c594ff63d93bdd052a6b648120c550f60f5..bc77b3093dbc7312516817d8dd5a9b04534fb09e 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
|
|
@@ -74,7 +74,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
|
|
if (!this.isNoGravity()) {
|
|
- this.setDeltaMovement(this.getDeltaMovement().add(0.0D, -0.04D, 0.0D));
|
|
+ this.addDeltaMovement(0.0D, -0.04D, 0.0D); // Sakura - reduce movement allocations
|
|
}
|
|
|
|
this.move(MoverType.SELF, this.getDeltaMovement());
|
|
@@ -84,9 +84,9 @@ public class PrimedTnt extends Entity implements TraceableEntity {
|
|
return;
|
|
}
|
|
// Paper end - Configurable TNT height nerf
|
|
- this.setDeltaMovement(this.getDeltaMovement().scale(0.98D));
|
|
+ this.scaleDeltaMovement(0.98D); // Sakura - reduce movement allocations
|
|
if (this.onGround()) {
|
|
- this.setDeltaMovement(this.getDeltaMovement().multiply(0.7D, -0.5D, 0.7D));
|
|
+ this.multiplyDeltaMovement(0.7D, -0.5D, 0.7D); // Sakura - reduce movement allocations
|
|
}
|
|
|
|
int i = this.getFuse() - 1;
|
|
diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java
|
|
index d1e4bc32a740da4f7e6d5f6f9559a12813909a9e..39c30a295df9dfbc3c861f1678a958ef2ed2ba93 100644
|
|
--- a/src/main/java/net/minecraft/world/level/Explosion.java
|
|
+++ b/src/main/java/net/minecraft/world/level/Explosion.java
|
|
@@ -617,10 +617,11 @@ public class Explosion {
|
|
d8 *= d13;
|
|
d9 *= d13;
|
|
d10 *= d13;
|
|
- Vec3 vec3d1 = new Vec3(d8, d9, d10);
|
|
+ Vec3 vec3d1 = null; // Sakura - move allocation below living entity condition
|
|
|
|
// CraftBukkit start - Call EntityKnockbackEvent
|
|
if (entity instanceof LivingEntity) {
|
|
+ vec3d1 = new Vec3(d8, d9, d10); // Sakura
|
|
Vec3 result = entity.getDeltaMovement().add(vec3d1);
|
|
org.bukkit.event.entity.EntityKnockbackEvent event = CraftEventFactory.callEntityKnockbackEvent((org.bukkit.craftbukkit.entity.CraftLivingEntity) entity.getBukkitEntity(), this.source, org.bukkit.event.entity.EntityKnockbackEvent.KnockbackCause.EXPLOSION, d13, vec3d1, result.x, result.y, result.z);
|
|
|
|
@@ -635,9 +636,13 @@ public class Explosion {
|
|
vec3d1 = org.bukkit.craftbukkit.util.CraftVector.toNMS(paperEvent.getAcceleration());
|
|
}
|
|
// Paper end - call EntityKnockbackByEntityEvent for explosions
|
|
+ // Sakura start - reduce deltamovement allocations
|
|
+ entity.setDeltaMovement(entity.getDeltaMovement().add(vec3d1));
|
|
+ } else {
|
|
+ entity.addDeltaMovement(d8, d9, d10);
|
|
+ // Sakura end - reduce deltamovement allocations
|
|
}
|
|
// CraftBukkit end
|
|
- entity.setDeltaMovement(entity.getDeltaMovement().add(vec3d1));
|
|
if (entity instanceof Player) {
|
|
Player entityhuman = (Player) entity;
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/Block.java b/src/main/java/net/minecraft/world/level/block/Block.java
|
|
index 22036ed3ea0629bc12981a8d91a03e55cc2117d6..73a453ef678ed90ebc1de4d1efc258ad81cf36b8 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/Block.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/Block.java
|
|
@@ -469,7 +469,7 @@ public class Block extends BlockBehaviour implements ItemLike {
|
|
}
|
|
|
|
public void updateEntityAfterFallOn(BlockGetter world, Entity entity) {
|
|
- entity.setDeltaMovement(entity.getDeltaMovement().multiply(1.0D, 0.0D, 1.0D));
|
|
+ entity.multiplyDeltaMovement(1.0D, 0.0D, 1.0D); // Sakura
|
|
}
|
|
|
|
public ItemStack getCloneItemStack(LevelReader world, BlockPos pos, BlockState state) {
|