Skip to content

Commit

Permalink
Prevent arrow pickup status from changing when reflecting arrows (#5098)
Browse files Browse the repository at this point in the history
  • Loading branch information
KnightMiner committed Mar 4, 2023
1 parent 89a8fbd commit a7c8457
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.projectile.AbstractArrow;
import net.minecraft.world.entity.projectile.AbstractArrow.Pickup;
import net.minecraft.world.entity.projectile.AbstractHurtingProjectile;
import net.minecraft.world.entity.projectile.Projectile;
import net.minecraft.world.item.ItemStack;
Expand Down Expand Up @@ -61,7 +63,14 @@ private void projectileImpact(ProjectileImpactEvent event) {
// time to actually reflect, this code is strongly based on code from the Parry mod
// take ownership of the projectile so it counts as a player kill, except in the case of fishing bobbers
if (!RegistryHelper.contains(TinkerTags.EntityTypes.REFLECTING_PRESERVE_OWNER, projectile.getType())) {
projectile.setOwner(living);
// arrows are dumb and mutate their pickup status when owner is set, so disagree and set it back
if (projectile instanceof AbstractArrow arrow) {
Pickup pickup = arrow.pickup;
arrow.setOwner(living);
arrow.pickup = pickup;
} else {
projectile.setOwner(living);
}
projectile.leftOwner = true;
}

Expand Down

0 comments on commit a7c8457

Please sign in to comment.