Fix PickupStatus getting reset

This commit is contained in:
Tamion 2024-07-21 19:11:22 +02:00
parent 15c4f72cf0
commit 92fa922afd
3 changed files with 46 additions and 9 deletions

View File

@ -115,13 +115,12 @@
this.hasImpulse = true; this.hasImpulse = true;
if (this.getPierceLevel() > 0 && projectiledeflection == ProjectileDeflection.NONE) { if (this.getPierceLevel() > 0 && projectiledeflection == ProjectileDeflection.NONE) {
@@ -317,8 +342,21 @@ @@ -318,7 +343,20 @@
this.level().addParticle(ParticleTypes.BUBBLE, pos.x - vec3d1.x * 0.25D, pos.y - vec3d1.y * 0.25D, pos.z - vec3d1.z * 0.25D, vec3d1.x, vec3d1.y, vec3d1.z); this.level().addParticle(ParticleTypes.BUBBLE, pos.x - vec3d1.x * 0.25D, pos.y - vec3d1.y * 0.25D, pos.z - vec3d1.z * 0.25D, vec3d1.x, vec3d1.y, vec3d1.z);
} }
+
+ }
+ }
+
+ // Paper start - Fix cancelling ProjectileHitEvent for piercing arrows + // Paper start - Fix cancelling ProjectileHitEvent for piercing arrows
+ @Override + @Override
+ public ProjectileDeflection preHitTargetOrDeflectSelf(HitResult hitResult) { + public ProjectileDeflection preHitTargetOrDeflectSelf(HitResult hitResult) {
@ -234,7 +233,18 @@
} else { } else {
this.firedFromWeapon = null; this.firedFromWeapon = null;
} }
@@ -688,34 +733,31 @@ @@ -684,38 +729,42 @@
@Override
public void setOwner(@Nullable Entity entity) {
+ // Paper start - Fix PickupStatus getting reset
+ this.setOwner(entity, true);
+ }
+
+ public void setOwner(@Nullable Entity entity, boolean resetPickup) {
+ // Paper end - Fix PickupStatus getting reset
super.setOwner(entity);
+ if (!resetPickup) return; // Paper - Fix PickupStatus getting reset
Entity entity1 = entity; Entity entity1 = entity;
byte b0 = 0; byte b0 = 0;
@ -281,7 +291,7 @@
} }
this.pickup = entityarrow_pickupstatus; this.pickup = entityarrow_pickupstatus;
@@ -724,9 +766,24 @@ @@ -724,9 +773,24 @@
@Override @Override
public void playerTouch(Player player) { public void playerTouch(Player player) {
if (!this.level().isClientSide && (this.isInGround() || this.isNoPhysics()) && this.shakeTime <= 0) { if (!this.level().isClientSide && (this.isInGround() || this.isNoPhysics()) && this.shakeTime <= 0) {

View File

@ -164,7 +164,22 @@
protected ProjectileDeflection hitTargetOrDeflectSelf(HitResult hitResult) { protected ProjectileDeflection hitTargetOrDeflectSelf(HitResult hitResult) {
if (hitResult.getType() == HitResult.Type.ENTITY) { if (hitResult.getType() == HitResult.Type.ENTITY) {
EntityHitResult movingobjectpositionentity = (EntityHitResult) hitResult; EntityHitResult movingobjectpositionentity = (EntityHitResult) hitResult;
@@ -309,6 +393,11 @@ @@ -269,7 +353,13 @@
public boolean deflect(ProjectileDeflection deflection, @Nullable Entity deflector, @Nullable Entity owner, boolean fromAttack) {
deflection.deflect(this, deflector, this.random);
if (!this.level().isClientSide) {
- this.setOwner(owner);
+ // Paper start - Fix PickupStatus getting reset
+ if (this instanceof AbstractArrow arrow) {
+ arrow.setOwner(owner, false);
+ } else {
+ this.setOwner(owner);
+ }
+ // Paper end - Fix PickupStatus getting reset
this.onDeflection(deflector, fromAttack);
}
@@ -309,6 +399,11 @@
protected void onHitEntity(EntityHitResult entityHitResult) {} protected void onHitEntity(EntityHitResult entityHitResult) {}
protected void onHitBlock(BlockHitResult blockHitResult) { protected void onHitBlock(BlockHitResult blockHitResult) {
@ -176,7 +191,7 @@
BlockState iblockdata = this.level().getBlockState(blockHitResult.getBlockPos()); BlockState iblockdata = this.level().getBlockState(blockHitResult.getBlockPos());
iblockdata.onProjectileHit(this.level(), iblockdata, blockHitResult, this); iblockdata.onProjectileHit(this.level(), iblockdata, blockHitResult, this);
@@ -320,6 +409,15 @@ @@ -320,6 +415,15 @@
} else { } else {
Entity entity1 = this.getOwner(); Entity entity1 = this.getOwner();
@ -192,7 +207,7 @@
return entity1 == null || this.leftOwner || !entity1.isPassengerOfSameVehicle(entity); return entity1 == null || this.leftOwner || !entity1.isPassengerOfSameVehicle(entity);
} }
} }
@@ -333,14 +431,8 @@ @@ -333,14 +437,8 @@
} }
protected static float lerpRotation(float prevRot, float newRot) { protected static float lerpRotation(float prevRot, float newRot) {

View File

@ -173,4 +173,16 @@ public class CraftAbstractArrow extends AbstractProjectile implements AbstractAr
this.getHandle().setSoundEvent(org.bukkit.craftbukkit.CraftSound.bukkitToMinecraft(sound)); this.getHandle().setSoundEvent(org.bukkit.craftbukkit.CraftSound.bukkitToMinecraft(sound));
} }
// Paper end // Paper end
// Paper start - Fix PickupStatus getting reset - Copy of CraftProjectile#setShooter, calling setOwner(Entity,boolean)
@Override
public void setShooter(org.bukkit.projectiles.ProjectileSource shooter, boolean resetPickupStatus) {
if (shooter instanceof CraftEntity craftEntity) {
this.getHandle().setOwner(craftEntity.getHandle(), resetPickupStatus);
} else {
this.getHandle().setOwner(null, resetPickupStatus);
}
this.getHandle().projectileSource = shooter;
}
// Paper end - Fix PickupStatus getting reset
} }