package com.thebrokenrail.energonrelics.block; import com.thebrokenrail.energonrelics.block.entity.DefensiveLaserBlockEntity; import com.thebrokenrail.energonrelics.api.block.energy.EnergyBlock; import com.thebrokenrail.energonrelics.client.block.entity.render.DefensiveLaserBlockEntityRenderer; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.block.ShapeContext; import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.BlockEntityType; import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher; import net.minecraft.client.render.block.entity.BlockEntityRenderer; import net.minecraft.sound.BlockSoundGroup; import net.minecraft.state.StateManager; import net.minecraft.state.property.BooleanProperty; import net.minecraft.state.property.Properties; import net.minecraft.util.math.BlockPos; import net.minecraft.util.shape.VoxelShape; import net.minecraft.util.shape.VoxelShapes; import net.minecraft.world.BlockView; import java.util.function.Function; @SuppressWarnings("deprecation") public class DefensiveLaserBlock extends EnergyBlock { public static final BooleanProperty POWERED = Properties.POWERED; public DefensiveLaserBlock() { super(FabricBlockSettings.copy(Blocks.OBSIDIAN).sounds(BlockSoundGroup.GLASS).nonOpaque().allowsSpawning((state, world, pos, type) -> false).solidBlock((state, world, pos) -> false).suffocates((state, world, pos) -> false).lightLevel(state -> state.get(POWERED) ? 7 : 0).blockVision((state, world, pos) -> false)); setDefaultState(getDefaultState().with(POWERED, false)); } @Override protected void appendProperties(StateManager.Builder builder) { builder.add(POWERED); } @Override @Environment(EnvType.CLIENT) public float getAmbientOcclusionLightLevel(BlockState state, BlockView world, BlockPos pos) { return 1f; } @Override public boolean isTranslucent(BlockState state, BlockView world, BlockPos pos) { return true; } @Override public VoxelShape getVisualShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) { return VoxelShapes.empty(); } @Override protected Function, BlockEntity> getFactory() { return DefensiveLaserBlockEntity::new; } @Override @Environment(EnvType.CLIENT) protected Function> getRenderer() { return DefensiveLaserBlockEntityRenderer::new; } }