Search in sources :

Example 11 with TimePhase

use of com.verdantartifice.primalmagick.common.blockstates.properties.TimePhase in project PrimalMagick by daedalus4096.

the class AbstractPhasingSlabBlock method randomTick.

@SuppressWarnings("deprecation")
@Override
public void randomTick(BlockState state, ServerLevel worldIn, BlockPos pos, Random random) {
    // Periodically check to see if the block's phase needs to be updated
    super.randomTick(state, worldIn, pos, random);
    TimePhase newPhase = this.getCurrentPhase(worldIn);
    if (newPhase != state.getValue(PHASE)) {
        worldIn.setBlock(pos, state.setValue(PHASE, newPhase), Block.UPDATE_ALL);
    }
}
Also used : TimePhase(com.verdantartifice.primalmagick.common.blockstates.properties.TimePhase)

Example 12 with TimePhase

use of com.verdantartifice.primalmagick.common.blockstates.properties.TimePhase in project PrimalMagick by daedalus4096.

the class AbstractPhasingStairsBlock method randomTick.

@Override
public void randomTick(BlockState state, ServerLevel worldIn, BlockPos pos, Random random) {
    // Periodically check to see if the block's phase needs to be updated
    super.randomTick(state, worldIn, pos, random);
    TimePhase newPhase = this.getCurrentPhase(worldIn);
    if (newPhase != state.getValue(PHASE)) {
        worldIn.setBlock(pos, state.setValue(PHASE, newPhase), Block.UPDATE_ALL);
    }
}
Also used : TimePhase(com.verdantartifice.primalmagick.common.blockstates.properties.TimePhase)

Example 13 with TimePhase

use of com.verdantartifice.primalmagick.common.blockstates.properties.TimePhase in project PrimalMagick by daedalus4096.

the class AbstractPhasingTree method growTree.

@Override
public boolean growTree(ServerLevel world, ChunkGenerator chunkGenerator, BlockPos pos, BlockState state, Random rand) {
    Map<TimePhase, Holder<ConfiguredFeature<TreeConfiguration, ?>>> featureMap = this.getTreeFeaturesByPhase(rand, false);
    TimePhase currentPhase = this.getCurrentPhase(world);
    ConfiguredFeature<TreeConfiguration, ?> configuredFeature = featureMap.get(currentPhase).value();
    if (configuredFeature == null) {
        return false;
    } else {
        world.setBlock(pos, Blocks.AIR.defaultBlockState(), Block.UPDATE_INVISIBLE);
        if (configuredFeature.place(world, chunkGenerator, rand, pos)) {
            return true;
        } else {
            world.setBlock(pos, state, Block.UPDATE_INVISIBLE);
            return false;
        }
    }
}
Also used : TimePhase(com.verdantartifice.primalmagick.common.blockstates.properties.TimePhase) Holder(net.minecraft.core.Holder) TreeConfiguration(net.minecraft.world.level.levelgen.feature.configurations.TreeConfiguration)

Aggregations

TimePhase (com.verdantartifice.primalmagick.common.blockstates.properties.TimePhase)13 BlockState (net.minecraft.world.level.block.state.BlockState)5 Holder (net.minecraft.core.Holder)1 TreeConfiguration (net.minecraft.world.level.levelgen.feature.configurations.TreeConfiguration)1