package com.thebrokenrail.energonrelics.block; import com.thebrokenrail.energonrelics.block.entity.DefensiveLaserBlockEntity; import com.thebrokenrail.energonrelics.block.util.energy.EnergyProviderBlock; 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.Material; import net.minecraft.block.MaterialColor; 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.state.StateManager; import net.minecraft.state.property.BooleanProperty; import net.minecraft.state.property.Properties; import net.minecraft.util.math.BlockPos; import net.minecraft.world.BlockView; import java.util.function.Function; public class DefensiveLaserBlock extends EnergyProviderBlock { public static final BooleanProperty POWERED = Properties.POWERED; public DefensiveLaserBlock() { super(FabricBlockSettings.of(Material.GLASS, MaterialColor.BLACK).requiresTool().strength(50.0F, 1200.0F).nonOpaque().allowsSpawning((state, world, pos, type) -> false).solidBlock((state, world, pos) -> false).suffocates((state, world, pos) -> false).lightLevel(state -> state.get(POWERED) ? 7 : 0)); setDefaultState(getDefaultState().with(POWERED, false)); } @Override protected void appendProperties(StateManager.Builder builder) { builder.add(POWERED); } @Override @SuppressWarnings("deprecation") @Environment(EnvType.CLIENT) public float getAmbientOcclusionLightLevel(BlockState state, BlockView world, BlockPos pos) { return 1.0F; } @Override public boolean isTranslucent(BlockState state, BlockView world, BlockPos pos) { return true; } @Override protected Function, BlockEntity> getFactory() { return DefensiveLaserBlockEntity::new; } @Override @Environment(EnvType.CLIENT) protected Function> getRenderer() { return DefensiveLaserBlockEntityRenderer::new; } }