mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-27 15:17:59 +01:00
Fixed attack goals, and fixed disguises hurting themselves
This commit is contained in:
parent
96e5af9743
commit
0059e92c2e
1 changed files with 17 additions and 1 deletions
|
@ -8,11 +8,27 @@ import net.minecraft.entity.LivingEntity;
|
||||||
import net.minecraft.entity.mob.MobEntity;
|
import net.minecraft.entity.mob.MobEntity;
|
||||||
|
|
||||||
public class MobBehaviour extends EntityBehaviour<MobEntity> {
|
public class MobBehaviour extends EntityBehaviour<MobEntity> {
|
||||||
|
|
||||||
|
private MobEntity dummy;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Pony player, MobEntity entity, DisguiseSpell spell) {
|
public void update(Pony player, MobEntity entity, DisguiseSpell spell) {
|
||||||
|
|
||||||
if (player.sneakingChanged() && isSneakingOnGround(player)) {
|
if (player.sneakingChanged() && isSneakingOnGround(player)) {
|
||||||
entity.tryAttack(RayTraceHelper.findEntity(player.getEntity(), 6, 1, e -> e instanceof LivingEntity).orElse(entity));
|
|
||||||
|
LivingEntity target = RayTraceHelper.<LivingEntity>findEntity(player.getEntity(), 6, 1,
|
||||||
|
e -> e instanceof LivingEntity && e != entity && e != player.getOwner())
|
||||||
|
.orElseGet(() -> getDummy(entity));
|
||||||
|
|
||||||
|
entity.tryAttack(target);
|
||||||
|
target.setAttacker(player.getOwner());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private MobEntity getDummy(MobEntity entity) {
|
||||||
|
if (dummy == null) {
|
||||||
|
dummy = (MobEntity)entity.getType().create(entity.world);
|
||||||
|
}
|
||||||
|
return dummy;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue