package org.betterx.betterend.blocks; import org.betterx.bclib.blocks.BaseBlockNotFull; import org.betterx.bclib.blocks.BlockProperties; import org.betterx.bclib.blocks.BlockProperties.TripleShape; import org.betterx.bclib.client.render.BCLRenderLayer; import org.betterx.bclib.interfaces.RenderLayerProvider; import org.betterx.bclib.util.BlocksHelper; import org.betterx.betterend.registry.EndBlocks; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.LevelReader; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Mirror; import net.minecraft.world.level.block.Rotation; 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.BlockStateProperties; import net.minecraft.world.level.block.state.properties.EnumProperty; import net.minecraft.world.level.material.Material; import net.minecraft.world.level.material.WaterFluid; import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.VoxelShape; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; public class EndLotusLeafBlock extends BaseBlockNotFull implements RenderLayerProvider { public static final EnumProperty HORIZONTAL_FACING = BlockStateProperties.HORIZONTAL_FACING; public static final EnumProperty SHAPE = BlockProperties.TRIPLE_SHAPE; private static final VoxelShape VSHAPE = Block.box(0, 0, 0, 16, 1, 16); public EndLotusLeafBlock() { super(FabricBlockSettings.of(Material.PLANT).noOcclusion().sound(SoundType.WET_GRASS)); } @Override @SuppressWarnings("deprecation") public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) { BlockState down = world.getBlockState(pos.below()); return !down.getFluidState().isEmpty() && down.getFluidState().getType() instanceof WaterFluid; } @Override protected void createBlockStateDefinition(StateDefinition.Builder builder) { builder.add(SHAPE, HORIZONTAL_FACING); } @Override @SuppressWarnings("deprecation") public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) { return VSHAPE; } @Override @SuppressWarnings("deprecation") public BlockState rotate(BlockState state, Rotation rotation) { return BlocksHelper.rotateHorizontal(state, rotation, HORIZONTAL_FACING); } @Override @SuppressWarnings("deprecation") public BlockState mirror(BlockState state, Mirror mirror) { return BlocksHelper.mirrorHorizontal(state, mirror, HORIZONTAL_FACING); } @Override public BCLRenderLayer getRenderLayer() { return BCLRenderLayer.CUTOUT; } @Override @Environment(EnvType.CLIENT) public ItemStack getCloneItemStack(BlockGetter world, BlockPos pos, BlockState state) { return new ItemStack(EndBlocks.END_LOTUS_SEED); } }