use of io.github.bioplethora.entity.creatures.GrylynenEntity in project bioplethora by AquexTheSeal.
the class ServerWorldEvents method onLivingHurt.
@SubscribeEvent
public static void onLivingHurt(LivingHurtEvent event) {
boolean dsFire = (event.getSource() == DamageSource.IN_FIRE);
boolean dsVoid = (event.getSource() == DamageSource.OUT_OF_WORLD);
boolean dsFire2 = (event.getSource() == DamageSource.ON_FIRE);
if (event.getEntity() instanceof HeliobladeEntity) {
HeliobladeEntity helioblade = (HeliobladeEntity) event.getEntity();
int shouldDodge = helioblade.getRandom().nextInt(3);
if (!dsFire && !dsVoid && !dsFire2) {
if ((shouldDodge == 1) || (shouldDodge == 2)) {
helioblade.teleportRandomly();
event.setCanceled(true);
}
}
}
if (event.getEntity() instanceof GrylynenEntity) {
GrylynenEntity grylynen = (GrylynenEntity) event.getEntity();
if (!dsVoid) {
event.setAmount(1);
}
}
if (event.getEntity() instanceof AlphemKingEntity) {
AlphemKingEntity king = (AlphemKingEntity) event.getEntity();
if (!dsVoid) {
if (king.isBarriered()) {
king.playSound(SoundEvents.GLASS_BREAK, 1.5F, 1.0F);
king.setBarriered(false);
event.setCanceled(true);
if (!king.level.isClientSide()) {
((ServerWorld) king.level).sendParticles(ParticleTypes.ASH, king.getX(), king.getY(), king.getZ(), 30, 0.75, 0.75, 0.75, 0.01);
}
}
}
}
}
Aggregations