Search in sources :

Example 1 with AlphemKingEntity

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);
                }
            }
        }
    }
}
Also used : ServerWorld(net.minecraft.world.server.ServerWorld) HeliobladeEntity(io.github.bioplethora.entity.creatures.HeliobladeEntity) AlphemKingEntity(io.github.bioplethora.entity.creatures.AlphemKingEntity) GrylynenEntity(io.github.bioplethora.entity.creatures.GrylynenEntity) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 2 with AlphemKingEntity

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();
            }
        }
    }
}
Also used : WindArrowEntity(io.github.bioplethora.entity.projectile.WindArrowEntity) ServerWorld(net.minecraft.world.server.ServerWorld) Entity(net.minecraft.entity.Entity) AlphemKingEntity(io.github.bioplethora.entity.creatures.AlphemKingEntity) WindArrowEntity(io.github.bioplethora.entity.projectile.WindArrowEntity) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) BlockRayTraceResult(net.minecraft.util.math.BlockRayTraceResult) RayTraceResult(net.minecraft.util.math.RayTraceResult) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) BlockRayTraceResult(net.minecraft.util.math.BlockRayTraceResult) AlphemKingEntity(io.github.bioplethora.entity.creatures.AlphemKingEntity) ServerWorld(net.minecraft.world.server.ServerWorld) World(net.minecraft.world.World)

Aggregations

AlphemKingEntity (io.github.bioplethora.entity.creatures.AlphemKingEntity)2 ServerWorld (net.minecraft.world.server.ServerWorld)2 GrylynenEntity (io.github.bioplethora.entity.creatures.GrylynenEntity)1 HeliobladeEntity (io.github.bioplethora.entity.creatures.HeliobladeEntity)1 WindArrowEntity (io.github.bioplethora.entity.projectile.WindArrowEntity)1 Entity (net.minecraft.entity.Entity)1 ServerPlayerEntity (net.minecraft.entity.player.ServerPlayerEntity)1 BlockRayTraceResult (net.minecraft.util.math.BlockRayTraceResult)1 RayTraceResult (net.minecraft.util.math.RayTraceResult)1 TranslationTextComponent (net.minecraft.util.text.TranslationTextComponent)1 World (net.minecraft.world.World)1 SubscribeEvent (net.minecraftforge.eventbus.api.SubscribeEvent)1