6
6
import net .minecraft .client .player .LocalPlayer ;
7
7
import net .minecraft .core .BlockPos ;
8
8
import net .minecraft .tags .BlockTags ;
9
+ import net .minecraft .tags .FluidTags ;
9
10
import net .minecraft .world .entity .Entity ;
10
11
import net .minecraft .world .entity .EntityType ;
11
12
import net .minecraft .world .entity .LivingEntity ;
12
13
import net .minecraft .world .item .ItemStack ;
13
- import net .minecraft .world .item .enchantment .EnchantmentHelper ;
14
14
import net .minecraft .world .item .enchantment .Enchantments ;
15
15
import net .minecraft .world .level .Level ;
16
16
import net .minecraft .world .level .block .Blocks ;
22
22
import org .spongepowered .asm .mixin .Unique ;
23
23
import org .spongepowered .asm .mixin .injection .At ;
24
24
import org .spongepowered .asm .mixin .injection .Inject ;
25
- import org .spongepowered .asm .mixin .injection .Slice ;
26
25
import org .spongepowered .asm .mixin .injection .callback .CallbackInfo ;
27
26
28
27
@ Mixin (LivingEntity .class )
@@ -32,6 +31,8 @@ public abstract class LivingEntityMixin extends Entity {
32
31
@ Shadow
33
32
protected int useItemRemaining ;
34
33
34
+ @ Shadow public abstract boolean isAlive ();
35
+
35
36
public LivingEntityMixin (EntityType <?> entityType_1 , Level level_1 ) {
36
37
super (entityType_1 , level_1 );
37
38
}
@@ -57,11 +58,9 @@ public void onEat(ItemStack stack, int particleCount, CallbackInfo ci) {
57
58
}
58
59
}
59
60
60
- @ Inject (method = "baseTick" ,
61
- slice = @ Slice (from = @ At (value = "FIELD" , target = "Lnet/minecraft/tags/FluidTags;WATER:Lnet/minecraft/tags/TagKey;" , ordinal = 0 )),
62
- at = @ At (value = "INVOKE" , target = "Lnet/minecraft/world/level/Level;getBlockState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/state/BlockState;" , ordinal = 0 ))
61
+ @ Inject (method = "baseTick" , at = @ At (value = "INVOKE" , target = "Lnet/minecraft/world/entity/LivingEntity;isAlive()Z" , ordinal = 0 ))
63
62
public void onUnderwater (CallbackInfo ci ) {
64
- if (isThePlayer ()) {
63
+ if (isThePlayer () && isAlive () && isEyeInFluid ( FluidTags . WATER ) ) {
65
64
PlayerRandCracker .onUnderwater ();
66
65
}
67
66
}
0 commit comments