Skip to content

Commit c34ea84

Browse files
authored
fix MC-299115 (closes #463) (#464)
1 parent 450cdf3 commit c34ea84

File tree

3 files changed

+39
-3
lines changed

3 files changed

+39
-3
lines changed

PATCHED.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@
114114
| Basic | [MC-271899](https://bugs.mojang.com/browse/MC-271899) | StructureTemplate Palette's caches are not thread safe |
115115
| Basic | [MC-272431](https://bugs.mojang.com/browse/MC-272431) | Ender Dragon incorrect vertical velocity causes erratic behavior |
116116
| Basic | [MC-298066](https://bugs.mojang.com/browse/MC-298066) | Directly entering a bed from a mount places the player in the wrong place |
117+
| Basic | [MC-299115](https://bugs.mojang.com/browse/MC-299115) | Arrow losing owner tag when deflected whilst owner being offline |
118+
|
117119

118120
## Previously patched
119121
Bugs that this mod has patched but has been superseded by a vanilla update.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package dev.isxander.debugify.mixins.basic.mc299115;
2+
3+
import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
4+
import dev.isxander.debugify.fixes.BugFix;
5+
import dev.isxander.debugify.fixes.FixCategory;
6+
import net.minecraft.world.entity.Entity;
7+
import net.minecraft.world.entity.EntityReference;
8+
import net.minecraft.world.entity.projectile.Projectile;
9+
import org.jetbrains.annotations.Nullable;
10+
import org.spongepowered.asm.mixin.Mixin;
11+
import org.spongepowered.asm.mixin.Shadow;
12+
import org.spongepowered.asm.mixin.injection.At;
13+
14+
@BugFix(id = "MC-299115", category = FixCategory.BASIC, env = BugFix.Env.SERVER, description = "Arrow loses owner tag when deflected whilst owner is offline.")
15+
@Mixin(Projectile.class)
16+
public class ProjectileMixin {
17+
@Shadow
18+
@Nullable
19+
protected EntityReference<Entity> owner;
20+
21+
/**
22+
* This deflect method takes the `Entity` owner, not an `EntityReference<Entity>`.
23+
* This means during deflection, the owner is resolved from its reference.
24+
* Because the owner is no longer online, it is nullified.
25+
*/
26+
@WrapWithCondition(method = "deflect", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/projectile/Projectile;setOwner(Lnet/minecraft/world/entity/Entity;)V"))
27+
private boolean preventNullifyingOwner(Projectile instance, Entity owner) {
28+
// only allow setting the owner if:
29+
// 1. the new owner is not null
30+
// 2. the current owner reference is null (which means it never had a reference to any owner)
31+
return this.owner == null || owner != null;
32+
}
33+
}

src/main/resources/debugify.mixins.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
"basic.mc132878.ArmorStandMixin",
2424
"basic.mc134110.ChestBlockMixin",
2525
"basic.mc136249.LivingEntityMixin",
26-
"basic.mc147659.CatSpawnerMixin",
2726
"basic.mc139041.FishingRodItemMixin",
27+
"basic.mc147659.CatSpawnerMixin",
2828
"basic.mc147784.FletchingTableBlockMixin",
2929
"basic.mc155509.PufferfishMixin",
3030
"basic.mc159283.DensityFunctionsMixin",
@@ -44,12 +44,12 @@
4444
"basic.mc206922.EntityMixin",
4545
"basic.mc206922.ItemEntityMixin",
4646
"basic.mc215530.ServerPlayerMixin",
47-
"basic.mc221257.ShulkerBulletMixin",
4847
"basic.mc219981.ZombieMixin",
48+
"basic.mc221257.ShulkerBulletMixin",
4949
"basic.mc223153.BlocksMixin",
5050
"basic.mc224729.ChunkMapMixin",
51-
"basic.mc227008.EnderManMixin",
5251
"basic.mc226961.ExperienceOrbMixin",
52+
"basic.mc227008.EnderManMixin",
5353
"basic.mc227337.ShulkerBulletMixin",
5454
"basic.mc231743.FlowerPotBlockMixin",
5555
"basic.mc232869.StriderMixin",
@@ -59,6 +59,7 @@
5959
"basic.mc271899.StructureTemplateMixin",
6060
"basic.mc272431.EnderDragonMixin",
6161
"basic.mc298066.LivingEntityMixin",
62+
"basic.mc299115.ProjectileMixin",
6263
"basic.mc30391.LivingEntityMixin",
6364
"basic.mc69216.ServerPlayerMixin",
6465
"basic.mc7569.RconConsoleSourceMixin",

0 commit comments

Comments
 (0)