2020-07-26 16:14:51 +00:00
|
|
|
package com.thebrokenrail.energonrelics.block;
|
|
|
|
|
|
|
|
import com.thebrokenrail.energonrelics.block.entity.HolographicSkyBlockEntity;
|
2020-07-26 23:05:59 +00:00
|
|
|
import com.thebrokenrail.energonrelics.block.util.energy.EnergyBlock;
|
2020-07-26 16:14:51 +00:00
|
|
|
import com.thebrokenrail.energonrelics.client.block.entity.render.HolographicSkyBlockEntityRenderer;
|
|
|
|
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.BlockRenderType;
|
|
|
|
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.IntProperty;
|
|
|
|
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")
|
2020-07-26 23:05:59 +00:00
|
|
|
public class HolographicSkyBlock extends EnergyBlock {
|
2020-07-26 16:14:51 +00:00
|
|
|
public static final BooleanProperty POWERED = Properties.POWERED;
|
|
|
|
public static final IntProperty LIGHT_LEVEL = IntProperty.of("light_level", 0, 15);
|
|
|
|
|
|
|
|
public HolographicSkyBlock() {
|
|
|
|
super(FabricBlockSettings.copy(Blocks.OBSIDIAN).sounds(BlockSoundGroup.GLASS).nonOpaque().allowsSpawning((state, world, pos, type) -> !state.get(POWERED)).solidBlock((state, world, pos) -> !state.get(POWERED)).suffocates((state, world, pos) -> !state.get(POWERED)).lightLevel(state -> state.get(POWERED) ? 7 : 0).blockVision((state, world, pos) -> !state.get(POWERED)));
|
|
|
|
setDefaultState(getDefaultState().with(POWERED, false).with(LIGHT_LEVEL, 0));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
|
|
|
|
builder.add(POWERED, LIGHT_LEVEL);
|
|
|
|
}
|
|
|
|
|
|
|
|
@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
|
|
|
|
public BlockRenderType getRenderType(BlockState state) {
|
|
|
|
return state.get(POWERED) ? BlockRenderType.ENTITYBLOCK_ANIMATED : BlockRenderType.MODEL;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected Function<BlockEntityType<BlockEntity>, BlockEntity> getFactory() {
|
|
|
|
return HolographicSkyBlockEntity::new;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Environment(EnvType.CLIENT)
|
|
|
|
protected Function<BlockEntityRenderDispatcher, BlockEntityRenderer<BlockEntity>> getRenderer() {
|
|
|
|
return HolographicSkyBlockEntityRenderer::new;
|
|
|
|
}
|
|
|
|
}
|