Get rid of up and down facings
This commit is contained in:
parent
1534eae1ab
commit
52ae451a23
@ -6,11 +6,20 @@ import net.minecraft.world.level.block.Block;
|
||||
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 org.apache.commons.lang3.ArrayUtils;
|
||||
import ru.dbotthepony.mc.otm.OverdriveThatMatters;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Arrays;
|
||||
|
||||
public abstract class BlockMatteryRotatable extends BlockMattery {
|
||||
public static final EnumProperty<Direction> FACING = EnumProperty.create("facing", Direction.class);
|
||||
public static final EnumProperty<Direction> FACING = EnumProperty.create(
|
||||
"facing",
|
||||
Direction.class,
|
||||
Direction.SOUTH,
|
||||
Direction.WEST,
|
||||
Direction.NORTH,
|
||||
Direction.EAST);
|
||||
|
||||
public BlockMatteryRotatable() {
|
||||
super();
|
||||
@ -26,7 +35,19 @@ public abstract class BlockMatteryRotatable extends BlockMattery {
|
||||
@Nullable
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockPlaceContext context) {
|
||||
return this.defaultBlockState().setValue(FACING, faceToPlayer(context) ? context.getNearestLookingDirection().getOpposite() : context.getNearestLookingDirection());
|
||||
Direction find_first = null;
|
||||
|
||||
for (Direction direction : context.getNearestLookingDirections()) {
|
||||
if (FACING.getPossibleValues().contains(direction)) {
|
||||
find_first = direction;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (find_first == null)
|
||||
return this.defaultBlockState();
|
||||
|
||||
return this.defaultBlockState().setValue(FACING, faceToPlayer(context) ? find_first.getOpposite() : find_first);
|
||||
}
|
||||
|
||||
public boolean faceToPlayer(BlockPlaceContext context) {
|
||||
|
Loading…
Reference in New Issue
Block a user