Search in sources :

Example 1 with EntityFlare

use of hellfirepvp.astralsorcery.common.entity.EntityFlare in project AstralSorcery by HellFirePvP.

the class MantleEffectBootes method tickServer.

@Override
protected void tickServer(PlayerEntity player) {
    super.tickServer(player);
    ItemStack mantle = player.getItemStackFromSlot(EquipmentSlotType.CHEST);
    if (mantle.isEmpty() || !(mantle.getItem() instanceof ItemMantle)) {
        return;
    }
    World world = player.getEntityWorld();
    List<EntityFlare> flares = gatherFlares(world, mantle);
    if (flares.size() < CONFIG.maxFlareCount.get()) {
        if (player.ticksExisted % 80 == 0) {
            if (AlignmentChargeHandler.INSTANCE.hasCharge(player, LogicalSide.SERVER, CONFIG.chargeCostPerFlare.get()) && rand.nextInt(4) == 0) {
                EntityFlare flare = EntityTypesAS.FLARE.create(player.getEntityWorld());
                flare.setPosition(player.getPosX(), player.getPosY(), player.getPosZ());
                flare.setFollowingTarget(player);
                if (world.addEntity(flare)) {
                    flares.add(flare);
                    AlignmentChargeHandler.INSTANCE.drainCharge(player, LogicalSide.SERVER, CONFIG.chargeCostPerFlare.get(), false);
                }
            }
        }
    }
    for (EntityFlare flare : flares) {
        if (flare.getFollowingTarget() != null && (flare.getAttackTarget() == null ? player.getDistance(flare) >= 12 : player.getDistance(flare) >= 35)) {
            flare.setPositionAndRotation(player.getPosX(), player.getPosY(), player.getPosZ(), 0, 0);
        }
    }
    setEntityIds(mantle, flares.stream().map(Entity::getEntityId).collect(Collectors.toList()));
}
Also used : EntityFlare(hellfirepvp.astralsorcery.common.entity.EntityFlare) Entity(net.minecraft.entity.Entity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) LivingEntity(net.minecraft.entity.LivingEntity) ItemMantle(hellfirepvp.astralsorcery.common.item.armor.ItemMantle) ItemStack(net.minecraft.item.ItemStack) World(net.minecraft.world.World)

Aggregations

EntityFlare (hellfirepvp.astralsorcery.common.entity.EntityFlare)1 ItemMantle (hellfirepvp.astralsorcery.common.item.armor.ItemMantle)1 Entity (net.minecraft.entity.Entity)1 LivingEntity (net.minecraft.entity.LivingEntity)1 PlayerEntity (net.minecraft.entity.player.PlayerEntity)1 ItemStack (net.minecraft.item.ItemStack)1 World (net.minecraft.world.World)1