Skip to content

Commit

Permalink
Make invulnerable entities require player attack
Browse files Browse the repository at this point in the history
  • Loading branch information
Patbox committed Dec 14, 2024
1 parent a81750f commit 87bf88c
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import net.minecraft.entity.Entity;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.damage.DamageTypes;
import net.minecraft.registry.tag.DamageTypeTags;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
Expand All @@ -19,7 +20,7 @@ public class EntityMixin {
*/
@Inject(method = "isAlwaysInvulnerableTo", at = @At("HEAD"), cancellable = true)
private void extras$makeExceptionForExplosions(DamageSource damageSource, CallbackInfoReturnable<Boolean> cir) {
if (this.invulnerable && damageSource.isIn(DamageTypeTags.IS_EXPLOSION)) {
if (this.invulnerable && !damageSource.isOf(DamageTypes.PLAYER_ATTACK)) {
cir.setReturnValue(true);
}
}
Expand Down

0 comments on commit 87bf88c

Please sign in to comment.