105 lines
4.3 KiB
Java
105 lines
4.3 KiB
Java
package com.dairymoose.modernlife.blocks;
|
|
|
|
import com.dairymoose.modernlife.core.ModernLifeCommon;
|
|
import com.dairymoose.modernlife.core.ModernLifeConfig;
|
|
import com.dairymoose.modernlife.tileentities.PhotonBlockEntity;
|
|
import com.dairymoose.modernlife.util.ModernLifeUtil;
|
|
import net.minecraft.core.BlockPos;
|
|
import net.minecraft.world.item.context.BlockPlaceContext;
|
|
import net.minecraft.world.level.BlockGetter;
|
|
import net.minecraft.world.level.Level;
|
|
import net.minecraft.world.level.LevelAccessor;
|
|
import net.minecraft.world.level.block.Block;
|
|
import net.minecraft.world.level.block.EntityBlock;
|
|
import net.minecraft.world.level.block.LiquidBlockContainer;
|
|
import net.minecraft.world.level.block.RenderShape;
|
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
|
import net.minecraft.world.level.block.entity.BlockEntityTicker;
|
|
import net.minecraft.world.level.block.entity.BlockEntityType;
|
|
import net.minecraft.world.level.block.state.BlockBehaviour;
|
|
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.BooleanProperty;
|
|
import net.minecraft.world.level.block.state.properties.Property;
|
|
import net.minecraft.world.level.material.Fluid;
|
|
import net.minecraft.world.level.material.FluidState;
|
|
import net.minecraft.world.level.material.Fluids;
|
|
import net.minecraft.world.phys.shapes.CollisionContext;
|
|
import net.minecraft.world.phys.shapes.Shapes;
|
|
import net.minecraft.world.phys.shapes.VoxelShape;
|
|
|
|
/* loaded from: outputsrg.jar:com/dairymoose/modernlife/blocks/PhotonBlock.class */
|
|
public class PhotonBlock extends Block implements EntityBlock, LiquidBlockContainer {
|
|
public static final BooleanProperty EXTINGUISHED = BooleanProperty.create("extinguished");
|
|
public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
|
|
|
|
public PhotonBlock(Properties props) {
|
|
super(props.lightLevel(PhotonBlock::getLightLevel).noCollission().air());
|
|
registerDefaultState((BlockState) ((BlockState) this.stateDefinition.any().setValue(EXTINGUISHED, false)).setValue(WATERLOGGED, false));
|
|
}
|
|
|
|
public FluidState getFluidState(BlockState state) {
|
|
if (((Boolean) state.getValue(WATERLOGGED)).booleanValue()) {
|
|
return Fluids.WATER.getSource(false);
|
|
}
|
|
return super.getFluidState(state);
|
|
}
|
|
|
|
public boolean canPlaceLiquid(BlockGetter p_56301_, BlockPos p_56302_, BlockState p_56303_, Fluid p_56304_) {
|
|
return false;
|
|
}
|
|
|
|
public boolean placeLiquid(LevelAccessor p_56306_, BlockPos p_56307_, BlockState p_56308_, FluidState p_56309_) {
|
|
return false;
|
|
}
|
|
|
|
protected boolean isAir(BlockState state) {
|
|
if (((Boolean) state.getValue(WATERLOGGED)).booleanValue()) {
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public boolean canBeReplaced(BlockState p_60470_, BlockPlaceContext p_60471_) {
|
|
return true;
|
|
}
|
|
|
|
public boolean canBeReplaced(BlockState p_60535_, Fluid p_60536_) {
|
|
return true;
|
|
}
|
|
|
|
public static int getLightLevel(BlockState state) {
|
|
if (((Boolean) state.getValue(EXTINGUISHED)).booleanValue()) {
|
|
return 0;
|
|
}
|
|
int lightLevel = 13;
|
|
Integer configLight = ModernLifeConfig.COMMON.flashlightLightLevel.getValue();
|
|
if (configLight != null) {
|
|
lightLevel = configLight.intValue();
|
|
}
|
|
ModernLifeCommon.LOGGER.debug("flashlight light level = " + lightLevel);
|
|
return lightLevel;
|
|
}
|
|
|
|
public RenderShape getRenderShape(BlockState p_149645_1_) {
|
|
return RenderShape.INVISIBLE;
|
|
}
|
|
|
|
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
|
|
builder.add(new Property[]{EXTINGUISHED, WATERLOGGED});
|
|
}
|
|
|
|
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, BlockState state, BlockEntityType<T> type) {
|
|
return ModernLifeUtil.createTickerHelper(type, PhotonBlockEntity.PHOTON, PhotonBlockEntity::tick);
|
|
}
|
|
|
|
public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
|
|
return PhotonBlockEntity.PHOTON.create(pos, state);
|
|
}
|
|
|
|
public VoxelShape getShape(BlockState bs, BlockGetter reader, BlockPos pos, CollisionContext sel) {
|
|
return Shapes.empty();
|
|
}
|
|
}
|