147 lines
6.4 KiB
Java
147 lines
6.4 KiB
Java
package com.dairymoose.modernlife.blocks;
|
|
|
|
import java.util.List;
|
|
import java.util.stream.Stream;
|
|
import javax.annotation.Nullable;
|
|
import net.minecraft.core.BlockPos;
|
|
import net.minecraft.core.Direction;
|
|
import net.minecraft.network.chat.Component;
|
|
import net.minecraft.network.chat.TextComponent;
|
|
import net.minecraft.world.item.ItemStack;
|
|
import net.minecraft.world.item.TooltipFlag;
|
|
import net.minecraft.world.item.context.BlockPlaceContext;
|
|
import net.minecraft.world.level.BlockGetter;
|
|
import net.minecraft.world.level.Level;
|
|
import net.minecraft.world.level.block.Block;
|
|
import net.minecraft.world.level.block.FaceAttachedHorizontalDirectionalBlock;
|
|
import net.minecraft.world.level.block.Mirror;
|
|
import net.minecraft.world.level.block.Rotation;
|
|
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.AttachFace;
|
|
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.phys.shapes.BooleanOp;
|
|
import net.minecraft.world.phys.shapes.CollisionContext;
|
|
import net.minecraft.world.phys.shapes.Shapes;
|
|
import net.minecraft.world.phys.shapes.VoxelShape;
|
|
import net.minecraftforge.api.distmarker.Dist;
|
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
|
|
|
/* loaded from: outputsrg.jar:com/dairymoose/modernlife/blocks/TileLightBlock.class */
|
|
public class TileLightBlock extends FaceAttachedHorizontalDirectionalBlock {
|
|
protected static final VoxelShape SHAPE_NORTH = (VoxelShape) Stream.of((Object[]) new VoxelShape[]{Block.box(5.0d, 15.0d, 5.0d, 11.0d, 16.0d, 11.0d), Block.box(5.5d, 14.0d, 5.5d, 10.5d, 15.0d, 10.5d)}).reduce((v1, v2) -> {
|
|
return Shapes.join(v1, v2, BooleanOp.OR);
|
|
}).get();
|
|
public static final BooleanProperty POWERED = BlockStateProperties.POWERED;
|
|
|
|
@OnlyIn(Dist.CLIENT)
|
|
public void appendHoverText(ItemStack itemStack, @Nullable BlockGetter blockReader, List<Component> list, TooltipFlag tooltipFlag) {
|
|
list.add(new TextComponent("Requires redstone power to operate"));
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* renamed from: com.dairymoose.modernlife.blocks.TileLightBlock$1 */
|
|
/* loaded from: outputsrg.jar:com/dairymoose/modernlife/blocks/TileLightBlock$1.class */
|
|
public class C00611 implements StatePredicate {
|
|
C00611() {
|
|
}
|
|
|
|
public boolean test(BlockState state, BlockGetter reader, BlockPos pos) {
|
|
if (((Boolean) state.getValue(TileLightBlock.POWERED)).booleanValue()) {
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public TileLightBlock(Properties props) {
|
|
super(props.lightLevel(LightBulbBlock::getLightLevel).emissiveRendering(new StatePredicate() { // from class: com.dairymoose.modernlife.blocks.TileLightBlock.1
|
|
C00611() {
|
|
}
|
|
|
|
public boolean test(BlockState state, BlockGetter reader, BlockPos pos) {
|
|
if (((Boolean) state.getValue(TileLightBlock.POWERED)).booleanValue()) {
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
}));
|
|
registerDefaultState((BlockState) ((BlockState) ((BlockState) this.stateDefinition.any().setValue(FaceAttachedHorizontalDirectionalBlock.FACE, AttachFace.CEILING)).setValue(HorizontalDirectionalBlock.FACING, Direction.NORTH)).setValue(POWERED, false));
|
|
}
|
|
|
|
public BlockState rotate(BlockState state, Rotation rotation) {
|
|
return state;
|
|
}
|
|
|
|
public BlockState mirror(BlockState state, Mirror mirror) {
|
|
return state;
|
|
}
|
|
|
|
public static int getLightLevel(BlockState state) {
|
|
if (((Boolean) state.getValue(POWERED)).booleanValue()) {
|
|
return 15;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
public BlockState getStateForPlacement(BlockPlaceContext context) {
|
|
BlockPos pos = context.getClickedPos();
|
|
boolean signal = context.getLevel().hasNeighborSignal(pos);
|
|
return (BlockState) defaultBlockState().setValue(POWERED, Boolean.valueOf(signal));
|
|
}
|
|
|
|
public void neighborChanged(BlockState state, Level world, BlockPos pos, Block block, BlockPos neighborPos, boolean p_220069_6_) {
|
|
boolean signal = world.hasNeighborSignal(pos);
|
|
if (block != this && signal != ((Boolean) state.getValue(POWERED)).booleanValue()) {
|
|
world.setBlock(pos, (BlockState) state.setValue(POWERED, Boolean.valueOf(signal)), 2);
|
|
}
|
|
}
|
|
|
|
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
|
|
builder.add(new Property[]{FaceAttachedHorizontalDirectionalBlock.FACE, HorizontalDirectionalBlock.FACING, POWERED});
|
|
}
|
|
|
|
/* renamed from: com.dairymoose.modernlife.blocks.TileLightBlock$2 */
|
|
/* loaded from: outputsrg.jar:com/dairymoose/modernlife/blocks/TileLightBlock$2.class */
|
|
static /* synthetic */ class C00622 {
|
|
static final /* synthetic */ int[] $SwitchMap$net$minecraft$core$Direction = new int[Direction.values().length];
|
|
|
|
static {
|
|
try {
|
|
$SwitchMap$net$minecraft$core$Direction[Direction.NORTH.ordinal()] = 1;
|
|
} catch (NoSuchFieldError e) {
|
|
}
|
|
try {
|
|
$SwitchMap$net$minecraft$core$Direction[Direction.SOUTH.ordinal()] = 2;
|
|
} catch (NoSuchFieldError e2) {
|
|
}
|
|
try {
|
|
$SwitchMap$net$minecraft$core$Direction[Direction.EAST.ordinal()] = 3;
|
|
} catch (NoSuchFieldError e3) {
|
|
}
|
|
try {
|
|
$SwitchMap$net$minecraft$core$Direction[Direction.WEST.ordinal()] = 4;
|
|
} catch (NoSuchFieldError e4) {
|
|
}
|
|
}
|
|
}
|
|
|
|
public VoxelShape getShape(BlockState bs, BlockGetter reader, BlockPos pos, CollisionContext sel) {
|
|
switch (C00622.$SwitchMap$net$minecraft$core$Direction[bs.getValue(HorizontalDirectionalBlock.FACING).ordinal()]) {
|
|
case 1:
|
|
return SHAPE_NORTH;
|
|
case 2:
|
|
return SHAPE_NORTH;
|
|
case 3:
|
|
return SHAPE_NORTH;
|
|
case 4:
|
|
return SHAPE_NORTH;
|
|
default:
|
|
return SHAPE_NORTH;
|
|
}
|
|
}
|
|
}
|