Search in sources :

Example 1 with GrylynenEntity

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);
                }
            }
        }
    }
}
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)

Aggregations

AlphemKingEntity (io.github.bioplethora.entity.creatures.AlphemKingEntity)1 GrylynenEntity (io.github.bioplethora.entity.creatures.GrylynenEntity)1 HeliobladeEntity (io.github.bioplethora.entity.creatures.HeliobladeEntity)1 ServerWorld (net.minecraft.world.server.ServerWorld)1 SubscribeEvent (net.minecraftforge.eventbus.api.SubscribeEvent)1