Search in sources :

Example 1 with TimePhase

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

the class AbstractPhasingBlock 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 2 with TimePhase

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

the class AbstractPhasingLeavesBlock method updateShape.

@Override
public BlockState updateShape(BlockState stateIn, Direction facing, BlockState facingState, LevelAccessor worldIn, BlockPos currentPos, BlockPos facingPos) {
    // Determine if the blockstate needs to be updated with a new distance
    int i = getDistance(facingState) + 1;
    if (i != 1 || stateIn.getValue(DISTANCE) != i) {
        worldIn.scheduleTick(currentPos, this, 1);
    }
    // Immediately check to see if the block's phase needs to be updated when one of its neighbors changes
    TimePhase newPhase = this.getCurrentPhase(worldIn);
    if (newPhase != stateIn.getValue(PHASE)) {
        stateIn = stateIn.setValue(PHASE, newPhase);
    }
    return stateIn;
}
Also used : TimePhase(com.verdantartifice.primalmagick.common.blockstates.properties.TimePhase)

Example 3 with TimePhase

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

the class AbstractPhasingLogBlock method updateShape.

@SuppressWarnings("deprecation")
@Override
public BlockState updateShape(BlockState stateIn, Direction facing, BlockState facingState, LevelAccessor worldIn, BlockPos currentPos, BlockPos facingPos) {
    // Immediately check to see if the block's phase needs to be updated when one of its neighbors changes
    BlockState state = super.updateShape(stateIn, facing, facingState, worldIn, currentPos, facingPos);
    TimePhase newPhase = this.getCurrentPhase(worldIn);
    if (newPhase != state.getValue(PHASE)) {
        state = state.setValue(PHASE, newPhase);
    }
    return state;
}
Also used : BlockState(net.minecraft.world.level.block.state.BlockState) TimePhase(com.verdantartifice.primalmagick.common.blockstates.properties.TimePhase)

Example 4 with TimePhase

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

the class AbstractPhasingPillarBlock 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 5 with TimePhase

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

the class AbstractPhasingSlabBlock method updateShape.

@Override
public BlockState updateShape(BlockState stateIn, Direction facing, BlockState facingState, LevelAccessor worldIn, BlockPos currentPos, BlockPos facingPos) {
    // Immediately check to see if the block's phase needs to be updated when one of its neighbors changes
    BlockState state = super.updateShape(stateIn, facing, facingState, worldIn, currentPos, facingPos);
    TimePhase newPhase = this.getCurrentPhase(worldIn);
    if (newPhase != state.getValue(PHASE)) {
        state = state.setValue(PHASE, newPhase);
    }
    return state;
}
Also used : BlockState(net.minecraft.world.level.block.state.BlockState) TimePhase(com.verdantartifice.primalmagick.common.blockstates.properties.TimePhase)

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