mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-23 21:38:00 +01:00
Fixed bulb attacking players in creative and spectator mode
This commit is contained in:
parent
7b78cbc49c
commit
b467aae7b2
2 changed files with 22 additions and 13 deletions
|
@ -181,6 +181,10 @@ public class IgnominiousBulbEntity extends MobEntity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LivingEntity target = getAttacker();
|
LivingEntity target = getAttacker();
|
||||||
|
if (!canTarget(target)) {
|
||||||
|
target = null;
|
||||||
|
setAttacker(null);
|
||||||
|
}
|
||||||
|
|
||||||
if (angryTicks > 0) {
|
if (angryTicks > 0) {
|
||||||
angryTicks--;
|
angryTicks--;
|
||||||
|
@ -194,13 +198,14 @@ public class IgnominiousBulbEntity extends MobEntity {
|
||||||
Pony.of(player).getMagicalReserves().getEnergy().add(6);
|
Pony.of(player).getMagicalReserves().getEnergy().add(6);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final LivingEntity t = target;
|
||||||
tentacles.values()
|
tentacles.values()
|
||||||
.stream()
|
.stream()
|
||||||
.flatMap(tentacle -> tentacle.getOrEmpty(getWorld()).stream())
|
.flatMap(tentacle -> tentacle.getOrEmpty(getWorld()).stream())
|
||||||
.sorted(Comparator.comparing(a -> a.distanceTo(target)))
|
.sorted(Comparator.comparing(a -> a.distanceTo(t)))
|
||||||
.limit(2)
|
.limit(2)
|
||||||
.forEach(tentacle -> {
|
.forEach(tentacle -> {
|
||||||
tentacle.setTarget(target);
|
tentacle.setTarget(t);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -171,17 +171,21 @@ public class TentacleEntity extends AbstractDecorationEntity {
|
||||||
if (isAttacking()) {
|
if (isAttacking()) {
|
||||||
if (--attackingTicks == 12) {
|
if (--attackingTicks == 12) {
|
||||||
if (target != null) {
|
if (target != null) {
|
||||||
target.damage(getDamageSources().create(DamageTypes.MOB_ATTACK, this), 15);
|
if (!canTarget(target)) {
|
||||||
Vec3d diff = target.getPos().subtract(getPos());
|
target = null;
|
||||||
target.takeKnockback(1, diff.x, diff.z);
|
} else {
|
||||||
|
target.damage(getDamageSources().create(DamageTypes.MOB_ATTACK, this), 15);
|
||||||
|
Vec3d diff = target.getPos().subtract(getPos());
|
||||||
|
target.takeKnockback(1, diff.x, diff.z);
|
||||||
|
|
||||||
ParticleUtils.spawnParticles(ParticleTypes.CLOUD, target, 10);
|
ParticleUtils.spawnParticles(ParticleTypes.CLOUD, target, 10);
|
||||||
|
|
||||||
for (Entity bystander : getWorld().getOtherEntities(target, target.getBoundingBox().expand(3))) {
|
for (Entity bystander : getWorld().getOtherEntities(target, target.getBoundingBox().expand(3))) {
|
||||||
if (bystander instanceof LivingEntity l) {
|
if (bystander instanceof LivingEntity l) {
|
||||||
diff = l.getPos().subtract(getPos());
|
diff = l.getPos().subtract(getPos());
|
||||||
l.takeKnockback(1, diff.x, diff.z);
|
l.takeKnockback(1, diff.x, diff.z);
|
||||||
ParticleUtils.spawnParticles(ParticleTypes.CLOUD, target, 10);
|
ParticleUtils.spawnParticles(ParticleTypes.CLOUD, target, 10);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,9 +262,9 @@ public class TentacleEntity extends AbstractDecorationEntity {
|
||||||
|
|
||||||
protected boolean canTarget(LivingEntity target) {
|
protected boolean canTarget(LivingEntity target) {
|
||||||
return target != null
|
return target != null
|
||||||
&& !target.isRemoved()
|
&& target.isPartOfGame()
|
||||||
|
&& target.canTakeDamage()
|
||||||
&& !target.isSneaky()
|
&& !target.isSneaky()
|
||||||
&& !(target instanceof PlayerEntity player && (player.isCreative() || player.isSpectator()))
|
|
||||||
&& canSee(target);
|
&& canSee(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue