Search in sources :

Example 1 with HeliobladeEntity

use of io.github.bioplethora.entity.creatures.HeliobladeEntity in project bioplethora by AquexTheSeal.

the class HeliobladeCloningGoal method tick.

public void tick() {
    LivingEntity target = this.helioblade.getTarget();
    if (target.distanceToSqr(this.helioblade) < 4096.0D && this.helioblade.canSee(target)) {
        this.helioblade.getLookControl().setLookAt(target, 30.0F, 30.0F);
        BlockPos blockpos = this.helioblade.blockPosition();
        ++this.helioblade.cloneChargeTime;
        if (this.helioblade.cloneChargeTime == 300) {
            if (this.helioblade.level instanceof ServerWorld) {
                ((ServerWorld) this.helioblade.level).sendParticles(ParticleTypes.CAMPFIRE_COSY_SMOKE, this.helioblade.getX(), this.helioblade.getY(), this.helioblade.getZ(), 75, 0.3, 0.2, 0.2, 0.1);
            }
            HeliobladeEntity clone1 = new HeliobladeEntity(BioplethoraEntities.HELIOBLADE.get(), this.helioblade.level);
            clone1.setOwner(this.helioblade);
            clone1.getAttribute(Attributes.ATTACK_DAMAGE).setBaseValue(5 * BioplethoraConfig.COMMON.mobMeeleeDamageMultiplier.get());
            clone1.getAttribute(Attributes.ARMOR).setBaseValue(5 * BioplethoraConfig.COMMON.mobArmorMultiplier.get());
            clone1.getAttribute(Attributes.MAX_HEALTH).setBaseValue(30 * BioplethoraConfig.COMMON.mobHealthMultiplier.get());
            clone1.setHealth(30 * BioplethoraConfig.COMMON.mobHealthMultiplier.get());
            clone1.moveTo(blockpos, 0.1F, 0.1F);
            clone1.setHasLimitedLife(true);
            clone1.setExplodeOnExpiry(false);
            clone1.setLifeLimitBeforeDeath(150 + this.helioblade.getRandom().nextInt(75));
            clone1.setClone(true);
            clone1.teleportRandomly();
            this.helioblade.level.addFreshEntity(clone1);
            HeliobladeEntity clone2 = new HeliobladeEntity(BioplethoraEntities.HELIOBLADE.get(), this.helioblade.level);
            clone2.setOwner(this.helioblade);
            clone2.getAttribute(Attributes.ATTACK_DAMAGE).setBaseValue(5 * BioplethoraConfig.COMMON.mobMeeleeDamageMultiplier.get());
            clone2.getAttribute(Attributes.ARMOR).setBaseValue(5 * BioplethoraConfig.COMMON.mobArmorMultiplier.get());
            clone2.getAttribute(Attributes.MAX_HEALTH).setBaseValue(30 * BioplethoraConfig.COMMON.mobHealthMultiplier.get());
            clone2.setHealth(30 * BioplethoraConfig.COMMON.mobHealthMultiplier.get());
            clone2.moveTo(blockpos, 0.1F, 0.1F);
            clone2.setHasLimitedLife(true);
            clone2.setExplodeOnExpiry(false);
            clone2.setLifeLimitBeforeDeath(150 + this.helioblade.getRandom().nextInt(75));
            clone2.setClone(true);
            clone2.teleportRandomly();
            this.helioblade.level.addFreshEntity(clone2);
            this.helioblade.cloneChargeTime = 0;
        }
    }
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) ServerWorld(net.minecraft.world.server.ServerWorld) HeliobladeEntity(io.github.bioplethora.entity.creatures.HeliobladeEntity) BlockPos(net.minecraft.util.math.BlockPos)

Example 2 with HeliobladeEntity

use of io.github.bioplethora.entity.creatures.HeliobladeEntity in project bioplethora by AquexTheSeal.

the class ServerWorldEvents method onProjectileHit.

@SubscribeEvent
public static void onProjectileHit(ProjectileImpactEvent event) {
    AlphemKingSpawnHelper.onProjectileImpact(event);
    Entity projectile = event.getEntity();
    RayTraceResult result = event.getRayTraceResult();
    if (result instanceof EntityRayTraceResult) {
        // =================================================
        // Totem of Swerving Skill
        // =================================================
        boolean targetIsEntity = ((EntityRayTraceResult) result).getEntity() instanceof LivingEntity;
        if (projectile instanceof AbstractArrowEntity) {
            ((AbstractArrowEntity) projectile).setPierceLevel((byte) 0);
        }
        if (!projectile.level.isClientSide && targetIsEntity) {
            LivingEntity user = ((LivingEntity) ((EntityRayTraceResult) result).getEntity());
            int shouldDodge = user.getRandom().nextInt(3);
            if ((user.getOffhandItem().getItem() instanceof SwervingTotemItem) || (user.getMainHandItem().getItem() instanceof SwervingTotemItem)) {
                if (shouldDodge == 1) {
                    boolean isNegVal = user.getRandom().nextBoolean();
                    int tpLoc = 1 + user.getRandom().nextInt(2);
                    user.level.playSound(null, user.getX(), user.getY(), user.getZ(), SoundEvents.GHAST_SHOOT, SoundCategory.PLAYERS, 1, 1);
                    if (user.level instanceof ServerWorld) {
                        ((ServerWorld) user.level).sendParticles(ParticleTypes.POOF, user.getX(), user.getY(), user.getZ(), 50, 0.65, 0.65, 0.65, 0.01);
                    }
                    BlockPos blockpos = new BlockPos(user.getX() + (isNegVal ? tpLoc : -tpLoc), user.getY(), user.getZ() + (isNegVal ? tpLoc : -tpLoc));
                    if (!user.level.getBlockState(blockpos).getMaterial().blocksMotion()) {
                        user.teleportTo(blockpos.getX(), blockpos.getY(), blockpos.getZ());
                        event.setCanceled(true);
                    }
                }
            }
        }
        // =================================================
        // Mob Special Skills
        // =================================================
        boolean targetIsAltyrus = ((EntityRayTraceResult) result).getEntity() instanceof AltyrusEntity;
        if (projectile instanceof AbstractArrowEntity) {
            ((AbstractArrowEntity) projectile).setPierceLevel((byte) 0);
        }
        if (!projectile.level.isClientSide() && targetIsAltyrus) {
            AltyrusEntity altyrus = ((AltyrusEntity) ((EntityRayTraceResult) result).getEntity());
            int shouldDodge = altyrus.getRandom().nextInt(3);
            if ((shouldDodge == 1) || (shouldDodge == 2)) {
                Vector3d projectilePos = event.getEntity().position();
                Vector3d rVec = altyrus.getLookAngle().yRot(0.5F + (float) Math.PI).add(altyrus.position());
                Vector3d lVec = altyrus.getLookAngle().yRot(0.5F + (float) Math.PI).add(altyrus.position());
                BlockPos pos = new BlockPos((int) altyrus.getX(), (int) altyrus.getY(), (int) altyrus.getZ());
                boolean rDir;
                if (projectilePos.distanceTo(rVec) < projectilePos.distanceTo(lVec)) {
                    rDir = true;
                } else if (projectilePos.distanceTo(rVec) > projectilePos.distanceTo(lVec)) {
                    rDir = false;
                } else {
                    rDir = altyrus.getRandom().nextBoolean();
                }
                Vector3d vectorThingy = event.getEntity().getDeltaMovement().yRot((float) ((rDir ? 0.5F : -0.5F) * Math.PI)).normalize();
                altyrus.setDodging(true);
                altyrus.level.playSound(null, pos, altyrus.getDodgeSound(), SoundCategory.HOSTILE, (float) 1, (float) 1);
                altyrus.setDeltaMovement(altyrus.getDeltaMovement().add(vectorThingy.x() * 0.5F, 0, vectorThingy.z() * 0.5F));
                event.setCanceled(true);
            }
        }
        boolean targetIsHelioblade = ((EntityRayTraceResult) result).getEntity() instanceof HeliobladeEntity;
        if (!projectile.level.isClientSide && targetIsHelioblade) {
            HeliobladeEntity helioblade = ((HeliobladeEntity) ((EntityRayTraceResult) result).getEntity());
            int shouldDodge = helioblade.getRandom().nextInt(3);
            if (projectile instanceof AbstractArrowEntity) {
                ((AbstractArrowEntity) projectile).setPierceLevel((byte) 0);
            }
            if ((shouldDodge == 1) || (shouldDodge == 2)) {
                Vector3d projectilePos = event.getEntity().position();
                Vector3d rVec = helioblade.getLookAngle().yRot(0.5F + (float) Math.PI).add(helioblade.position());
                Vector3d lVec = helioblade.getLookAngle().yRot(0.5F + (float) Math.PI).add(helioblade.position());
                BlockPos pos = new BlockPos((int) helioblade.getX(), (int) helioblade.getY(), (int) helioblade.getZ());
                boolean rDir;
                if (projectilePos.distanceTo(rVec) < projectilePos.distanceTo(lVec)) {
                    rDir = true;
                } else if (projectilePos.distanceTo(rVec) > projectilePos.distanceTo(lVec)) {
                    rDir = false;
                } else {
                    rDir = helioblade.getRandom().nextBoolean();
                }
                Vector3d vectorThingy = event.getEntity().getDeltaMovement().yRot((float) ((rDir ? 0.5F : -0.5F) * Math.PI)).normalize();
                helioblade.setDeltaMovement(helioblade.getDeltaMovement().add(vectorThingy.x() * 1F, 0, vectorThingy.z() * 1F));
                event.setCanceled(true);
            }
        }
        boolean targetIsPrimordialRing = ((EntityRayTraceResult) result).getEntity() instanceof PrimordialRingEntity;
        if (!projectile.level.isClientSide && targetIsPrimordialRing) {
            PrimordialRingEntity primordialRing = ((PrimordialRingEntity) ((EntityRayTraceResult) result).getEntity());
            if (projectile instanceof AbstractArrowEntity) {
                ((AbstractArrowEntity) projectile).setPierceLevel((byte) 0);
            }
            Vector3d projectilePos = event.getEntity().position();
            Vector3d rVec = primordialRing.getLookAngle().yRot(0.5F + (float) Math.PI).add(primordialRing.position());
            Vector3d lVec = primordialRing.getLookAngle().yRot(0.5F + (float) Math.PI).add(primordialRing.position());
            boolean rDir;
            if (projectilePos.distanceTo(rVec) < projectilePos.distanceTo(lVec)) {
                rDir = true;
            } else if (projectilePos.distanceTo(rVec) > projectilePos.distanceTo(lVec)) {
                rDir = false;
            } else {
                rDir = primordialRing.getRandom().nextBoolean();
            }
            Vector3d vectorThingy = event.getEntity().getDeltaMovement().yRot((float) ((rDir ? 0.5F : -0.5F) * Math.PI)).normalize();
            primordialRing.setDeltaMovement(primordialRing.getDeltaMovement().add(vectorThingy.x() * 1F, 0, vectorThingy.z() * 1F));
            event.setCanceled(true);
        }
    }
}
Also used : HeliobladeEntity(io.github.bioplethora.entity.creatures.HeliobladeEntity) PrimordialRingEntity(io.github.bioplethora.entity.others.PrimordialRingEntity) GrylynenEntity(io.github.bioplethora.entity.creatures.GrylynenEntity) Entity(net.minecraft.entity.Entity) AbstractArrowEntity(net.minecraft.entity.projectile.AbstractArrowEntity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) AlphemKingEntity(io.github.bioplethora.entity.creatures.AlphemKingEntity) LivingEntity(net.minecraft.entity.LivingEntity) AltyrusEntity(io.github.bioplethora.entity.creatures.AltyrusEntity) EntityRayTraceResult(net.minecraft.util.math.EntityRayTraceResult) AltyrusEntity(io.github.bioplethora.entity.creatures.AltyrusEntity) RayTraceResult(net.minecraft.util.math.RayTraceResult) EntityRayTraceResult(net.minecraft.util.math.EntityRayTraceResult) LivingEntity(net.minecraft.entity.LivingEntity) ServerWorld(net.minecraft.world.server.ServerWorld) Vector3d(net.minecraft.util.math.vector.Vector3d) PrimordialRingEntity(io.github.bioplethora.entity.others.PrimordialRingEntity) HeliobladeEntity(io.github.bioplethora.entity.creatures.HeliobladeEntity) SwervingTotemItem(io.github.bioplethora.item.functionals.SwervingTotemItem) BlockPos(net.minecraft.util.math.BlockPos) AbstractArrowEntity(net.minecraft.entity.projectile.AbstractArrowEntity) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 3 with HeliobladeEntity

use of io.github.bioplethora.entity.creatures.HeliobladeEntity 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

HeliobladeEntity (io.github.bioplethora.entity.creatures.HeliobladeEntity)3 ServerWorld (net.minecraft.world.server.ServerWorld)3 AlphemKingEntity (io.github.bioplethora.entity.creatures.AlphemKingEntity)2 GrylynenEntity (io.github.bioplethora.entity.creatures.GrylynenEntity)2 LivingEntity (net.minecraft.entity.LivingEntity)2 BlockPos (net.minecraft.util.math.BlockPos)2 SubscribeEvent (net.minecraftforge.eventbus.api.SubscribeEvent)2 AltyrusEntity (io.github.bioplethora.entity.creatures.AltyrusEntity)1 PrimordialRingEntity (io.github.bioplethora.entity.others.PrimordialRingEntity)1 SwervingTotemItem (io.github.bioplethora.item.functionals.SwervingTotemItem)1 Entity (net.minecraft.entity.Entity)1 PlayerEntity (net.minecraft.entity.player.PlayerEntity)1 AbstractArrowEntity (net.minecraft.entity.projectile.AbstractArrowEntity)1 EntityRayTraceResult (net.minecraft.util.math.EntityRayTraceResult)1 RayTraceResult (net.minecraft.util.math.RayTraceResult)1 Vector3d (net.minecraft.util.math.vector.Vector3d)1