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