Search in sources :

Example 1 with PartialEffectExecutor

use of hellfirepvp.astralsorcery.common.util.PartialEffectExecutor in project AstralSorcery by HellFirePvP.

the class TileLens method doColorEffects.

private void doColorEffects() {
    World world = this.getWorld();
    if (!world.isRemote() && !this.occupiedConnections.isEmpty()) {
        this.occupiedConnections.clear();
        markForUpdate();
        preventNetworkSync();
    }
    if (accumulatedStarlight <= 0) {
        return;
    }
    float effectMultiplier = accumulatedStarlight * 1.4F;
    accumulatedStarlight = 0;
    List<BlockPos> linked = getLinkedPositions();
    if (linked.isEmpty()) {
        return;
    }
    Vector3 thisVec = new Vector3(this).add(0.5, 0.5, 0.5);
    for (BlockPos linkedTo : linked) {
        PartialEffectExecutor exec = new PartialEffectExecutor((1F / ((float) linked.size())) * effectMultiplier, rand);
        Vector3 to = new Vector3(linkedTo).add(0.5, 0.5, 0.5);
        RaytraceAssist rta = new RaytraceAssist(thisVec, to).includeEndPoint();
        if (colorType.getType().doBlockInteraction()) {
            if (!rta.isClear(world) && rta.positionHit() != null) {
                BlockPos posHit = rta.positionHit();
                BlockState stateHit = world.getBlockState(posHit);
                colorType.blockInBeam(world, posHit, stateHit, exec);
                if (!world.isRemote()) {
                    this.occupiedConnections.add(posHit);
                }
            } else {
                if (!world.isRemote()) {
                    this.occupiedConnections.add(linkedTo);
                }
            }
        }
        if (colorType.getType().doEntityInteraction()) {
            exec.reset();
            rta.setCollectEntities(0.5);
            rta.isClear(world);
            List<Entity> found = rta.collectedEntities(world);
            found.forEach(e -> colorType.entityInBeam(world, thisVec, to, e, exec));
        }
    }
}
Also used : Entity(net.minecraft.entity.Entity) BlockState(net.minecraft.block.BlockState) PartialEffectExecutor(hellfirepvp.astralsorcery.common.util.PartialEffectExecutor) BlockPos(net.minecraft.util.math.BlockPos) Vector3(hellfirepvp.astralsorcery.common.util.data.Vector3) World(net.minecraft.world.World) RaytraceAssist(hellfirepvp.astralsorcery.common.util.RaytraceAssist)

Example 2 with PartialEffectExecutor

use of hellfirepvp.astralsorcery.common.util.PartialEffectExecutor in project AstralSorcery by HellFirePvP.

the class StarlightReceiverRitualPedestal method doRitualEffect.

private void doRitualEffect(World world) {
    ConstellationEffectProperties properties = this.effect.createProperties(this.getMirrorCount());
    if (this.channelingTrait != null) {
        this.channelingTrait.affectConstellationEffect(properties);
    }
    properties.multiplySize(CrystalCalculations.getRitualEffectRangeFactor(this, this.attributes));
    float maxDrain = 12;
    maxDrain *= CrystalCalculations.getRitualCostReductionFactor(this, this.attributes);
    maxDrain /= Math.max(1F, ((float) (this.getMirrorCount() - 1)) * 0.33F);
    float ritualStrength = ((float) collectedStarlight) / maxDrain;
    BlockPos to = getLocationPos();
    if (this.ritualLinkPos != null) {
        to = this.ritualLinkPos;
    }
    if (this.effect instanceof ConstellationEffectStatus && this.collectedStarlight > 0) {
        this.collectedStarlight = 0;
        if (this.effect.getConfig().enabled.get() && ((ConstellationEffectStatus) this.effect).runStatusEffect(world, to, this.getMirrorCount(), properties, this.channelingTrait)) {
            markDirty(world);
        }
        return;
    }
    float max = 10F * properties.getEffectAmplifier();
    float stretch = 10F / properties.getPotency();
    float executeTimes = (float) Math.atan(ritualStrength / stretch) * max;
    if (properties.isCorrupted()) {
        executeTimes *= Math.max(rand.nextDouble() * 1.4, 0.1);
    }
    PartialEffectExecutor exec = new PartialEffectExecutor(executeTimes, rand);
    while (exec.canExecute()) {
        exec.markExecution();
        if (this.effect.getConfig().enabled.get()) {
            boolean didEffectExecute;
            if (this.effect.needsChunkToBeLoaded()) {
                didEffectExecute = MiscUtils.executeWithChunk(world, to, to, (pos) -> {
                    return this.effect.playEffect(world, pos, properties, this.channelingTrait);
                }, false);
            } else {
                didEffectExecute = this.effect.playEffect(world, to, properties, this.channelingTrait);
            }
            if (didEffectExecute) {
                markDirty(world);
            }
        }
    }
    this.collectedStarlight = 0F;
}
Also used : TileRitualPedestal(hellfirepvp.astralsorcery.common.tile.TileRitualPedestal) Vector3(hellfirepvp.astralsorcery.common.util.data.Vector3) java.util(java.util) NBTHelper(hellfirepvp.astralsorcery.common.util.nbt.NBTHelper) Constants(net.minecraftforge.common.util.Constants) IMinorConstellation(hellfirepvp.astralsorcery.common.constellation.IMinorConstellation) SkyHandler(hellfirepvp.astralsorcery.common.constellation.SkyHandler) ConstellationEffectRegistry(hellfirepvp.astralsorcery.common.constellation.effect.ConstellationEffectRegistry) CompoundNBT(net.minecraft.nbt.CompoundNBT) SimpleTransmissionReceiver(hellfirepvp.astralsorcery.common.starlight.transmission.base.SimpleTransmissionReceiver) SkyCollectionHelper(hellfirepvp.astralsorcery.common.util.world.SkyCollectionHelper) IPrismTransmissionNode(hellfirepvp.astralsorcery.common.starlight.transmission.IPrismTransmissionNode) DayTimeHelper(hellfirepvp.astralsorcery.common.constellation.world.DayTimeHelper) IWeakConstellation(hellfirepvp.astralsorcery.common.constellation.IWeakConstellation) MiscUtils(hellfirepvp.astralsorcery.common.util.MiscUtils) IConstellation(hellfirepvp.astralsorcery.common.constellation.IConstellation) RaytraceAssist(hellfirepvp.astralsorcery.common.util.RaytraceAssist) INBT(net.minecraft.nbt.INBT) ISeedReader(net.minecraft.world.ISeedReader) Nullable(javax.annotation.Nullable) LogicalSide(net.minecraftforge.fml.LogicalSide) ListNBT(net.minecraft.nbt.ListNBT) WorldNetworkHandler(hellfirepvp.astralsorcery.common.starlight.WorldNetworkHandler) World(net.minecraft.world.World) ConstellationEffectStatus(hellfirepvp.astralsorcery.common.constellation.effect.ConstellationEffectStatus) BlockPos(net.minecraft.util.math.BlockPos) ConstellationEffect(hellfirepvp.astralsorcery.common.constellation.effect.ConstellationEffect) TransmissionProvider(hellfirepvp.astralsorcery.common.starlight.transmission.registry.TransmissionProvider) NodeConnection(hellfirepvp.astralsorcery.common.starlight.transmission.NodeConnection) CrystalAttributes(hellfirepvp.astralsorcery.common.crystal.CrystalAttributes) PartialEffectExecutor(hellfirepvp.astralsorcery.common.util.PartialEffectExecutor) Vector3d(net.minecraft.util.math.vector.Vector3d) CrystalCalculations(hellfirepvp.astralsorcery.common.crystal.CrystalCalculations) TileEntity(net.minecraft.tileentity.TileEntity) ConstellationEffectProperties(hellfirepvp.astralsorcery.common.constellation.effect.ConstellationEffectProperties) WorldContext(hellfirepvp.astralsorcery.common.constellation.world.WorldContext) ConstellationEffectProperties(hellfirepvp.astralsorcery.common.constellation.effect.ConstellationEffectProperties) ConstellationEffectStatus(hellfirepvp.astralsorcery.common.constellation.effect.ConstellationEffectStatus) PartialEffectExecutor(hellfirepvp.astralsorcery.common.util.PartialEffectExecutor) BlockPos(net.minecraft.util.math.BlockPos)

Aggregations

PartialEffectExecutor (hellfirepvp.astralsorcery.common.util.PartialEffectExecutor)2 RaytraceAssist (hellfirepvp.astralsorcery.common.util.RaytraceAssist)2 Vector3 (hellfirepvp.astralsorcery.common.util.data.Vector3)2 BlockPos (net.minecraft.util.math.BlockPos)2 World (net.minecraft.world.World)2 IConstellation (hellfirepvp.astralsorcery.common.constellation.IConstellation)1 IMinorConstellation (hellfirepvp.astralsorcery.common.constellation.IMinorConstellation)1 IWeakConstellation (hellfirepvp.astralsorcery.common.constellation.IWeakConstellation)1 SkyHandler (hellfirepvp.astralsorcery.common.constellation.SkyHandler)1 ConstellationEffect (hellfirepvp.astralsorcery.common.constellation.effect.ConstellationEffect)1 ConstellationEffectProperties (hellfirepvp.astralsorcery.common.constellation.effect.ConstellationEffectProperties)1 ConstellationEffectRegistry (hellfirepvp.astralsorcery.common.constellation.effect.ConstellationEffectRegistry)1 ConstellationEffectStatus (hellfirepvp.astralsorcery.common.constellation.effect.ConstellationEffectStatus)1 DayTimeHelper (hellfirepvp.astralsorcery.common.constellation.world.DayTimeHelper)1 WorldContext (hellfirepvp.astralsorcery.common.constellation.world.WorldContext)1 CrystalAttributes (hellfirepvp.astralsorcery.common.crystal.CrystalAttributes)1 CrystalCalculations (hellfirepvp.astralsorcery.common.crystal.CrystalCalculations)1 WorldNetworkHandler (hellfirepvp.astralsorcery.common.starlight.WorldNetworkHandler)1 IPrismTransmissionNode (hellfirepvp.astralsorcery.common.starlight.transmission.IPrismTransmissionNode)1 NodeConnection (hellfirepvp.astralsorcery.common.starlight.transmission.NodeConnection)1