package org.betterx.betterend.blocks; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.level.LevelReader; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.world.level.block.state.properties.BooleanProperty; import net.minecraft.world.level.material.Material; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import org.betterx.bclib.blocks.BaseBlock; import org.betterx.bclib.blocks.BlockProperties; import org.betterx.bclib.interfaces.tools.AddMineableAxe; import org.betterx.betterend.registry.EndBlocks; public class BlueVineLanternBlock extends BaseBlock implements AddMineableAxe { public static final BooleanProperty NATURAL = BlockProperties.NATURAL; public BlueVineLanternBlock() { super(FabricBlockSettings.of(Material.WOOD) .luminance(15) .sound(SoundType.WART_BLOCK)); this.registerDefaultState(this.stateDefinition.any().setValue(NATURAL, false)); } @Override @SuppressWarnings("deprecation") public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) { return !state.getValue(NATURAL) || world.getBlockState(pos.below()).getBlock() == EndBlocks.BLUE_VINE; } @Override @SuppressWarnings("deprecation") public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) { if (!canSurvive(state, world, pos)) { return Blocks.AIR.defaultBlockState(); } else { return state; } } @Override protected void createBlockStateDefinition(StateDefinition.Builder stateManager) { stateManager.add(NATURAL); } }