184 lines
8.6 KiB
Java
184 lines
8.6 KiB
Java
package com.dairymoose.modernlife.blocks;
|
|
|
|
import com.dairymoose.modernlife.util.ModernLifeUtil;
|
|
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/LightBulbBlock.class */
|
|
public class LightBulbBlock extends FaceAttachedHorizontalDirectionalBlock {
|
|
public static final BooleanProperty POWERED = BlockStateProperties.POWERED;
|
|
protected static final VoxelShape SHAPE_CEILING = (VoxelShape) Stream.of((Object[]) new VoxelShape[]{Block.box(6.75d, 11.924999999999995d, 6.725d, 9.25d, 13.149999999999995d, 9.25d), Block.box(7.162500000000001d, 10.950000000000001d, 7.137500000000001d, 8.8375d, 11.925d, 8.837499999999999d), Block.box(6.987500000000001d, 12.950000000000001d, 6.987500000000001d, 9.012500000000001d, 13.950000000000001d, 8.987499999999999d), Block.box(7.162500000000001d, 13.950000000000001d, 7.137500000000001d, 8.8375d, 14.400000000000002d, 8.812499999999998d), Block.box(7.4d, 14.4d, 7.35d, 8.675d, 16.0d, 8.6d)}).reduce((v1, v2) -> {
|
|
return Shapes.join((VoxelShape) v1, (VoxelShape) v2, BooleanOp.OR);
|
|
}).get();
|
|
protected final VoxelShape SHAPE_WALL_NORTH;
|
|
protected final VoxelShape SHAPE_WALL_EAST;
|
|
protected final VoxelShape SHAPE_WALL_SOUTH;
|
|
protected final VoxelShape SHAPE_WALL_WEST;
|
|
protected final VoxelShape SHAPE_FLOOR;
|
|
|
|
public BlockState rotate(BlockState state, Rotation rotation) {
|
|
return state;
|
|
}
|
|
|
|
public BlockState mirror(BlockState state, Mirror mirror) {
|
|
return state;
|
|
}
|
|
|
|
@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.LightBulbBlock$1 */
|
|
/* loaded from: outputsrg.jar:com/dairymoose/modernlife/blocks/LightBulbBlock$1.class */
|
|
public class C00321 implements StatePredicate {
|
|
C00321() {
|
|
}
|
|
|
|
public boolean test(BlockState state, BlockGetter reader, BlockPos pos) {
|
|
if (((Boolean) state.getValue(LightBulbBlock.POWERED)).booleanValue()) {
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public LightBulbBlock(Properties props) {
|
|
super(props.lightLevel(LightBulbBlock::getLightLevel).emissiveRendering(new StatePredicate() { // from class: com.dairymoose.modernlife.blocks.LightBulbBlock.1
|
|
|
|
public boolean test(BlockState state, BlockGetter reader, BlockPos pos) {
|
|
if (((Boolean) state.getValue(LightBulbBlock.POWERED)).booleanValue()) {
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
}));
|
|
this.SHAPE_WALL_NORTH = ModernLifeUtil.RotateVoxelShapeXAxis(SHAPE_CEILING);
|
|
this.SHAPE_WALL_EAST = ModernLifeUtil.RotateVoxelShapeClockwise(this.SHAPE_WALL_NORTH);
|
|
this.SHAPE_WALL_SOUTH = ModernLifeUtil.RotateVoxelShapeClockwise(this.SHAPE_WALL_EAST);
|
|
this.SHAPE_WALL_WEST = ModernLifeUtil.RotateVoxelShapeClockwise(this.SHAPE_WALL_SOUTH);
|
|
this.SHAPE_FLOOR = ModernLifeUtil.RotateVoxelShapeXAxis(this.SHAPE_WALL_NORTH);
|
|
registerDefaultState((BlockState) ((BlockState) ((BlockState) this.stateDefinition.any().setValue(FaceAttachedHorizontalDirectionalBlock.FACE, AttachFace.CEILING)).setValue(HorizontalDirectionalBlock.FACING, Direction.NORTH)).setValue(POWERED, false));
|
|
}
|
|
|
|
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);
|
|
BlockState superState = super.getStateForPlacement(context);
|
|
if (superState == null) {
|
|
superState = defaultBlockState();
|
|
}
|
|
return (BlockState) superState.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.LightBulbBlock$2 */
|
|
/* loaded from: outputsrg.jar:com/dairymoose/modernlife/blocks/LightBulbBlock$2.class */
|
|
static /* synthetic */ class C00332 {
|
|
static final /* synthetic */ int[] $SwitchMap$net$minecraft$core$Direction;
|
|
|
|
/* renamed from: $SwitchMap$net$minecraft$world$level$block$state$properties$AttachFace */
|
|
static final /* synthetic */ int[] f4x6a19ab39 = new int[AttachFace.values().length];
|
|
|
|
static {
|
|
try {
|
|
f4x6a19ab39[AttachFace.CEILING.ordinal()] = 1;
|
|
} catch (NoSuchFieldError e) {
|
|
}
|
|
try {
|
|
f4x6a19ab39[AttachFace.WALL.ordinal()] = 2;
|
|
} catch (NoSuchFieldError e2) {
|
|
}
|
|
try {
|
|
f4x6a19ab39[AttachFace.FLOOR.ordinal()] = 3;
|
|
} catch (NoSuchFieldError e3) {
|
|
}
|
|
$SwitchMap$net$minecraft$core$Direction = new int[Direction.values().length];
|
|
try {
|
|
$SwitchMap$net$minecraft$core$Direction[Direction.NORTH.ordinal()] = 1;
|
|
} catch (NoSuchFieldError e4) {
|
|
}
|
|
try {
|
|
$SwitchMap$net$minecraft$core$Direction[Direction.EAST.ordinal()] = 2;
|
|
} catch (NoSuchFieldError e5) {
|
|
}
|
|
try {
|
|
$SwitchMap$net$minecraft$core$Direction[Direction.WEST.ordinal()] = 3;
|
|
} catch (NoSuchFieldError e6) {
|
|
}
|
|
try {
|
|
$SwitchMap$net$minecraft$core$Direction[Direction.SOUTH.ordinal()] = 4;
|
|
} catch (NoSuchFieldError e7) {
|
|
}
|
|
}
|
|
}
|
|
|
|
public VoxelShape getShape(BlockState bs, BlockGetter reader, BlockPos pos, CollisionContext sel) {
|
|
switch (C00332.f4x6a19ab39[bs.getValue(FaceAttachedHorizontalDirectionalBlock.FACE).ordinal()]) {
|
|
case 1:
|
|
return SHAPE_CEILING;
|
|
case 2:
|
|
switch (C00332.$SwitchMap$net$minecraft$core$Direction[bs.getValue(HorizontalDirectionalBlock.FACING).ordinal()]) {
|
|
case 1:
|
|
return this.SHAPE_WALL_NORTH;
|
|
case 2:
|
|
return this.SHAPE_WALL_EAST;
|
|
case 3:
|
|
return this.SHAPE_WALL_WEST;
|
|
case 4:
|
|
return this.SHAPE_WALL_SOUTH;
|
|
}
|
|
case 3:
|
|
break;
|
|
default:
|
|
return SHAPE_CEILING;
|
|
}
|
|
return this.SHAPE_FLOOR;
|
|
}
|
|
}
|