Search in sources :

Example 6 with TimePhase

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

the class AbstractPhasingStairsBlock 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)

Example 7 with TimePhase

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

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

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

the class AbstractPhasingLeavesBlock method randomTick.

@Override
public void randomTick(BlockState state, ServerLevel worldIn, BlockPos pos, Random random) {
    // Remove the leaves if too far from a log
    if (!state.getValue(PERSISTENT) && state.getValue(DISTANCE) == 7) {
        dropResources(state, worldIn, pos);
        worldIn.removeBlock(pos, false);
    }
    // Periodically check to see if the block's phase needs to be updated
    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 9 with TimePhase

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

the class AbstractPhasingLogBlock 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 10 with TimePhase

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

the class AbstractPhasingPillarBlock 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