2020-07-15 22:44:49 +00:00
|
|
|
package com.thebrokenrail.energonrelics.block;
|
|
|
|
|
|
|
|
import com.thebrokenrail.energonrelics.block.entity.DefensiveLaserBlockEntity;
|
2020-08-04 17:06:11 +00:00
|
|
|
import com.thebrokenrail.energonrelics.api.block.energy.EnergyBlock;
|
2020-07-17 03:55:31 +00:00
|
|
|
import com.thebrokenrail.energonrelics.client.block.entity.render.DefensiveLaserBlockEntityRenderer;
|
2020-07-15 22:44:49 +00:00
|
|
|
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;
|
2020-07-22 20:40:19 +00:00
|
|
|
import net.minecraft.block.Blocks;
|
2020-07-26 00:23:40 +00:00
|
|
|
import net.minecraft.block.ShapeContext;
|
2020-07-15 22:44:49 +00:00
|
|
|
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;
|
2020-07-22 20:01:10 +00:00
|
|
|
import net.minecraft.sound.BlockSoundGroup;
|
2020-07-15 22:44:49 +00:00
|
|
|
import net.minecraft.state.StateManager;
|
|
|
|
import net.minecraft.state.property.BooleanProperty;
|
|
|
|
import net.minecraft.state.property.Properties;
|
2020-07-16 18:50:18 +00:00
|
|
|
import net.minecraft.util.math.BlockPos;
|
2020-07-26 00:23:40 +00:00
|
|
|
import net.minecraft.util.shape.VoxelShape;
|
|
|
|
import net.minecraft.util.shape.VoxelShapes;
|
2020-07-16 18:50:18 +00:00
|
|
|
import net.minecraft.world.BlockView;
|
2020-07-15 22:44:49 +00:00
|
|
|
|
|
|
|
import java.util.function.Function;
|
|
|
|
|
2020-07-26 00:23:40 +00:00
|
|
|
@SuppressWarnings("deprecation")
|
2020-07-26 23:05:59 +00:00
|
|
|
public class DefensiveLaserBlock extends EnergyBlock {
|
2020-07-15 22:44:49 +00:00
|
|
|
public static final BooleanProperty POWERED = Properties.POWERED;
|
|
|
|
|
|
|
|
public DefensiveLaserBlock() {
|
2020-07-26 00:23:40 +00:00
|
|
|
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));
|
2020-07-16 18:50:18 +00:00
|
|
|
setDefaultState(getDefaultState().with(POWERED, false));
|
2020-07-15 22:44:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
|
|
|
|
builder.add(POWERED);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2020-07-16 18:50:18 +00:00
|
|
|
@Environment(EnvType.CLIENT)
|
|
|
|
public float getAmbientOcclusionLightLevel(BlockState state, BlockView world, BlockPos pos) {
|
2020-07-22 22:57:51 +00:00
|
|
|
return 1f;
|
2020-07-15 22:44:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2020-07-16 18:50:18 +00:00
|
|
|
public boolean isTranslucent(BlockState state, BlockView world, BlockPos pos) {
|
|
|
|
return true;
|
2020-07-15 22:44:49 +00:00
|
|
|
}
|
|
|
|
|
2020-07-26 00:23:40 +00:00
|
|
|
@Override
|
|
|
|
public VoxelShape getVisualShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
|
|
|
|
return VoxelShapes.empty();
|
|
|
|
}
|
|
|
|
|
2020-07-15 22:44:49 +00:00
|
|
|
@Override
|
|
|
|
protected Function<BlockEntityType<BlockEntity>, BlockEntity> getFactory() {
|
|
|
|
return DefensiveLaserBlockEntity::new;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Environment(EnvType.CLIENT)
|
|
|
|
protected Function<BlockEntityRenderDispatcher, BlockEntityRenderer<BlockEntity>> getRenderer() {
|
|
|
|
return DefensiveLaserBlockEntityRenderer::new;
|
|
|
|
}
|
|
|
|
}
|