144 lines
5.4 KiB
Java
144 lines
5.4 KiB
Java
package com.dairymoose.modernlife.blocks;
|
|
|
|
import java.util.stream.Stream;
|
|
import javax.annotation.Nullable;
|
|
import net.minecraft.core.BlockPos;
|
|
import net.minecraft.core.Direction;
|
|
import net.minecraft.util.StringRepresentable;
|
|
import net.minecraft.world.item.context.BlockPlaceContext;
|
|
import net.minecraft.world.level.BlockGetter;
|
|
import net.minecraft.world.level.LevelAccessor;
|
|
import net.minecraft.world.level.block.Block;
|
|
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.EnumProperty;
|
|
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;
|
|
|
|
/* loaded from: outputsrg.jar:com/dairymoose/modernlife/blocks/SmallTableBlock.class */
|
|
public class SmallTableBlock extends Block {
|
|
protected static final VoxelShape SHAPE_NORMAL = (VoxelShape) Stream.of(Block.box(0.01d, 0.0d, 0.01d, 15.99d, 16.0d, 15.99d)).reduce((v1, v2) -> {
|
|
return Shapes.join(v1, v2, BooleanOp.OR);
|
|
}).get();
|
|
public static final EnumProperty<TableType> TYPE = EnumProperty.create("type", TableType.class);
|
|
|
|
/* loaded from: outputsrg.jar:com/dairymoose/modernlife/blocks/SmallTableBlock$TableType.class */
|
|
public enum TableType implements StringRepresentable {
|
|
single,
|
|
mid,
|
|
s_end,
|
|
w_end,
|
|
n_end,
|
|
e_end,
|
|
ne_corner,
|
|
se_corner,
|
|
nw_corner,
|
|
sw_corner;
|
|
|
|
public String getSerializedName() {
|
|
return name().toLowerCase();
|
|
}
|
|
}
|
|
|
|
public SmallTableBlock(Properties p_i48377_1_) {
|
|
super(p_i48377_1_);
|
|
registerDefaultState((BlockState) defaultBlockState().setValue(TYPE, TableType.single));
|
|
}
|
|
|
|
public SmallTableBlock(Properties p_i48377_1_, boolean skipDefaultState) {
|
|
super(p_i48377_1_);
|
|
if (!skipDefaultState) {
|
|
registerDefaultState((BlockState) defaultBlockState().setValue(TYPE, TableType.single));
|
|
}
|
|
}
|
|
|
|
public int getFlammability(BlockState state, BlockGetter world, BlockPos pos, Direction face) {
|
|
if (this.material.isFlammable()) {
|
|
return 20;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
public int getFireSpreadSpeed(BlockState state, BlockGetter world, BlockPos pos, Direction face) {
|
|
if (this.material.isFlammable()) {
|
|
return 5;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
public BlockState updateShape(BlockState state, Direction dir, BlockState updater, LevelAccessor world, BlockPos pos, BlockPos updaterPos) {
|
|
return getNewState(world, pos);
|
|
}
|
|
|
|
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
|
|
builder.add(new Property[]{TYPE});
|
|
}
|
|
|
|
protected BlockState getNewState(LevelAccessor world, BlockPos pos) {
|
|
BlockState nState = world.getBlockState(pos.north());
|
|
BlockState eState = world.getBlockState(pos.east());
|
|
BlockState sState = world.getBlockState(pos.south());
|
|
BlockState wState = world.getBlockState(pos.west());
|
|
int adjacentTableCount = 0;
|
|
boolean nTable = nState.is(this);
|
|
boolean eTable = eState.is(this);
|
|
boolean sTable = sState.is(this);
|
|
boolean wTable = wState.is(this);
|
|
if (nTable) {
|
|
adjacentTableCount = 0 + 1;
|
|
}
|
|
if (eTable) {
|
|
adjacentTableCount++;
|
|
}
|
|
if (sTable) {
|
|
adjacentTableCount++;
|
|
}
|
|
if (wTable) {
|
|
adjacentTableCount++;
|
|
}
|
|
if (adjacentTableCount >= 2) {
|
|
if (nTable && eTable && !sTable && !wTable) {
|
|
return (BlockState) defaultBlockState().setValue(TYPE, TableType.sw_corner);
|
|
}
|
|
if (nTable && wTable && !sTable && !eTable) {
|
|
return (BlockState) defaultBlockState().setValue(TYPE, TableType.se_corner);
|
|
}
|
|
if (sTable && eTable && !nTable && !wTable) {
|
|
return (BlockState) defaultBlockState().setValue(TYPE, TableType.nw_corner);
|
|
}
|
|
if (sTable && wTable && !nTable && !eTable) {
|
|
return (BlockState) defaultBlockState().setValue(TYPE, TableType.ne_corner);
|
|
}
|
|
return (BlockState) defaultBlockState().setValue(TYPE, TableType.mid);
|
|
}
|
|
if (adjacentTableCount == 1) {
|
|
if (nTable) {
|
|
return (BlockState) defaultBlockState().setValue(TYPE, TableType.s_end);
|
|
}
|
|
if (eTable) {
|
|
return (BlockState) defaultBlockState().setValue(TYPE, TableType.w_end);
|
|
}
|
|
if (sTable) {
|
|
return (BlockState) defaultBlockState().setValue(TYPE, TableType.n_end);
|
|
}
|
|
if (wTable) {
|
|
return (BlockState) defaultBlockState().setValue(TYPE, TableType.e_end);
|
|
}
|
|
}
|
|
return defaultBlockState();
|
|
}
|
|
|
|
@Nullable
|
|
public BlockState getStateForPlacement(BlockPlaceContext context) {
|
|
return getNewState(context.getLevel(), context.getClickedPos());
|
|
}
|
|
|
|
public VoxelShape getShape(BlockState bs, BlockGetter reader, BlockPos pos, CollisionContext sel) {
|
|
return SHAPE_NORMAL;
|
|
}
|
|
}
|