use of io.github.bioplethora.entity.creatures.AlphemKingEntity 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);
}
}
}
}
}
use of io.github.bioplethora.entity.creatures.AlphemKingEntity in project bioplethora by AquexTheSeal.
the class AlphemKingSpawnHelper method onProjectileImpact.
public static void onProjectileImpact(ProjectileImpactEvent event) {
Entity projectile = event.getEntity();
World world = projectile.level;
RayTraceResult result = event.getRayTraceResult();
if (projectile instanceof WindArrowEntity) {
WindArrowEntity windArrow = (WindArrowEntity) projectile;
if (result instanceof BlockRayTraceResult) {
BlockRayTraceResult blockResult = (BlockRayTraceResult) result;
if (world.getBlockState(blockResult.getBlockPos()).getBlock() == BioplethoraBlocks.ALPHANUM_NUCLEUS.get()) {
BlockUtils.destroyAllNearbyBlocks(world, blockResult.getBlockPos(), 3, 2, 3, false);
if (!world.isClientSide()) {
((ServerWorld) world).sendParticles(ParticleTypes.CLOUD, windArrow.getX(), windArrow.getY(), windArrow.getZ(), 30, 1.2, 1.2, 1.2, 0.1);
if (BioplethoraConfig.COMMON.announceAlphemKing.get()) {
List<ServerPlayerEntity> list = ((ServerWorld) world).getPlayers((playerEntity) -> true);
for (ServerPlayerEntity serverplayerentity : list) {
serverplayerentity.playSound(SoundEvents.WITHER_DEATH, 1.0F, 1.0F);
serverplayerentity.displayClientMessage(new TranslationTextComponent("message.bioplethora.alphem_king.summon", windArrow.getOwner().getDisplayName(), windArrow.getX(), windArrow.getY(), windArrow.getZ()).withStyle(TextFormatting.RED).withStyle(TextFormatting.BOLD), false);
}
}
}
windArrow.playSound(SoundEvents.FIREWORK_ROCKET_LARGE_BLAST, 1.0F, 1.0F);
AlphemKingEntity king = new AlphemKingEntity(BioplethoraEntities.ALPHEM_KING.get(), world);
king.moveTo(blockResult.getBlockPos(), 30.0F, 30.0F);
king.setBarriered(true);
world.addFreshEntity(king);
windArrow.remove();
}
}
}
}
Aggregations