Search in sources :

Example 1 with BlockPositionGenerator

use of hellfirepvp.astralsorcery.common.util.block.iterator.BlockPositionGenerator in project AstralSorcery by HellFirePvP.

the class CEffectAbstractList method peekNewPosition.

@Nonnull
public Either<T, BlockPos> peekNewPosition(World world, BlockPos pos, ConstellationEffectProperties prop) {
    if (this.excludesRitual || this.excludeRitualColumn) {
        MiscUtils.executeWithChunk(world, pos, () -> {
            this.isLinkedRitual = MiscUtils.getTileAt(world, pos, TileRitualLink.class, true) != null;
        });
    }
    BlockPositionGenerator gen = this.selectPositionStrategy(this.positionStrategy, prop);
    if (gen != this.positionStrategy) {
        gen.copyFilterFrom(this.positionStrategy);
    }
    BlockPos at = gen.generateNextPosition(new Vector3(0.5, 0.5, 0.5), prop.getSize());
    BlockPos actual = at.add(pos);
    if (this.getCount() >= this.maxAmount) {
        return Either.right(actual);
    }
    return MiscUtils.executeWithChunk(world, actual, () -> {
        if (this.verifier.test(world, actual, world.getBlockState(actual))) {
            T element = this.createElement(world, actual);
            if (element == null) {
                return Either.right(actual);
            } else {
                return Either.left(element);
            }
        }
        return Either.right(actual);
    }, Either.right(actual));
}
Also used : CompoundNBT(net.minecraft.nbt.CompoundNBT) INBT(net.minecraft.nbt.INBT) ListNBT(net.minecraft.nbt.ListNBT) BlockPositionGenerator(hellfirepvp.astralsorcery.common.util.block.iterator.BlockPositionGenerator) BlockPos(net.minecraft.util.math.BlockPos) Vector3(hellfirepvp.astralsorcery.common.util.data.Vector3) Nonnull(javax.annotation.Nonnull)

Example 2 with BlockPositionGenerator

use of hellfirepvp.astralsorcery.common.util.block.iterator.BlockPositionGenerator in project AstralSorcery by HellFirePvP.

the class CEffectFornax method createPositionStrategy.

@Nonnull
@Override
protected BlockPositionGenerator createPositionStrategy() {
    BlockPositionGenerator gen = new BlockRandomPositionGenerator();
    gen.andFilter(pos -> pos.getY() < 0);
    return gen;
}
Also used : BlockPositionGenerator(hellfirepvp.astralsorcery.common.util.block.iterator.BlockPositionGenerator) BlockRandomPositionGenerator(hellfirepvp.astralsorcery.common.util.block.iterator.BlockRandomPositionGenerator) Nonnull(javax.annotation.Nonnull)

Aggregations

BlockPositionGenerator (hellfirepvp.astralsorcery.common.util.block.iterator.BlockPositionGenerator)2 Nonnull (javax.annotation.Nonnull)2 BlockRandomPositionGenerator (hellfirepvp.astralsorcery.common.util.block.iterator.BlockRandomPositionGenerator)1 Vector3 (hellfirepvp.astralsorcery.common.util.data.Vector3)1 CompoundNBT (net.minecraft.nbt.CompoundNBT)1 INBT (net.minecraft.nbt.INBT)1 ListNBT (net.minecraft.nbt.ListNBT)1 BlockPos (net.minecraft.util.math.BlockPos)1