9
0
mirror of https://github.com/Samsuik/Sakura.git synced 2026-01-06 15:41:49 +00:00

Keep the bukkitEntity around after changing the handle

This commit is contained in:
Samsuik
2025-02-13 21:17:17 +00:00
parent e236d4e54a
commit 9c28db86b2
9 changed files with 41 additions and 40 deletions

View File

@@ -209,10 +209,10 @@ index 0aea28a20f775b5df2ae2f92e435c84152b4d4be..839ab14b901f7deae5c53626c16ff1e7
this.guardEntityTick(this::tickNonPassenger, entity);
gameprofilerfiller.pop();
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 2946d081032f6d8481643b43420f23b9bd6184d6..ed536165683302e22d50cacc49f7c341c67018d9 100644
index 2946d081032f6d8481643b43420f23b9bd6184d6..33f3a18eb0ef90bc71f1f40c3fd057cc50d22b2b 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -565,6 +565,123 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -565,6 +565,124 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
return to.entityState() != null && to.entityState().isCurrentState(this);
}
// Sakura end - store entity data/state
@@ -329,14 +329,15 @@ index 2946d081032f6d8481643b43420f23b9bd6184d6..ed536165683302e22d50cacc49f7c341
+ //noinspection ConstantValue
+ if (this.bukkitEntity != null) {
+ this.bukkitEntity.setHandle(entity);
+ } else {
+ this.bukkitEntity = entity.getBukkitEntity();
+ }
+ this.bukkitEntity = entity.getBukkitEntity();
+ }
+ // Sakura end - cannon entity merging
public Entity(EntityType<?> type, Level world) {
this.id = Entity.ENTITY_COUNTER.incrementAndGet();
@@ -611,6 +728,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -611,6 +729,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
this.getEntityData().registrationLocked = true; // Spigot
this.setPos(0.0D, 0.0D, 0.0D);
this.eyeHeight = this.getEyeHeight(net.minecraft.world.entity.Pose.STANDING, this.dimensions);
@@ -344,7 +345,7 @@ index 2946d081032f6d8481643b43420f23b9bd6184d6..ed536165683302e22d50cacc49f7c341
}
public boolean isColliding(BlockPos pos, BlockState state) {
@@ -2317,6 +2435,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -2317,6 +2436,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
nbt.putBoolean("Paper.FreezeLock", true);
}
// Paper end
@@ -356,7 +357,7 @@ index 2946d081032f6d8481643b43420f23b9bd6184d6..ed536165683302e22d50cacc49f7c341
return nbt;
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "Saving entity NBT");
@@ -2484,6 +2607,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -2484,6 +2608,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
freezeLocked = nbt.getBoolean("Paper.FreezeLock");
}
// Paper end
@@ -368,7 +369,7 @@ index 2946d081032f6d8481643b43420f23b9bd6184d6..ed536165683302e22d50cacc49f7c341
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "Loading entity NBT");
@@ -4529,6 +4657,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -4529,6 +4658,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
return;
}
// Paper end - rewrite chunk system

View File

@@ -5,10 +5,10 @@ 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 89acaac907dbc948707882e1e9b37eeb507c5037..acc90e8d519bbfad624146675ec26a61d2434781 100644
index 33f3a18eb0ef90bc71f1f40c3fd057cc50d22b2b..9c12e45314fccc48dc0b64e813afe75aab88c84a 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -1141,6 +1141,92 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -1142,6 +1142,92 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
}
// Paper end - detailed watchdog information
@@ -101,7 +101,7 @@ index 89acaac907dbc948707882e1e9b37eeb507c5037..acc90e8d519bbfad624146675ec26a61
public void move(MoverType movementType, Vec3 movement) {
// Paper start - detailed watchdog information
io.papermc.paper.util.TickThread.ensureTickThread("Cannot move an entity off-main");
@@ -1493,6 +1579,88 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -1494,6 +1580,88 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
return offsetFactor;
}

View File

@@ -5,18 +5,18 @@ Subject: [PATCH] isPushedByFluid API
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index d60a0e771a2a1769405a2cb7e293ef7c370b2f7e..2c59ac30260d76557a36cfcff66ba1f2f7d35442 100644
index 9c12e45314fccc48dc0b64e813afe75aab88c84a..2f8a5f5434bdcf1d992df9cb2a3ee8028f395a53 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -682,6 +682,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
this.bukkitEntity = entity.getBukkitEntity();
@@ -683,6 +683,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
}
}
// Sakura end - cannon entity merging
+ public boolean pushedByFluid = true; // Sakura - entity pushed by fluid api
public Entity(EntityType<?> type, Level world) {
this.id = Entity.ENTITY_COUNTER.incrementAndGet();
@@ -3954,7 +3955,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -3955,7 +3956,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
}
public boolean isPushedByFluid() {

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Optimise TNT fluid state and pushing
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 99be514200cde762923f8bd49dc75c248d4646af..0424482f0cf09929fe4e781181f1bb1c343a4072 100644
index 2f8a5f5434bdcf1d992df9cb2a3ee8028f395a53..16934f888e0a7609bd803bc988d5307e27eae793 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -2017,7 +2017,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -2018,7 +2018,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
return this.isInWater() || flag;
}

View File

@@ -75,7 +75,7 @@ index 52c1990bd3bcfe0a3f6e70748fca42f3e3994da4..49a698d9e5559aac4943b4b0ae3ced13
protected void startExplosion() {
for (int i = this.calculateExplosionPotential() - 1; i >= 0; --i) {
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 0424482f0cf09929fe4e781181f1bb1c343a4072..fb9d93de6ea371a2fb3423db5022207e3becf7ba 100644
index 16934f888e0a7609bd803bc988d5307e27eae793..4b35f249ee880e07acd0e0b642e86f6486a6ded8 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -362,7 +362,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -87,7 +87,7 @@ index 0424482f0cf09929fe4e781181f1bb1c343a4072..fb9d93de6ea371a2fb3423db5022207e
public boolean isInPowderSnow;
public boolean wasInPowderSnow;
public boolean wasOnFire;
@@ -683,6 +683,13 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -684,6 +684,13 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
}
// Sakura end - cannon entity merging
public boolean pushedByFluid = true; // Sakura - entity pushed by fluid api
@@ -101,7 +101,7 @@ index 0424482f0cf09929fe4e781181f1bb1c343a4072..fb9d93de6ea371a2fb3423db5022207e
public Entity(EntityType<?> type, Level world) {
this.id = Entity.ENTITY_COUNTER.incrementAndGet();
@@ -1148,7 +1155,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -1149,7 +1156,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
if (this.noPhysics) {
this.setPos(this.getX() + movement.x, this.getY() + movement.y, this.getZ() + movement.z);
} else {
@@ -110,7 +110,7 @@ index 0424482f0cf09929fe4e781181f1bb1c343a4072..fb9d93de6ea371a2fb3423db5022207e
movement = this.limitPistonMovement(movement);
if (movement.equals(Vec3.ZERO)) {
return;
@@ -1166,8 +1173,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -1167,8 +1174,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
Vec3 vec3d1 = this.collideScan(movement);
double d0 = vec3d1.lengthSqr();
@@ -121,7 +121,7 @@ index 0424482f0cf09929fe4e781181f1bb1c343a4072..fb9d93de6ea371a2fb3423db5022207e
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) {
@@ -1203,6 +1210,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -1204,6 +1211,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
if (this.horizontalCollision) {
Vec3 vec3d2 = this.getDeltaMovement();
@@ -134,7 +134,7 @@ index 0424482f0cf09929fe4e781181f1bb1c343a4072..fb9d93de6ea371a2fb3423db5022207e
this.setDeltaMovement(flag ? 0.0D : vec3d2.x, vec3d2.y, flag1 ? 0.0D : vec3d2.z);
}
@@ -1243,7 +1256,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -1244,7 +1257,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
this.setPos(this.getX() + movement.x, this.getY() + movement.y, this.getZ() + movement.z);
} else {
this.wasOnFire = this.isOnFire();
@@ -143,7 +143,7 @@ index 0424482f0cf09929fe4e781181f1bb1c343a4072..fb9d93de6ea371a2fb3423db5022207e
this.activatedTick = Math.max(this.activatedTick, MinecraftServer.currentTick + 20); // Paper
this.activatedImmunityTick = Math.max(this.activatedImmunityTick, MinecraftServer.currentTick + 20); // Paper
movement = this.limitPistonMovement(movement);
@@ -1270,8 +1283,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -1271,8 +1284,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
Vec3 vec3d1 = this.collide(movement);
double d0 = vec3d1.lengthSqr();
@@ -154,7 +154,7 @@ index 0424482f0cf09929fe4e781181f1bb1c343a4072..fb9d93de6ea371a2fb3423db5022207e
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) {
@@ -1307,6 +1320,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -1308,6 +1321,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
if (this.horizontalCollision) {
Vec3 vec3d2 = this.getDeltaMovement();
@@ -167,7 +167,7 @@ index 0424482f0cf09929fe4e781181f1bb1c343a4072..fb9d93de6ea371a2fb3423db5022207e
this.setDeltaMovement(flag ? 0.0D : vec3d2.x, vec3d2.y, flag1 ? 0.0D : vec3d2.z);
}
@@ -1595,7 +1614,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -1596,7 +1615,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
} else {
final AABB bb = currBoundingBox.expandTowards(movement.x, movement.y, movement.z);
this.collectCollisions(bb, potentialCollisionsBB);
@@ -176,7 +176,7 @@ index 0424482f0cf09929fe4e781181f1bb1c343a4072..fb9d93de6ea371a2fb3423db5022207e
}
}
@@ -1604,7 +1623,10 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -1605,7 +1624,10 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
double y = movement.y;
double z = movement.z;
@@ -188,7 +188,7 @@ index 0424482f0cf09929fe4e781181f1bb1c343a4072..fb9d93de6ea371a2fb3423db5022207e
if (y != 0.0) {
y = this.scanY(currBoundingBox, y, bbList);
@@ -1707,7 +1729,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -1708,7 +1730,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
io.papermc.paper.util.CollisionUtil.addBoxesToIfIntersects(world.getWorldBorder().getCollisionShape(), collisionBox, potentialCollisions);
}
@@ -197,7 +197,7 @@ index 0424482f0cf09929fe4e781181f1bb1c343a4072..fb9d93de6ea371a2fb3423db5022207e
if (stepHeight > 0.0
&& (this.onGround || (limitedMoveVector.y != movement.y && movement.y < 0.0))
@@ -1826,8 +1848,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -1827,8 +1849,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
protected void checkInsideBlocks() {
AABB axisalignedbb = this.getBoundingBox();

View File

@@ -38,10 +38,10 @@ index 93977027caa8c398ca6f0d2bb0890231adf8bf49..07d3aac679ed4a3d85573706bd664e4d
if (predicate != null && !predicate.test(blockData, mutablePos)) {
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index fb9d93de6ea371a2fb3423db5022207e3becf7ba..8c1c978cd6cfbe6b987e6cf9a3be4283c78f2b1f 100644
index 4b35f249ee880e07acd0e0b642e86f6486a6ded8..28e1768bdcc2c45643272b759da95452a324a59d 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -690,6 +690,18 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -691,6 +691,18 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
return this.physics;
}
// Sakura end - physics version api

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Optimise check inside blocks and fluids
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 8c1c978cd6cfbe6b987e6cf9a3be4283c78f2b1f..6ec4376f84c8f1a1a9ef1060377e35d5cba5290e 100644
index 28e1768bdcc2c45643272b759da95452a324a59d..868649a111694e0d0c267f7fdc5ffd3fd01cd748 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -1866,14 +1866,34 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -1867,14 +1867,34 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
BlockPos blockposition1 = new BlockPos(axisalignedbb.maxX - offset, axisalignedbb.maxY - offset, axisalignedbb.maxZ - offset);
// Sakura end
@@ -47,7 +47,7 @@ index 8c1c978cd6cfbe6b987e6cf9a3be4283c78f2b1f..6ec4376f84c8f1a1a9ef1060377e35d5
try {
iblockdata.entityInside(this.level, blockposition_mutableblockposition, this);
@@ -4455,7 +4475,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -4456,7 +4476,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
}
public boolean updateFluidHeightAndDoFluidPushing(TagKey<Fluid> tag, double speed) {
@@ -56,7 +56,7 @@ index 8c1c978cd6cfbe6b987e6cf9a3be4283c78f2b1f..6ec4376f84c8f1a1a9ef1060377e35d5
return false;
} else {
AABB axisalignedbb = this.getBoundingBox().deflate(0.001D);
@@ -4472,11 +4492,31 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -4473,11 +4493,31 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
int k1 = 0;
BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos();

View File

@@ -21,10 +21,10 @@ index ab5472c27f94e196a2747466f8721173cef937fc..c32140ded7da15123774b24438305285
} else { entity.inactiveTick(); } // Paper - EAR 2
this.getProfiler().pop();
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 6ec4376f84c8f1a1a9ef1060377e35d5cba5290e..152988e793a61556d76c2067424acb60874a553e 100644
index 868649a111694e0d0c267f7fdc5ffd3fd01cd748..13906fc7d31e11d75754fe2c39c5ddf267d5ddb0 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -702,6 +702,19 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -703,6 +703,19 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
return false;
}
// Sakura end - Treat all collidable blocks as full when moving fast
@@ -44,7 +44,7 @@ index 6ec4376f84c8f1a1a9ef1060377e35d5cba5290e..152988e793a61556d76c2067424acb60
public Entity(EntityType<?> type, Level world) {
this.id = Entity.ENTITY_COUNTER.incrementAndGet();
@@ -749,6 +762,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -750,6 +763,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
this.setPos(0.0D, 0.0D, 0.0D);
this.eyeHeight = this.getEyeHeight(net.minecraft.world.entity.Pose.STANDING, this.dimensions);
this.mergeLevel = level.sakuraConfig().cannons.mergeLevel; // Sakura

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Configurable left shooting and adjusting limits
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 152988e793a61556d76c2067424acb60874a553e..c9c1602fba85e8d1c4074289a674e8a741f866e8 100644
index 13906fc7d31e11d75754fe2c39c5ddf267d5ddb0..8b7cb6929d40db0844b594282cf32d98e54c6217 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -715,6 +715,24 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -716,6 +716,24 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
return Math.max(x, z) >= this.travelDistanceLimit;
}
// Sakura end - entity travel distance limits
@@ -33,7 +33,7 @@ index 152988e793a61556d76c2067424acb60874a553e..c9c1602fba85e8d1c4074289a674e8a7
public Entity(EntityType<?> type, Level world) {
this.id = Entity.ENTITY_COUNTER.incrementAndGet();
@@ -1653,6 +1671,25 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -1654,6 +1672,25 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
final boolean xSmaller = this.physics == null || this.physics.afterOrEqual(1_14_0) ? Math.abs(x) < Math.abs(z)
: this.physics.isLegacy() && Math.abs(x) > Math.abs(z);
// Sakura end - physics version api