Skip to content

Commit

Permalink
Merge pull request #179 from Elite-Modding-Team/122-dont-attack-ridin…
Browse files Browse the repository at this point in the history
…g-mob-by-owner-while-riding

Bugfix: prevent an owner from attacking their pet while riding/being ridden
  • Loading branch information
demonlexe authored Aug 22, 2024
2 parents a72758d + b025cda commit e3457f6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/main/java/drzhark/mocreatures/entity/MoCEntityMob.java
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,8 @@ public boolean attackEntityFrom(DamageSource damagesource, float i) {
if (!this.world.isRemote && getIsTamed()) {
MoCMessageHandler.INSTANCE.sendToAllAround(new MoCMessageHealth(this.getEntityId(), this.getHealth()), new TargetPoint(this.world.provider.getDimensionType().getId(), this.posX, this.posY, this.posZ, 64));
}
return super.attackEntityFrom(damagesource, i);
Entity entity = damagesource.getTrueSource();
return (this.isBeingRidden() && entity != null && this.isRidingOrBeingRiddenBy(entity)) ? false : super.attackEntityFrom(damagesource, i);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public boolean attackEntityFrom(DamageSource damagesource, float i) {
return false;
}

return super.attackEntityFrom(damagesource, i);
return (this.isBeingRidden() && entity != null && this.isRidingOrBeingRiddenBy(entity)) ? false : super.attackEntityFrom(damagesource, i);
}

private boolean checkOwnership(EntityPlayer player, EnumHand hand) {
Expand Down

0 comments on commit e3457f6

Please sign in to comment.