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